From ed1df88e880911207fa97e3b430ca51b9267f9ac Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Sun, 14 Oct 2018 15:40:11 +0200 Subject: [PATCH 01/91] The basic modules system works. - Mowed all old classes to a temp. old package for clarity. - Added a modules system to the game. - Added config, commands, and sidebar integration for the modules. - Created a few core modules (unfinished for most). --- pom.xml | 12 +- .../amaury/UHCReloaded/UHCReloaded.java | 502 +++++++++++++++--- .../carrade/amaury/UHCReloaded/UHConfig.java | 10 +- .../amaury/UHCReloaded/core/ModuleInfo.java | 125 +++++ .../UHCReloaded/core/ModuleWrapper.java | 243 +++++++++ .../amaury/UHCReloaded/core/UHModule.java | 84 +++ .../UHCReloaded/events/TimerEndsEvent.java | 2 +- .../UHCReloaded/events/TimerStartsEvent.java | 2 +- .../UHCReloaded/events/UHGameEndsEvent.java | 2 +- .../UHCReloaded/events/UHTeamDeathEvent.java | 2 +- .../events/modules/AllModulesLoadedEvent.java | 73 +++ .../events/modules/ModuleLoadedEvent.java | 73 +++ .../events/modules/ModuleUnloadedEvent.java | 76 +++ .../carrade/amaury/UHCReloaded/game/Cage.java | 2 +- .../UHCReloaded/game/UHGameManager.java | 14 +- .../UHCReloaded/modules/core/game/Config.java | 48 ++ .../modules/core/game/GameModule.java | 87 +++ .../modules/core/game/GamePhase.java | 59 ++ .../game/events/GamePhaseChangedEvent.java | 75 +++ .../modules/core/modules/ModulesCommand.java | 55 ++ .../core/modules/ModulesManagerModule.java | 65 +++ .../modules/core/sidebar/Config.java | 51 ++ .../modules/core/sidebar/GameSidebar.java | 80 +++ .../modules/core/sidebar/SidebarInjector.java | 335 ++++++++++++ .../modules/core/sidebar/SidebarModule.java | 67 +++ .../modules/core/teams/Config.java | 47 ++ .../modules/core/teams/TeamsModule.java | 69 +++ .../{ => old}/borders/BorderManager.java | 12 +- .../{ => old}/borders/MapShape.java | 14 +- .../CannotGenerateWallsException.java | 2 +- .../exceptions/UnknownWallGenerator.java | 2 +- .../generators/CircularWallGenerator.java | 2 +- .../generators/SquaredWallGenerator.java | 2 +- .../borders/generators/WallGenerator.java | 2 +- .../borders/generators/WallPosition.java | 2 +- .../borders/shapes/CircularMapShape.java | 2 +- .../borders/shapes/MapShapeDescriptor.java | 2 +- .../borders/shapes/SquaredMapShape.java | 2 +- .../worldborders/BrettflanWorldBorder.java | 4 +- .../borders/worldborders/FakeWorldBorder.java | 4 +- .../worldborders/VanillaWorldBorder.java | 4 +- .../borders/worldborders/WorldBorder.java | 4 +- .../{ => old}/commands/UHCommandExecutor.java | 18 +- .../commands/GlobalMessageCommand.java | 10 +- .../commands/commands/JoinCommand.java | 8 +- .../commands/commands/LeaveCommand.java | 6 +- .../commands/commands/TeamMessageCommand.java | 10 +- .../commands/commands/TeamsCommand.java | 6 +- .../commands/commands/ToggleChatCommand.java | 12 +- .../commands/commands/UHRootCommand.java | 54 +- .../commands/categories/Category.java | 2 +- .../commands/commands/uh/UHAboutCommand.java | 14 +- .../commands/commands/uh/UHBorderCommand.java | 18 +- .../commands/uh/UHFeedAllCommand.java | 10 +- .../commands/commands/uh/UHFeedCommand.java | 10 +- .../commands/commands/uh/UHFinishCommand.java | 10 +- .../commands/commands/uh/UHFreezeCommand.java | 12 +- .../commands/uh/UHGenerateWallsCommand.java | 14 +- .../commands/uh/UHHealAllCommand.java | 10 +- .../commands/commands/uh/UHHealCommand.java | 10 +- .../commands/commands/uh/UHInfosCommand.java | 14 +- .../commands/commands/uh/UHKillCommand.java | 10 +- .../commands/uh/UHLoadPlayersCommand.java | 12 +- .../commands/uh/UHResurrectCommand.java | 10 +- .../commands/commands/uh/UHRulesCommand.java | 10 +- .../commands/commands/uh/UHShiftCommand.java | 10 +- .../commands/commands/uh/UHSpawnsCommand.java | 22 +- .../commands/uh/UHSpectatorsCommand.java | 14 +- .../commands/commands/uh/UHStartCommand.java | 14 +- .../commands/commands/uh/UHTPBackCommand.java | 10 +- .../commands/commands/uh/UHTPCommand.java | 14 +- .../commands/uh/UHTPSpawnCommand.java | 10 +- .../commands/commands/uh/UHTeamCommand.java | 30 +- .../commands/commands/uh/UHTimersCommand.java | 30 +- .../uh/border/UHBorderCheckCommand.java | 8 +- .../uh/border/UHBorderGetCommand.java | 10 +- .../uh/border/UHBorderSetCommand.java | 12 +- .../uh/border/UHBorderWarningCommand.java | 10 +- .../uh/spawns/UHSpawnsAddCommand.java | 10 +- .../uh/spawns/UHSpawnsDumpCommand.java | 10 +- .../uh/spawns/UHSpawnsGenerateCommand.java | 16 +- .../uh/spawns/UHSpawnsListCommand.java | 12 +- .../uh/spawns/UHSpawnsRemoveCommand.java | 10 +- .../uh/spawns/UHSpawnsResetCommand.java | 10 +- .../commands/uh/team/UHTeamAddCommand.java | 16 +- .../commands/uh/team/UHTeamBannerCommand.java | 12 +- .../uh/team/UHTeamBannerResetCommand.java | 12 +- .../commands/uh/team/UHTeamGUICommand.java | 10 +- .../commands/uh/team/UHTeamJoinCommand.java | 18 +- .../commands/uh/team/UHTeamLeaveCommand.java | 12 +- .../commands/uh/team/UHTeamListCommand.java | 12 +- .../commands/uh/team/UHTeamRemoveCommand.java | 14 +- .../commands/uh/team/UHTeamResetCommand.java | 10 +- .../commands/uh/team/UHTeamSpyCommand.java | 8 +- .../uh/timers/UHTimersAddCommand.java | 10 +- .../uh/timers/UHTimersDisplayCommand.java | 12 +- .../uh/timers/UHTimersHideCommand.java | 12 +- .../uh/timers/UHTimersListCommand.java | 12 +- .../uh/timers/UHTimersPauseCommand.java | 12 +- .../uh/timers/UHTimersRemoveCommand.java | 12 +- .../uh/timers/UHTimersResumeCommand.java | 12 +- .../uh/timers/UHTimersSetCommand.java | 12 +- .../uh/timers/UHTimersStartCommand.java | 12 +- .../uh/timers/UHTimersStopCommand.java | 12 +- .../commands/core/AbstractCommand.java | 12 +- .../core/AbstractCommandExecutor.java | 8 +- .../commands/core/annotations/Command.java | 2 +- .../CannotExecuteCommandException.java | 4 +- .../commands/core/utils/CommandUtils.java | 6 +- .../integration/UHDynmapIntegration.java | 6 +- .../integration/UHProtocolLibIntegration.java | 4 +- .../UHProtocolLibIntegrationWrapper.java | 2 +- .../UHSpectatorPlusIntegration.java | 2 +- .../integration/UHWorldBorderIntegration.java | 2 +- .../listeners/BeforeGameListener.java | 4 +- .../{ => old}/listeners/CraftingListener.java | 8 +- .../{ => old}/listeners/FreezerListener.java | 2 +- .../{ => old}/listeners/GameListener.java | 8 +- .../{ => old}/listeners/GameplayListener.java | 4 +- .../{ => old}/listeners/PacketsListener.java | 2 +- .../{ => old}/listeners/SpawnsListener.java | 2 +- .../UHCReloaded/{ => old}/misc/Freezer.java | 4 +- .../{ => old}/misc/MOTDManager.java | 4 +- .../{ => old}/misc/OfflinePlayersLoader.java | 2 +- .../misc/PlayerListHeaderFooterManager.java | 2 +- .../{ => old}/misc/RulesManager.java | 4 +- .../misc/RuntimeCommandsExecutor.java | 4 +- .../UHCReloaded/{ => old}/protips/ProTip.java | 2 +- .../{ => old}/protips/ProTips.java | 2 +- .../{ => old}/recipes/RecipeUtil.java | 2 +- .../{ => old}/recipes/RecipesManager.java | 2 +- .../spectators/SPlusSpectatorsManager.java | 2 +- .../spectators/SpectatorsManager.java | 2 +- .../spectators/VanillaSpectatorsManager.java | 2 +- .../{ => old}/task/BorderWarningTask.java | 4 +- .../{ => old}/task/CancelBrewTask.java | 2 +- .../task/FireworksOnWinnersTask.java | 2 +- .../task/ScheduledCommandsExecutorTask.java | 2 +- .../{ => old}/task/UpdateTimerTask.java | 4 +- .../{ => old}/teams/TeamChatManager.java | 4 +- .../{ => old}/teams/TeamColor.java | 2 +- .../{ => old}/teams/TeamManager.java | 9 +- .../{gui => old}/teams/TeamsSelectorGUI.java | 8 +- .../UHCReloaded/{ => old}/teams/UHTeam.java | 2 +- .../teams/builder/TeamBuilderBaseGUI.java | 4 +- .../builder/TeamBuilderStepColorGUI.java | 4 +- .../teams/builder/TeamBuilderStepNameGUI.java | 4 +- .../builder/TeamBuilderStepPlayersGUI.java | 10 +- .../teams/editor/TeamActionGUI.java | 4 +- .../teams/editor/TeamEditColorGUI.java | 8 +- .../teams/editor/TeamEditDeleteGUI.java | 6 +- .../teams/editor/TeamEditGUI.java | 4 +- .../teams/editor/TeamEditMembersGUI.java | 6 +- .../{ => old}/timers/TimerManager.java | 2 +- .../UHCReloaded/{ => old}/timers/UHTimer.java | 2 +- .../UHCReloaded/scoreboard/GameSidebar.java | 10 +- .../scoreboard/SidebarPlayerCache.java | 2 +- .../generators/GridSpawnPointsGenerator.java | 2 +- .../RandomSpawnPointsGenerator.java | 2 +- .../UHCReloaded/utils/ModulesUtils.java | 82 +++ src/main/resources/plugin.yml | 49 +- .../UHCReloaded/SidebarInjectorTest.java | 229 ++++++++ 162 files changed, 3034 insertions(+), 661 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/BorderManager.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/MapShape.java (87%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/exceptions/CannotGenerateWallsException.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/exceptions/UnknownWallGenerator.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/generators/CircularWallGenerator.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/generators/SquaredWallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/generators/WallGenerator.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/generators/WallPosition.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/shapes/CircularMapShape.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/shapes/MapShapeDescriptor.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/shapes/SquaredMapShape.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/worldborders/BrettflanWorldBorder.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/worldborders/FakeWorldBorder.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/worldborders/VanillaWorldBorder.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/borders/worldborders/WorldBorder.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/UHCommandExecutor.java (77%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/GlobalMessageCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/JoinCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/LeaveCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/TeamMessageCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/TeamsCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/ToggleChatCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/UHRootCommand.java (63%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/categories/Category.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHAboutCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHBorderCommand.java (81%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHFeedAllCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHFeedCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHFinishCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHFreezeCommand.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHGenerateWallsCommand.java (87%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHHealAllCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHHealCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHInfosCommand.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHKillCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHLoadPlayersCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHResurrectCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHRulesCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHShiftCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHSpawnsCommand.java (79%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHSpectatorsCommand.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHStartCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHTPBackCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHTPCommand.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHTPSpawnCommand.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHTeamCommand.java (77%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/UHTimersCommand.java (73%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/border/UHBorderCheckCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/border/UHBorderGetCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/border/UHBorderSetCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/border/UHBorderWarningCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsAddCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsDumpCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsListCommand.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/spawns/UHSpawnsResetCommand.java (86%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamAddCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamBannerCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamBannerResetCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamGUICommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamJoinCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamLeaveCommand.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamListCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamRemoveCommand.java (86%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamResetCommand.java (86%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/team/UHTeamSpyCommand.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersAddCommand.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersDisplayCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersHideCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersListCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersPauseCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersRemoveCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersResumeCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersSetCommand.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersStartCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/commands/uh/timers/UHTimersStopCommand.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/core/AbstractCommand.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/core/AbstractCommandExecutor.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/core/annotations/Command.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/core/exceptions/CannotExecuteCommandException.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/commands/core/utils/CommandUtils.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/integration/UHDynmapIntegration.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/integration/UHProtocolLibIntegration.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/integration/UHProtocolLibIntegrationWrapper.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/integration/UHSpectatorPlusIntegration.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/integration/UHWorldBorderIntegration.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/BeforeGameListener.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/CraftingListener.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/FreezerListener.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/GameListener.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/GameplayListener.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/PacketsListener.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/listeners/SpawnsListener.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/Freezer.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/MOTDManager.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/OfflinePlayersLoader.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/PlayerListHeaderFooterManager.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/RulesManager.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/misc/RuntimeCommandsExecutor.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/protips/ProTip.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/protips/ProTips.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/recipes/RecipeUtil.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/recipes/RecipesManager.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/spectators/SPlusSpectatorsManager.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/spectators/SpectatorsManager.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/spectators/VanillaSpectatorsManager.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/task/BorderWarningTask.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/task/CancelBrewTask.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/task/FireworksOnWinnersTask.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/task/ScheduledCommandsExecutorTask.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/task/UpdateTimerTask.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/teams/TeamChatManager.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/teams/TeamColor.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/teams/TeamManager.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/TeamsSelectorGUI.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/teams/UHTeam.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/builder/TeamBuilderBaseGUI.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/builder/TeamBuilderStepColorGUI.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/builder/TeamBuilderStepNameGUI.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/builder/TeamBuilderStepPlayersGUI.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/editor/TeamActionGUI.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/editor/TeamEditColorGUI.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/editor/TeamEditDeleteGUI.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/editor/TeamEditGUI.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{gui => old}/teams/editor/TeamEditMembersGUI.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/timers/TimerManager.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/timers/UHTimer.java (99%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java create mode 100644 src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java diff --git a/pom.xml b/pom.xml index 69dc8c6..d056f6f 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 4.0.0 eu.carrade.amaury UHCReloaded - 1.5 + 2.0-SNAPSHOT UHCReloaded Ultra Hardcore plugin https://github.com/zDevelopers/UHPlugin/ @@ -99,6 +99,7 @@ fr.zcraft:zlib + fr.zcraft:zteams @@ -106,6 +107,10 @@ fr.zcraft.zlib eu.carrade.amaury.UHCReloaded.zlib + + fr.zcraft.zteams + eu.carrade.amaury.UHCReloaded.zteams + @@ -159,6 +164,11 @@ zlib 0.99-SNAPSHOT + + fr.zcraft + zteams + 1.0-SNAPSHOT + com.wimbli.WorldBorder WorldBorder diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 34c2643..f81ad28 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -31,47 +31,83 @@ */ package eu.carrade.amaury.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.BorderManager; -import eu.carrade.amaury.UHCReloaded.commands.UHCommandExecutor; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.events.modules.AllModulesLoadedEvent; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import eu.carrade.amaury.UHCReloaded.integration.UHDynmapIntegration; -import eu.carrade.amaury.UHCReloaded.integration.UHProtocolLibIntegrationWrapper; -import eu.carrade.amaury.UHCReloaded.integration.UHSpectatorPlusIntegration; -import eu.carrade.amaury.UHCReloaded.integration.UHWorldBorderIntegration; -import eu.carrade.amaury.UHCReloaded.listeners.BeforeGameListener; -import eu.carrade.amaury.UHCReloaded.listeners.CraftingListener; -import eu.carrade.amaury.UHCReloaded.listeners.GameListener; -import eu.carrade.amaury.UHCReloaded.listeners.GameplayListener; -import eu.carrade.amaury.UHCReloaded.listeners.SpawnsListener; -import eu.carrade.amaury.UHCReloaded.misc.Freezer; -import eu.carrade.amaury.UHCReloaded.misc.MOTDManager; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.misc.PlayerListHeaderFooterManager; -import eu.carrade.amaury.UHCReloaded.misc.RulesManager; -import eu.carrade.amaury.UHCReloaded.misc.RuntimeCommandsExecutor; -import eu.carrade.amaury.UHCReloaded.recipes.RecipesManager; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesManagerModule; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; +import eu.carrade.amaury.UHCReloaded.old.borders.BorderManager; +import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; +import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; +import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; +import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; +import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; +import eu.carrade.amaury.UHCReloaded.old.misc.MOTDManager; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.misc.PlayerListHeaderFooterManager; +import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager; +import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; +import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; +import eu.carrade.amaury.UHCReloaded.old.spectators.SpectatorsManager; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; +import eu.carrade.amaury.UHCReloaded.old.timers.TimerManager; import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; import eu.carrade.amaury.UHCReloaded.spawns.SpawnsManager; -import eu.carrade.amaury.UHCReloaded.spectators.SpectatorsManager; -import eu.carrade.amaury.UHCReloaded.task.UpdateTimerTask; -import eu.carrade.amaury.UHCReloaded.teams.TeamChatManager; -import eu.carrade.amaury.UHCReloaded.teams.TeamManager; -import eu.carrade.amaury.UHCReloaded.timers.TimerManager; +import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.Commands; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.i18n.I18n; import fr.zcraft.zlib.components.scoreboard.SidebarScoreboard; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.core.ZPlugin; -import org.bukkit.entity.Player; - +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandMap; +import org.bukkit.command.PluginCommand; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.world.WorldLoadEvent; +import org.bukkit.plugin.Plugin; +import org.bukkit.scoreboard.Scoreboard; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; -public class UHCReloaded extends ZPlugin +public class UHCReloaded extends ZPlugin implements Listener { private static UHCReloaded instance; + private Map, ModuleWrapper> modules = new HashMap<>(); + private Set loadedPriorities = new HashSet<>(); + + private Scoreboard scoreboard = null; + private TeamManager teamManager = null; private SpawnsManager spawnsManager = null; private UHGameManager gameManager = null; @@ -94,6 +130,8 @@ public class UHCReloaded extends ZPlugin private UHDynmapIntegration dynmapintegration = null; private UHProtocolLibIntegrationWrapper protocollibintegrationwrapper = null; + private boolean worldsLoaded = false; + @Override public void onEnable() @@ -102,92 +140,384 @@ public void onEnable() this.saveDefaultConfig(); - loadComponents(SidebarScoreboard.class, Gui.class, I18n.class, UHConfig.class, OfflinePlayersLoader.class); - final String langInConfig = UHConfig.LANG.get(); - if (langInConfig == null || langInConfig.isEmpty()) + /* *** Required zLib base components *** */ + + loadComponents(UHConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, OfflinePlayersLoader.class); + + + /* *** Internationalization *** */ + + if (UHConfig.LANG.get() == null) I18n.useDefaultPrimaryLocale(); + else I18n.setPrimaryLocale(UHConfig.LANG.get()); + + I18n.setFallbackLocale(Locale.US); + + + /* *** Core events *** */ + + ZLib.registerEvents(this); + + + /* *** Core modules *** */ + + registerModules( + ModulesManagerModule.class, // Manages the modules from the game/commands + SidebarModule.class, // Manages the sidebar and provides hooks for other modules. + // Must be loaded before the game-related modules. + TeamsModule.class, // Manages the teams (for both team & solo games). + // Must be loaded before the game-related modules. + GameModule.class // Manages the game progression + ); + + + /* *** Config modules *** */ + + UHConfig.MODULES.forEach((BiConsumer) this::registerModule); + + + /* *** Loads modules from startup time *** */ + + loadModules(ModuleInfo.ModuleLoadTime.STARTUP); + + + /* *** Loads modules from post-world time if worlds are loaded (server reloaded) *** */ + + if (!getServer().getWorlds().isEmpty()) + { + scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); + + loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); + collectCommandsFromModules(); + + worldsLoaded = true; + } + + + /* *** Ready *** */ + + PluginLogger.info(I.t("Ultra Hardcore plugin loaded.")); + } + + + + /** + * Registers an UHCReloaded module (or many). It is not enabled by this method. + * + * @param modules the module's class, that must accept a zero-arguments constructor. + */ + @SafeVarargs + public final void registerModules(final Class... modules) + { + Arrays.stream(modules).forEach(module -> registerModule(module, true)); + } + + /** + * Registers an UHCReloaded module (or many). It is not enabled by this method. + * + * @param module the module's class, that must accept a zero-arguments constructor. + * @param enableAtStartup {@code true} if this module, according to the configuration file, should be loaded at startup. + */ + private void registerModule(final Class module, final boolean enableAtStartup) + { + final String name, description; + final ModuleInfo.ModuleLoadTime priority; + final boolean internal; + + final Class moduleConfiguration; + final String settingsFileName; + + final ModuleInfo info = module.getAnnotation(ModuleInfo.class); + + if (info == null) { - //i18n = new eu.carrade.amaury.UHCReloaded.i18n.I18n(this); - I18n.useDefaultPrimaryLocale(); + name = ""; + description = ""; + internal = false; + priority = ModuleInfo.ModuleLoadTime.POST_WORLD; + moduleConfiguration = null; + settingsFileName = null; } else { - //i18n = new eu.carrade.amaury.UHCReloaded.i18n.I18n(this, langInConfig); - I18n.setPrimaryLocale(Locale.forLanguageTag(langInConfig)); + name = info.name(); + description = info.description(); + internal = info.internal(); + priority = info.when(); + moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); + settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); } - I18n.setFallbackLocale(Locale.US); + this.modules.put(module, new ModuleWrapper( + name, description, internal, enableAtStartup, priority, module, moduleConfiguration, settingsFileName)); + } + /** + * Registers an UHCReloaded module. It is not enabled by this method. + * + * It tries to load the following classes (in this order, taking the first existing): + * + * - eu.carrade.amaury.UHCReloaded.modules.[name] + * - eu.carrade.amaury.UHCReloaded.modules.[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module + * - [name] + * + * @param module the module's class name; the class must accept a zero-arguments constructor. + */ + public void registerModule(final String module) + { + registerModule(module, true); + } - wbintegration = new UHWorldBorderIntegration(); - spintegration = new UHSpectatorPlusIntegration(); - dynmapintegration = new UHDynmapIntegration(); + /** + * Registers an UHCReloaded module. It is not enabled by this method. + * + * It tries to load the following classes (in this order, taking the first existing): + * + * - eu.carrade.amaury.UHCReloaded.modules.[name] + * - eu.carrade.amaury.UHCReloaded.modules.[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module + * - [name] + * + * @param module the module's class name; the class must accept a zero-arguments constructor. + * @param enabledAtStartup {@code true} if this module, according to the configuration file, should be loaded at startup. + */ + private void registerModule(final String module, boolean enabledAtStartup) + { + final Class moduleClass = ModulesUtils.getClassFromName( + module, + "eu.carrade.amaury.UHCReloaded.modules", + "Module", + UHModule.class + ); + + if (moduleClass != null) + { + registerModules(moduleClass); + } + else + { + PluginLogger.error("Error registering a module: unable to find a module named {0} in the class path. Maybe you spelled it wrong?", module); + } + } + + + + /** + * Loads registered modules. Internal modules will always be loaded first. + * + * @param loadTime Loads the modules registered to be loaded at that given time. + */ + private void loadModules(final ModuleInfo.ModuleLoadTime loadTime) + { + if (loadedPriorities.contains(loadTime)) return; + + // Loads all internal modules first + modules.values().stream() + .filter(module -> module.getWhen() == loadTime) + .filter(module -> module.get() == null || !module.get().isEnabled()) + .filter(ModuleWrapper::isInternal) + .forEach(ModuleWrapper::enable); + + // Then loads other modules + modules.values().stream() + .filter(module -> module.getWhen() == loadTime) + .filter(module -> module.get() == null || !module.get().isEnabled()) + .filter(module -> !module.isInternal()) + .forEach(ModuleWrapper::enable); + + loadedPriorities.add(loadTime); + + getServer().getPluginManager().callEvent(new AllModulesLoadedEvent(loadTime)); + } + + /** + * Loads a module from its class. + * + * @param moduleClass The module's class. + * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or + * {@link #registerModule(String)} before. + */ + public void loadModule(Class moduleClass) + { + final ModuleWrapper module = modules.get(moduleClass); - // Needed to avoid a NoClassDefFoundError. - // I don't like this way of doing this, but else, the plugin will not load without ProtocolLib. - protocollibintegrationwrapper = new UHProtocolLibIntegrationWrapper(this); + if (module == null) + throw new IllegalArgumentException("The module " + moduleClass.getName() + " was not registered."); + module.enable(); + } - spectatorsManager = SpectatorsManager.getInstance(); - teamManager = new TeamManager(); - gameManager = new UHGameManager(this); - spawnsManager = new SpawnsManager(this); - borderManager = new BorderManager(this); - recipesManager = new RecipesManager(this); - teamChatManager = new TeamChatManager(this); - timerManager = new TimerManager(); + /** + * Unloads a module from its class. + * + * @param moduleClass The module's class. + * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or + * {@link #registerModule(String)} before. + */ + public void unloadModule(Class moduleClass) + { + final ModuleWrapper module = modules.get(moduleClass); - runtimeCommandsExecutor = new RuntimeCommandsExecutor(); + if (module == null) + throw new IllegalArgumentException("The module " + moduleClass.getName() + " was not registered."); - freezer = new Freezer(this); + module.disable(); + } - scoreboardManager = new ScoreboardManager(this); - motdManager = new MOTDManager(this); - rulesManager = new RulesManager(); - playerListHeaderFooterManager = new PlayerListHeaderFooterManager(); + /** + * Gets a module's instance. This may return null if the module is not currently + * enabled. + * + * @param moduleClass The module's class. + * @param The module's type. + * + * @return The module's instance. + */ + public static M getModule(Class moduleClass) + { + final ModuleWrapper module = get().modules.get(moduleClass); + + if (module == null) return null; + else return (M) module.get(); + } - UHCommandExecutor executor = new UHCommandExecutor(this); - for (String commandName : getDescription().getCommands().keySet()) + + + /** + * @return The Bukkit scoreboard to use for everything. + */ + public Scoreboard getScoreboard() + { + return scoreboard; + } + + + + @EventHandler (priority = EventPriority.LOWEST) + public final void onWorldsLoaded(WorldLoadEvent e) + { + if (!worldsLoaded) { - getCommand(commandName).setExecutor(executor); - getCommand(commandName).setTabCompleter(executor); + RunTask.nextTick(() -> { + loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); + collectCommandsFromModules(); + }); + + worldsLoaded = true; + scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); } + } - ZLib.registerEvents(new GameListener()); - ZLib.registerEvents(new GameplayListener()); - ZLib.registerEvents(new CraftingListener(this)); - ZLib.registerEvents(new SpawnsListener()); - ZLib.registerEvents(new BeforeGameListener()); + @EventHandler + public void onGamePhaseChanged(final GamePhaseChangedEvent ev) + { + switch (ev.getNewPhase()) + { + case IN_GAME: + loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_START); + break; - // The freezer listener is registered by the freezer when it is needed. + case END: + loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_END); + break; + } + } - recipesManager.registerRecipes(); - gameManager.initEnvironment(); + @EventHandler (priority = EventPriority.LOWEST) + public final void onPlayerJoin(final PlayerJoinEvent ev) + { + ev.getPlayer().setScoreboard(scoreboard); + } - motdManager.updateMOTDBeforeStart(); - // In case of reload - for (Player player : getServer().getOnlinePlayers()) + + @SuppressWarnings ("unchecked") + private void collectCommandsFromModules() + { + Commands.register("uh", modules.values().stream() + .filter(ModuleWrapper::isEnabled) + .map(module -> module.get().getCommands()) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .toArray(Class[]::new)); + + final Map> commandAliases = modules.values().stream() + .filter(ModuleWrapper::isEnabled) + .map(module -> module.get().getCommandsAliases()) + .filter(Objects::nonNull) + .flatMap(commandsAliases -> commandsAliases.entrySet().stream()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a)); + + // As they are not registered in the plugin.yml, for each command, we have to force-register + // the name manually. + + final List pluginCommands = new ArrayList<>(); + final Set registered = new HashSet<>(); + + try + { + final Constructor pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); + pluginCommandConstructor.setAccessible(true); + + for (final String commandName : commandAliases.keySet()) + { + try + { + pluginCommands.add(pluginCommandConstructor.newInstance(commandName, this)); + registered.add(commandName); + } + catch (InstantiationException | InvocationTargetException | IllegalAccessException e) + { + PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandName); + } + } + + try + { + final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); + + String prefix = getDescription().getPrefix(); + if (prefix == null) prefix = getDescription().getName().toLowerCase(); + + commandMap.registerAll(prefix, pluginCommands); + } + catch (NoSuchFieldException | IllegalAccessException e) + { + PluginLogger.error("Unable to retrieve Bukkit's command map, is this version supported by UHCReloaded?", e); + } + } + catch (NoSuchMethodException | SecurityException e) { - gameManager.initPlayer(player); + PluginLogger.error("Unable to register plugin commands: unable to retrieve PluginCommand's constructor. Is this version supported by UHCReloaded?", e); } - // Imports spawnpoints from the config. - this.spawnsManager.importSpawnPointsFromConfig(); + // Now that all commands are registered into Bukkit, we can register them into zLib. + + commandAliases.forEach((name, klass) -> + { + // Bukkit registration failed? + if (!registered.contains(name)) return; + + Commands.registerShortcut("uh", klass, name); + }); + } - // Imports teams from the config. - this.teamManager.importTeamsFromConfig(); - // Starts the task that updates the timers. - // Started here, so a timer can be displayed before the start of the game - // (example: countdown before the start). - new UpdateTimerTask().runTaskTimer(this, 20L, 20L); - // Schedule commands - runtimeCommandsExecutor.registerCommandsInScheduler(RuntimeCommandsExecutor.AFTER_SERVER_START); - getLogger().info(I.t("Ultra Hardcore plugin loaded.")); - } /** * Returns the team manager. @@ -341,4 +671,12 @@ public static UHCReloaded get() { return instance; } + + /** + * @return A view on all registered modules. + */ + public Collection getModules() + { + return modules.values(); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index d83b0ab..a3ae421 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -1,8 +1,8 @@ package eu.carrade.amaury.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; import eu.carrade.amaury.UHCReloaded.game.Cage; -import eu.carrade.amaury.UHCReloaded.teams.TeamManager; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.configuration.Configuration; import fr.zcraft.zlib.components.configuration.ConfigurationItem; @@ -15,12 +15,16 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.util.Vector; +import java.util.Locale; + import static fr.zcraft.zlib.components.configuration.ConfigurationItem.*; public class UHConfig extends Configuration { - static public final ConfigurationItem LANG = item("lang", ""); + static public final ConfigurationItem LANG = item("lang", Locale.class); + + static public final ConfigurationMap MODULES = map("modules", String.class, Boolean.class); static public final EpisodesSection EPISODES = section("episodes", EpisodesSection.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java new file mode 100644 index 0000000..0972341 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -0,0 +1,125 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target ({ElementType.TYPE}) +public @interface ModuleInfo +{ + /** + * @return A name for the module (optional). + */ + String name() default ""; + + /** + * @return A short description for this module. + */ + String description() default ""; + + /** + * @return When this module should load. + */ + ModuleLoadTime when() default ModuleLoadTime.POST_WORLD; + + /** + * @return The configuration class to initialize (if any). + * ConfigurationInstance.class is used as a default value to represent no settings as null values are + * not allowed and classes will always be subclasses of this one. + */ + Class settings() default ConfigurationInstance.class; + + /** + * @return The settings's filename (without the .yml extension). + * If empty/not provided, derived from the class name. + */ + String settings_filename() default ""; + + /** + * @return {@code true} if this module is an internal core module + * that should always be loaded first. + */ + boolean internal() default false; + + /** + * @return {@code true} if the module can be disabled and re-enabled. This reflects the status change + * from inside the game, as all modules can always be disabled on the configuration file (or not loaded + * at all). + * + * If this is {@code true}, when disabled, a module will have its {@link UHModule#onDisable() onDisable()} + * method called, and after that, its listener will be unregistered and the module instance removed from the system. + * + * When re-enabled, a whole new instance will be created. + */ + boolean can_be_disabled() default true; + + + enum ModuleLoadTime + { + /** + * Loads the module at startup, before the worlds are loaded. + * + * Please note that most core modules (an localization) are not loaded at this point. Use that + * for modules altering the world generation. + */ + STARTUP, + + /** + * Loads the module after the world(s), or immediately if the plugin is reloaded. + * The thing is, all worlds will be loaded when the module is. + */ + POST_WORLD, + + /** + * Loads the module when the game starts. + * + * Modules loaded this late cannot register new commands. You must use a load time before + * {@link #POST_WORLD} (included) to do so. + */ + ON_GAME_START, + + /** + * Loads the module when the game ends. + * + * Modules loaded this late cannot register new commands. You must use a load time before + * {@link #POST_WORLD} (included) to do so. + */ + ON_GAME_END + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java new file mode 100644 index 0000000..239c1fc --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -0,0 +1,243 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import com.google.common.base.CaseFormat; +import eu.carrade.amaury.UHCReloaded.events.modules.ModuleLoadedEvent; +import eu.carrade.amaury.UHCReloaded.events.modules.ModuleUnloadedEvent; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + + +public class ModuleWrapper +{ + private final String name; + private final String description; + private final ModuleInfo.ModuleLoadTime when; + + private final Class moduleClass; + + private final Class moduleConfiguration; + private final String settingsFileName; + + private final boolean internal; + + private boolean enabledAtStartup; + + private UHModule instance = null; + + public ModuleWrapper( + final String name, + final String description, + final boolean internal, + final boolean enabledAtStartup, + final ModuleInfo.ModuleLoadTime when, + final Class moduleClass, + final Class moduleConfiguration, + final String settingsFileName) + { + this.name = name; + this.description = description; + this.internal = internal; + this.enabledAtStartup = enabledAtStartup; + this.when = when; + this.moduleClass = moduleClass; + this.moduleConfiguration = moduleConfiguration; + this.settingsFileName = settingsFileName; + + loadConfiguration(); + } + + /** + * Enables this module. + */ + public void enable() + { + instance = ZLib.loadComponent(moduleClass); + Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(instance)); + } + + /** + * Disable this module. + */ + public void disable() + { + if (instance == null) return; + + instance.setEnabled(false); + ZLib.unregisterEvents(instance); + + Bukkit.getPluginManager().callEvent(new ModuleUnloadedEvent(instance)); + + instance = null; + } + + /** + * If this module was not yet loaded (e.g. if we're pre-game and the module loads + * when the game starts), sets the module to be loaded (or not) when the time comes. + * + * @param enabledAtStartup {@code true} to register this module to be enabled at the right time. + */ + public void setEnabledAtStartup(boolean enabledAtStartup) + { + if (instance != null) return; + + this.enabledAtStartup = enabledAtStartup; + } + + /** + * @return A name for this module. Either the provided name using {@link ModuleInfo} or a name derived from the class name. + */ + public String getName() + { + return name != null && !name.isEmpty() + ? name + : StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); + } + + /** + * @return A description for the module, or {@code null} if none provided. + */ + public String getDescription() + { + return description != null && !description.isEmpty() ? description : null; + } + + /** + * @return When this module should be loaded. + */ + public ModuleInfo.ModuleLoadTime getWhen() + { + return when; + } + + /** + * @return This module's base class. + */ + public Class getModuleClass() + { + return moduleClass; + } + + /** + * @return A {@link File} representing the configuration file on the server's filesystem. + */ + private File getConfigurationFile() + { + final String settingsFileName; + + if (this.settingsFileName != null) + { + settingsFileName = this.settingsFileName + ".yml"; + } + else + { + settingsFileName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, moduleClass.getSimpleName()) + ".yml"; + } + + return new File(ZLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); + } + + /** + * Loads the configuration from its file and initialize the class. + */ + private void loadConfiguration() + { + if (moduleConfiguration != null ) + { + final File settingsFile = getConfigurationFile(); + try + { + if (!settingsFile.exists()) + { + try + { + settingsFile.getParentFile().mkdirs(); + settingsFile.createNewFile(); + } + catch (IOException e) + { + PluginLogger.error("Cannot create and populate {0}'s module configuration file - using default values.", e, getName()); + } + } + + final ConfigurationInstance settings = Reflection.instantiate(moduleConfiguration, settingsFile); + settings.setEnabled(true); + settings.save(); + } + catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) + { + PluginLogger.info("Cannot initialize the configuration for the module {0} ({1})!", e, getName(), moduleClass.getName()); + } + } + } + + /** + * @return {@code true} if this module is internal. + */ + public boolean isInternal() + { + return internal; + } + + /** + * @return {@code true} if this module, according to the configuration file, should be loaded at startup. + */ + public boolean isEnabledAtStartup() + { + return enabledAtStartup; + } + + /** + * @return {@code true} if the module was loaded and enabled. + */ + public boolean isEnabled() + { + return instance != null && instance.isEnabled(); + } + + /** + * @return This module's instance. + */ + public UHModule get() + { + return instance; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java new file mode 100644 index 0000000..35f45b0 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java @@ -0,0 +1,84 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.scoreboard.Sidebar; +import fr.zcraft.zlib.core.ZLibComponent; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.util.List; +import java.util.Map; + + +public abstract class UHModule extends ZLibComponent implements Listener +{ + /** + * Called when the configuration is loaded. + */ + public void onConfigLoaded() {} + + /** + * Use this method to register sub-commands into the /uh command. + * + * @return A list of command classes to register. + */ + public List> getCommands() { return null; } + + /** + * Use this method to register new commands aliases. + * + * @return The command aliases to add, map from the alias to the command class. + */ + public Map> getCommandsAliases() { return null; } + + /** + * This method will be called before calling {@link #injectIntoSidebar(Player, SidebarInjector)} so you can + * prepare and cache lines shared between all players. + * + * Be careful as this method will be called every ten ticks. + * + * @see Sidebar#preRender() + */ + public void prepareInjectionIntoSidebar() {} + + /** + * Use this method to inject content into the game's sidebar. + * + * Be careful as this method will be called every ten ticks for each player. + * + * @param injector The injector will allows you to inject content in specific parts of the sidebar. + */ + public void injectIntoSidebar(final Player player, final SidebarInjector injector) {} +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java index c170d2c..626fc2b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.events; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java index 2476221..b4c191c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.events; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java index 1988d69..7e2eac1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.events; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java index b02ef9e..cf68d09 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.events; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java new file mode 100644 index 0000000..33b0136 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java @@ -0,0 +1,73 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.events.modules; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired when all modules registered in the config are loaded (both at startup and post-world). + */ +public class AllModulesLoadedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final ModuleInfo.ModuleLoadTime loadTime; + + public AllModulesLoadedEvent(ModuleInfo.ModuleLoadTime loadTime) + { + this.loadTime = loadTime; + } + + /** + * This event is launched for each batch of modules load. This represents the batch. + * + * @return the moment when these modules were all loaded. + */ + public ModuleInfo.ModuleLoadTime getLoadTime() + { + return loadTime; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java new file mode 100644 index 0000000..5d460ba --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java @@ -0,0 +1,73 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.events.modules; + +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired after a module was loaded. + */ +public class ModuleLoadedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final UHModule module; + + + public ModuleLoadedEvent(final UHModule module) + { + this.module = module; + } + + /** + * @return the loaded module. + */ + public UHModule getModule() + { + return module; + } + + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java new file mode 100644 index 0000000..9c59e73 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java @@ -0,0 +1,76 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.events.modules; + +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired after a module was unloaded. + * + * When this event is called, the embed instance is dying, unregistered from all + * events managers and soon-to-be-deleted. + */ +public class ModuleUnloadedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final UHModule module; + + + public ModuleUnloadedEvent(final UHModule module) + { + this.module = module; + } + + /** + * @return the unloaded module. + */ + public UHModule getModule() + { + return module; + } + + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java index 679b19d..449044f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.game; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index 9d8d8da..e285ac7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -37,13 +37,13 @@ import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.task.FireworksOnWinnersTask; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.teams.TeamManager; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; +import eu.carrade.amaury.UHCReloaded.old.task.FireworksOnWinnersTask; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java new file mode 100644 index 0000000..3e643c3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -0,0 +1,48 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public final static ConfigurationItem TOAST = ConfigurationItem.item("toast", 21); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java new file mode 100644 index 0000000..94830b0 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -0,0 +1,87 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + + +@ModuleInfo ( + name = "Game", + description = "Manages the game execution and phases", + settings = Config.class, + internal = true, + can_be_disabled = false +) +public class GameModule extends UHModule implements Listener +{ + private GamePhase phase = GamePhase.WAIT; + + private final Set players = new HashSet<>(); + private final Set spectators = new HashSet<>(); + + @Override + protected void onEnable() + { + + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + injector.injectLines( + SidebarInjector.SidebarPriority.VERY_TOP, true, + I.tn("{white}{0}{gray} player", "{white}{0}{gray} players", Bukkit.getOnlinePlayers().size(), Bukkit.getOnlinePlayers().size()) + ); + } + + public void setPhase(GamePhase phase) + { + if (this.phase != phase) + { + final GamePhase oldPhase = this.phase; + + this.phase = phase; + Bukkit.getServer().getPluginManager().callEvent(new GamePhaseChangedEvent(oldPhase, phase)); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java new file mode 100644 index 0000000..1359a45 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java @@ -0,0 +1,59 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game; + + +/** + * Represents the current phase of the game. + */ +public enum GamePhase +{ + /** + * Before the game, when the players are waiting for the game to start. + */ + WAIT, + + /** + * While the game is starting (can last a tick, or a long time with slow start). + */ + STARTING, + + /** + * The main phase of the game. + */ + IN_GAME, + + /** + * After the game when some player(s) won. + */ + END +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java new file mode 100644 index 0000000..c2392cf --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java @@ -0,0 +1,75 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired after a module was loaded. + */ +public class GamePhaseChangedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final GamePhase oldPhase; + private final GamePhase newPhase; + + public GamePhaseChangedEvent(final GamePhase oldPhase, final GamePhase newPhase) + { + this.oldPhase = oldPhase; + this.newPhase = newPhase; + } + + public GamePhase getOldPhase() + { + return oldPhase; + } + + public GamePhase getNewPhase() + { + return newPhase; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java new file mode 100644 index 0000000..db67d31 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -0,0 +1,55 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; + +import java.util.Collection; + + +@CommandInfo (name = "modules", usageParameters = "[list|enable|disable]", aliases = {"module"}) +public class ModulesCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final Collection modules = UHCReloaded.get().getModules(); + + success(I.tn("{0} module registered", "{0} modules registered", modules.size())); + modules.forEach(module -> info(I.t("- {0} ({1} - {2})", module.getName(), module.isEnabled() ? "enabled" : "disabled", module.getWhen()))); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java new file mode 100644 index 0000000..4888b20 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -0,0 +1,65 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules; + +import com.google.common.collect.ImmutableMap; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.commands.Command; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + + +@ModuleInfo ( + name = "Modules manager", + description = "Offers to the users a way to manage modules", + when = ModuleInfo.ModuleLoadTime.STARTUP, + can_be_disabled = false +) +public class ModulesManagerModule extends UHModule +{ + @Override + public List> getCommands() + { + return Collections.singletonList(ModulesCommand.class); + } + + @Override + public Map> getCommandsAliases() + { + return ImmutableMap.of( + "modules", ModulesCommand.class + ); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java new file mode 100644 index 0000000..f46a18e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java @@ -0,0 +1,51 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import org.bukkit.ChatColor; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public final static ConfigurationItem TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java new file mode 100644 index 0000000..b9e7620 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java @@ -0,0 +1,80 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.scoreboard.Sidebar; +import fr.zcraft.zlib.components.scoreboard.SidebarMode; +import org.bukkit.entity.Player; + +import java.util.List; + + +public class GameSidebar extends Sidebar +{ + public GameSidebar() + { + setAutoRefreshDelay(10); + setTitleMode(SidebarMode.GLOBAL); + setContentMode(SidebarMode.PER_PLAYER); + } + + @Override + public void preRender() + { + UHCReloaded.get().getModules().stream() + .filter(ModuleWrapper::isEnabled) + .map(ModuleWrapper::get) + .forEach(UHModule::prepareInjectionIntoSidebar); + } + + @Override + public List getContent(Player player) + { + final SidebarInjector injector = new SidebarInjector(); + + UHCReloaded.get().getModules().stream() + .filter(ModuleWrapper::isEnabled) + .map(ModuleWrapper::get) + .forEach(module -> module.injectIntoSidebar(player, injector)); + + return injector.buildLines(); + } + + @Override + public String getTitle(Player player) + { + return Config.TITLE.get(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java new file mode 100644 index 0000000..70879e0 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java @@ -0,0 +1,335 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + + +/** + * An instance of this class will be passed to each modules to add for a given player lines to the sidebar. + */ +public class SidebarInjector +{ + private final Set buckets = new TreeSet<>(new LinesBucketComparator()); + + /** + * Injects lines into the sidebar. + * + * @param priority The lines priority to order all injected lines. + * @param spacesAbove {@code true} to add a space above the given lines (if not first) + * @param spacesBelow {@code true} to add a space below the given lines (if not last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, final boolean spacesBelow, final Collection lines) + { + buckets.add(new LinesBucket(priority, spacesAbove, spacesBelow, new LinkedList<>(lines))); + return this; + } + + /** + * Injects lines into the sidebar. + * + * @param priority The lines priority to order all injected lines. + * @param spacesAbove {@code true} to add a space above the given lines (if not first) + * @param spacesBelow {@code true} to add a space below the given lines (if not last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, final boolean spacesBelow, final String... lines) + { + injectLines(priority, spacesAbove, spacesBelow, Arrays.asList(lines)); + return this; + } + + /** + * Injects lines into the sidebar. + * + * @param priority The lines priority to order all injected lines. + * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, final Collection lines) + { + injectLines(priority, spacesAround, spacesAround, lines); + return this; + } + + /** + * Injects lines into the sidebar. + * + * @param priority The lines priority to order all injected lines. + * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, final String... lines) + { + injectLines(priority, spacesAround, spacesAround, Arrays.asList(lines)); + return this; + } + + /** + * Injects lines into the sidebar. No spaces are added before or after. + * + * @param priority The lines priority to order all injected lines. + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final Collection lines) + { + injectLines(priority, false, false, lines); + return this; + } + + /** + * Injects lines into the sidebar. No spaces are added before or after. + * + * @param priority The lines priority to order all injected lines. + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final SidebarPriority priority, final String... lines) + { + injectLines(priority, false, false, Arrays.asList(lines)); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. + * + * @param spacesAbove {@code true} to add a space above the given lines (if not first) + * @param spacesBelow {@code true} to add a space below the given lines (if not last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, final Collection lines) + { + injectLines(SidebarPriority.MIDDLE, spacesAbove, spacesBelow, lines); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. + * + * @param spacesAbove {@code true} to add a space above the given lines (if not first) + * @param spacesBelow {@code true} to add a space below the given lines (if not last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, final String... lines) + { + injectLines(SidebarPriority.MIDDLE, spacesAbove, spacesBelow, Arrays.asList(lines)); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. + * + * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final boolean spacesAround, final Collection lines) + { + injectLines(SidebarPriority.MIDDLE, spacesAround, spacesAround, lines); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. + * + * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final boolean spacesAround, final String... lines) + { + injectLines(SidebarPriority.MIDDLE, spacesAround, spacesAround, Arrays.asList(lines)); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. No spaces are added before or after. + * + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final Collection lines) + { + injectLines(SidebarPriority.MIDDLE, false, false, lines); + return this; + } + + /** + * Injects lines into the sidebar without constrain on placement. No spaces are added before or after. + * + * @param lines The lines (from top to bottom). + * + * @return current instance, for methods chaining. + */ + public SidebarInjector injectLines(final String... lines) + { + injectLines(SidebarPriority.MIDDLE, false, false, Arrays.asList(lines)); + return this; + } + + /** + * Builds the lines for the sidebar according to the priorities and the spaces requirements. + * + * Does not adds multiple empty lines if one bucket requiring spaces below is followed by one + * requiring spaces above. + * + * @return a list of lines ready to be used by the sidebar. + */ + public List buildLines() + { + final LinkedList lines = new LinkedList<>(); + + // Initially to true so for the first one, if there is a space above, it's not added. + boolean lastInsertedASpace = true; + + for (final LinesBucket bucket : buckets) + { + if (bucket.spaceAbove && !lastInsertedASpace) + { + lines.add(""); + } + + lines.addAll(bucket.lines); + + if (bucket.spaceBelow) + { + lines.add(""); + lastInsertedASpace = true; + } + else + { + lastInsertedASpace = false; + } + } + + if (lines.getLast().equals("")) lines.removeLast(); + + return lines; + } + + /** + * Represents a packet of lines added to the scoreboard. + */ + private static class LinesBucket + { + private static int inserts = 0; + + private final int insertOrder; + private final SidebarPriority priority; + private final boolean spaceAbove; + private final boolean spaceBelow; + private final List lines; + + private LinesBucket(final SidebarPriority priority, final boolean spaceAbove, final boolean spaceBelow, final List lines) + { + this.insertOrder = ++inserts; + + this.priority = priority; + this.spaceAbove = spaceAbove; + this.spaceBelow = spaceBelow; + this.lines = lines; + } + } + + /** + * Comparator for {@link LinesBucket}. + */ + protected class LinesBucketComparator implements Comparator + { + @Override + public int compare(final LinesBucket bucket1, final LinesBucket bucket2) + { + final int priorityComparison = Integer.compare(bucket1.priority.ordinal(), bucket2.priority.ordinal()); + + if (priorityComparison != 0) return priorityComparison; + else return Integer.compare(bucket1.insertOrder, bucket2.insertOrder); + } + } + + /** + * The priority is used to order the lines given by various modules in the + * sidebar. Lines in the same priority bucket will be displayed in an order + * dependant on the modules's loading order. + */ + public enum SidebarPriority + { + /** + * Places the lines at the very top of the scoreboard. + */ + VERY_TOP, + + /** + * Places the lines on the top part of the scoreboard. + */ + TOP, + + /** + * Places the lines at the middle, without any strong preferences on placement. + */ + MIDDLE, + + /** + * Places the lines on the bottom part of the scoreboard. + */ + BOTTOM, + + /** + * Places the lines at the very bottom of the scoreboard. + */ + VERY_BOTTOM + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java new file mode 100644 index 0000000..6918ba2 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java @@ -0,0 +1,67 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; + + +@ModuleInfo ( + name = "Sidebar", + description = "Manages the sidebar and allows hooks for all modules into it", + settings = Config.class, + internal = true, + can_be_disabled = false +) +public class SidebarModule extends UHModule +{ + private GameSidebar sidebar; + + @Override + protected void onEnable() + { + sidebar = new GameSidebar(); + sidebar.runAutoRefresh(true); + + Bukkit.getOnlinePlayers().forEach(player -> sidebar.addRecipient(player)); + } + + @EventHandler (priority = EventPriority.LOWEST) + public void onPlayerJoin(final PlayerJoinEvent ev) + { + sidebar.addRecipient(ev.getPlayer()); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java new file mode 100644 index 0000000..b60e091 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java @@ -0,0 +1,47 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.teams; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; + +import java.io.File; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java new file mode 100644 index 0000000..cb246c5 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -0,0 +1,69 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.teams; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.commands.TeamsCommand; + +import java.util.Collections; +import java.util.List; + + +@ModuleInfo ( + name = "Teams", + description = "Manages the teams and related commands", + settings = Config.class, + internal = true, + can_be_disabled = false +) +public class TeamsModule extends UHModule +{ + @Override + protected void onEnable() + { + ZLib.loadComponent(ZTeams.class); + + ZTeams.settings() + .setScoreboard(UHCReloaded.get().getScoreboard()); + } + + @Override + public List> getCommands() + { + return Collections.singletonList(TeamsCommand.class); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java index 91ca1c9..c918c8d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java @@ -30,15 +30,15 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders; +package eu.carrade.amaury.UHCReloaded.old.borders; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.borders.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.borders.generators.WallGenerator; -import eu.carrade.amaury.UHCReloaded.borders.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.task.BorderWarningTask; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.borders.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.old.borders.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.old.borders.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.old.task.BorderWarningTask; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.PluginLogger; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/MapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/MapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java index ee22c5d..842dc14 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/MapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders; +package eu.carrade.amaury.UHCReloaded.old.borders; -import eu.carrade.amaury.UHCReloaded.borders.generators.CircularWallGenerator; -import eu.carrade.amaury.UHCReloaded.borders.generators.SquaredWallGenerator; -import eu.carrade.amaury.UHCReloaded.borders.generators.WallGenerator; -import eu.carrade.amaury.UHCReloaded.borders.shapes.CircularMapShape; -import eu.carrade.amaury.UHCReloaded.borders.shapes.MapShapeDescriptor; -import eu.carrade.amaury.UHCReloaded.borders.shapes.SquaredMapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.generators.CircularWallGenerator; +import eu.carrade.amaury.UHCReloaded.old.borders.generators.SquaredWallGenerator; +import eu.carrade.amaury.UHCReloaded.old.borders.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.old.borders.shapes.CircularMapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.shapes.MapShapeDescriptor; +import eu.carrade.amaury.UHCReloaded.old.borders.shapes.SquaredMapShape; import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/CannotGenerateWallsException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java index 3407022..f8345fc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.exceptions; +package eu.carrade.amaury.UHCReloaded.old.borders.exceptions; public class CannotGenerateWallsException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/UnknownWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java index 9dadeee..887d25c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.exceptions; +package eu.carrade.amaury.UHCReloaded.old.borders.exceptions; public class UnknownWallGenerator extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/CircularWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java index a652e1b..8c0eb8d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.generators; +package eu.carrade.amaury.UHCReloaded.old.borders.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/SquaredWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java index d3f1106..47e896c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.generators; +package eu.carrade.amaury.UHCReloaded.old.borders.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java index fbd9a30..bd93415 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.generators; +package eu.carrade.amaury.UHCReloaded.old.borders.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallPosition.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java index 1d6cab6..618dd21 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.generators; +package eu.carrade.amaury.UHCReloaded.old.borders.generators; /** * Used to determine in witch wall we are, to get the "inner" block. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/CircularMapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/CircularMapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java index 2fa71e3..4018844 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/CircularMapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.shapes; +package eu.carrade.amaury.UHCReloaded.old.borders.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/MapShapeDescriptor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/MapShapeDescriptor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java index c2590c5..cb9930c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/MapShapeDescriptor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.shapes; +package eu.carrade.amaury.UHCReloaded.old.borders.shapes; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/SquaredMapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/SquaredMapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java index a46b5e4..42307c7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/SquaredMapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.shapes; +package eu.carrade.amaury.UHCReloaded.old.borders.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/BrettflanWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java index 312e85c..9462a3b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; import com.wimbli.WorldBorder.BorderData; import com.wimbli.WorldBorder.Config; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/FakeWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java index a93e212..f8e386a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/VanillaWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java index 5ca69e4..7e72fa6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/WorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java index 3284b79..67ea144 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/UHCommandExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/UHCommandExecutor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java index bbb9c59..3e20c6c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/UHCommandExecutor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands; +package eu.carrade.amaury.UHCReloaded.old.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.GlobalMessageCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.JoinCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.LeaveCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.TeamMessageCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.TeamsCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.ToggleChatCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.UHRootCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommandExecutor; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.GlobalMessageCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.JoinCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.LeaveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.TeamMessageCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.TeamsCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.ToggleChatCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.UHRootCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommandExecutor; public class UHCommandExecutor extends AbstractCommandExecutor diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/GlobalMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/GlobalMessageCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java index 8ffd5a9..b8ed15a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/GlobalMessageCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -63,7 +63,7 @@ public GlobalMessageCommand(UHCReloaded p) * * @param sender The sender of the command. * @param args The arguments passed to the command. - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/JoinCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/JoinCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java index 59d55f6..86be1eb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/JoinCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamJoinCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamJoinCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/LeaveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/LeaveCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java index 92d6f8e..3d9b056 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/LeaveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamLeaveCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamLeaveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; // The permissions are too complex, we need to manage them manually. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamMessageCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java index 7b37dcc..70c9da7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamMessageCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -62,7 +62,7 @@ public TeamMessageCommand(UHCReloaded p) * * @param sender The sender of the command. * @param args The arguments passed to the command. - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java index 75d5b14..b42612d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamGUICommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamGUICommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; @Command (name = "teams", noPermission = true, inheritPermission = false) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java index 38aaf62..9d452f9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java @@ -30,14 +30,14 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java similarity index 63% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 754bd26..0ec6754 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -29,35 +29,35 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands; +package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHAboutCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHBorderCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHFeedAllCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHFeedCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHFinishCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHFreezeCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHGenerateWallsCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHHealAllCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHHealCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHInfosCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHKillCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHLoadPlayersCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHResurrectCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHRulesCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHShiftCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHSpawnsCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHSpectatorsCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHStartCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHTPBackCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHTPCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHTPSpawnCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHTeamCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHTimersCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHAboutCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHBorderCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedAllCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFinishCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFreezeCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHGenerateWallsCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealAllCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHInfosCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHKillCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHLoadPlayersCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHResurrectCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHRulesCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHShiftCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpawnsCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpectatorsCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHStartCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPBackCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPSpawnCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTeamCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTimersCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import org.bukkit.command.CommandSender; import java.util.List; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java index 896d66b..328df5d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.categories; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.categories; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java index ece3639..eb50f53 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.i18n.I18n; import org.bukkit.command.CommandSender; @@ -70,7 +70,7 @@ public UHAboutCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java index f83ab73..5386e47 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderCheckCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderGetCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderSetCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderWarningCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderCheckCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderGetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderSetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderWarningCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java index a5f1cc2..336f0eb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java index a31fb19..9d4c8a6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java index deb0042..c1627bb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java @@ -30,13 +30,13 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java index e936ccc..f6014c2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java index 66780d7..5a92695 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.borders.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; @@ -67,7 +67,7 @@ public UHGenerateWallsCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java index 3d02795..b24ce4f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java index b2040f0..ab9bf98 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java index dec93b8..fff2afb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java @@ -29,15 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.text.RawMessage; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java index 800d74c..3976de7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java index e05baf1..e11ca37 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java index 2eaa039..4e57472 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java index 83b8688..3653fd6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java index d85cb81..3c850a0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpawnsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpawnsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java index 0ec9db5..226b007 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java @@ -29,19 +29,19 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsAddCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsDumpCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsGenerateCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsListCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsRemoveCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns.UHSpawnsResetCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsAddCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsDumpCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsGenerateCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsListCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsRemoveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsResetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java index 1e5a72a..f0b2f86 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java @@ -29,15 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java index 80dc3a0..9c78e44 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; @@ -69,7 +69,7 @@ public UHStartCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java index cc18f3c..58a03b1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java index cdfb4b6..37b0a21 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java @@ -30,15 +30,15 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java index 2341887..098132f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java index 8ba51f0..1d7d766 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java @@ -29,23 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamAddCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamBannerCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamBannerResetCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamGUICommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamJoinCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamLeaveCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamListCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamRemoveCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamResetCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamSpyCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamAddCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerResetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamGUICommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamJoinCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamLeaveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamListCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamRemoveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamResetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamSpyCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java similarity index 73% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTimersCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java index c137550..04f0526 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTimersCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java @@ -29,23 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersAddCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersDisplayCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersHideCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersListCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersPauseCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersRemoveCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersResumeCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersSetCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersStartCommand; -import eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers.UHTimersStopCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersAddCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersDisplayCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersHideCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersListCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersPauseCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersRemoveCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersResumeCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersSetCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStartCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStopCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java index 11feab9..7dc54ee 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java index 135df11..f319394 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java index 38e4951..916d686 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java index 1e57c3c..481bd91 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java index 95ae84f..12347b2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; @@ -61,7 +61,7 @@ public UHSpawnsAddCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsDumpCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsDumpCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java index 0c77ad7..45c6fed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsDumpCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; import org.bukkit.World; @@ -63,7 +63,7 @@ public UHSpawnsDumpCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java index a48807d..35bfeba 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.spawns.Generator; import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.spawns.exceptions.UnknownGeneratorException; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; @@ -68,7 +68,7 @@ public UHSpawnsGenerateCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException @@ -250,7 +250,7 @@ else if (args.length == 7) * a line of the help of the parent command. *

*

- * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException} + * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException} * is caught by the command executor. *

* diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java index 25718e5..87700e8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; import org.bukkit.World; @@ -63,7 +63,7 @@ public UHSpawnsListCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException @@ -171,7 +171,7 @@ public List tabComplete(CommandSender sender, String[] args) * a line of the help of the parent command. *

*

- * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException} + * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException} * is caught by the command executor. *

* diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java index 0772056..db1e09e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Location; import org.bukkit.World; @@ -62,7 +62,7 @@ public UHSpawnsRemoveCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java index f093f0f..3f8cc14 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; @@ -58,7 +58,7 @@ public UHSpawnsResetCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java index 7be11b5..b00023a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java @@ -29,15 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; @@ -63,7 +63,7 @@ public UHTeamAddCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java index 1a1e146..f8ce689 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java index c203289..80bfaae 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamGUICommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamGUICommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java index 5226fee..3016b6d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamGUICommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java index 5b21b29..e37737d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java @@ -29,15 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; @@ -52,7 +52,7 @@ /** * This class is used for both /uh team join and /join commands. * - * @see {@link eu.carrade.amaury.UHCReloaded.commands.commands.JoinCommand}. + * @see {@link eu.carrade.amaury.UHCReloaded.old.commands.commands.JoinCommand}. */ @Command (name = "join") public class UHTeamJoinCommand extends AbstractCommand @@ -71,7 +71,7 @@ public UHTeamJoinCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(final CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java index 2e32eef..81963f9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -61,7 +61,7 @@ public UHTeamLeaveCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java index 844508e..e8c57e0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -60,7 +60,7 @@ public UHTeamListCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java index 6f53cb9..52fb585 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java @@ -29,15 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; @@ -63,7 +63,7 @@ public UHTeamRemoveCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java index fbc1d7d..406def8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; @@ -58,7 +58,7 @@ public UHTeamResetCommand(UHCReloaded plugin) * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java index fc18e0b..7488863 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java index 20e4c6d..36fa46d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java index 27f7a4f..c6e4504 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java index b047eb5..3575b22 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java index 331c1ab..ac08925 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java index d6ac577..edff3a6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java index 0b4b45e..3b47183 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java index 85239c4..aeb4b2c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java index 5bce4a5..08cce95 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java index e169a14..398440f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java index c4d629d..6107a46 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; +package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java index 9c11b97..aad7634 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.core; +package eu.carrade.amaury.UHCReloaded.old.commands.core; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import org.bukkit.command.CommandSender; import java.util.LinkedHashMap; @@ -96,7 +96,7 @@ public abstract class AbstractCommand * @param sender The sender of the command. * @param args The arguments passed to the command. * - * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. + * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. */ public abstract void run(CommandSender sender, String[] args) throws CannotExecuteCommandException; @@ -200,7 +200,7 @@ public AbstractCommand getParent() * * @param command The command to register. * - * @throws IllegalArgumentException If the command object don't have the {@link eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command} annotation. + * @throws IllegalArgumentException If the command object don't have the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command} annotation. */ public void registerSubCommand(AbstractCommand command) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java index dbb2861..892d547 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.core; +package eu.carrade.amaury.UHCReloaded.old.commands.core; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/annotations/Command.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/annotations/Command.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java index 2a3f2be..9e00a29 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/annotations/Command.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.core.annotations; +package eu.carrade.amaury.UHCReloaded.old.commands.core.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/exceptions/CannotExecuteCommandException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/exceptions/CannotExecuteCommandException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java index b755752..77e3df8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/exceptions/CannotExecuteCommandException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.core.exceptions; +package eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/utils/CommandUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/utils/CommandUtils.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java index 6d760bd..1934872 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/utils/CommandUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.commands.core.utils; +package eu.carrade.amaury.UHCReloaded.old.commands.core.utils; -import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java index aae72ff..95a0c90 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.integration; +package eu.carrade.amaury.UHCReloaded.old.integration; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.Bukkit; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java index e94d114..f8dc2c3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.integration; +package eu.carrade.amaury.UHCReloaded.old.integration; import com.comphenix.protocol.ProtocolLibrary; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.listeners.PacketsListener; +import eu.carrade.amaury.UHCReloaded.old.listeners.PacketsListener; import fr.zcraft.zlib.tools.PluginLogger; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegrationWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegrationWrapper.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java index d81a39a..2a86227 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegrationWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.integration; +package eu.carrade.amaury.UHCReloaded.old.integration; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHSpectatorPlusIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHSpectatorPlusIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java index e6ff484..1b614a7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHSpectatorPlusIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.integration; +package eu.carrade.amaury.UHCReloaded.old.integration; import com.pgcraft.spectatorplus.SpectateAPI; import com.pgcraft.spectatorplus.SpectatorPlus; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHWorldBorderIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHWorldBorderIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java index ac77862..b31b51c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHWorldBorderIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.integration; +package eu.carrade.amaury.UHCReloaded.old.integration; import com.wimbli.WorldBorder.WorldBorder; import fr.zcraft.zlib.tools.PluginLogger; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/BeforeGameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/BeforeGameListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java index a9ba7f5..43706a6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/BeforeGameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/CraftingListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/CraftingListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java index f4b2fb1..9fe235c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/CraftingListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java @@ -30,13 +30,13 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.recipes.RecipesManager; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; +import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/FreezerListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/FreezerListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java index 7687790..515903f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/FreezerListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import org.bukkit.entity.Creature; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 9c7862a..5c6276f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; @@ -43,9 +43,9 @@ import eu.carrade.amaury.UHCReloaded.events.UHPlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.events.UHTeamDeathEvent; -import eu.carrade.amaury.UHCReloaded.misc.RuntimeCommandsExecutor; -import eu.carrade.amaury.UHCReloaded.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; +import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index 4aecb0b..128f883 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -30,11 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.task.CancelBrewTask; +import eu.carrade.amaury.UHCReloaded.old.task.CancelBrewTask; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/PacketsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/PacketsListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java index c6187cd..a838418 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/PacketsListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/SpawnsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/listeners/SpawnsListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java index 31dcc05..ccb85f0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/listeners/SpawnsListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.listeners; +package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/Freezer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/Freezer.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java index 43ec706..6f25beb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/Freezer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.listeners.FreezerListener; +import eu.carrade.amaury.UHCReloaded.old.listeners.FreezerListener; import org.bukkit.Location; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java index 4e194dc..364d8af 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java @@ -30,11 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/OfflinePlayersLoader.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/OfflinePlayersLoader.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java index 29b8902..3e2d437 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/OfflinePlayersLoader.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import fr.zcraft.zlib.components.worker.Worker; import fr.zcraft.zlib.components.worker.WorkerCallback; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java index f2b1b3c..11466fb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/RulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/RulesManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java index a6797f4..d904f31 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/RulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/RuntimeCommandsExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/misc/RuntimeCommandsExecutor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java index 4b4a3e3..43810aa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/misc/RuntimeCommandsExecutor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.misc; +package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.task.ScheduledCommandsExecutorTask; +import eu.carrade.amaury.UHCReloaded.old.task.ScheduledCommandsExecutorTask; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.tools.runners.RunTask; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTip.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTip.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java index 94f1f25..a1d9337 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTip.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.protips; +package eu.carrade.amaury.UHCReloaded.old.protips; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java index 602ed75..0db8d56 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.protips; +package eu.carrade.amaury.UHCReloaded.old.protips; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipeUtil.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipeUtil.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java index c34dc3e..70062e7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipeUtil.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.recipes; +package eu.carrade.amaury.UHCReloaded.old.recipes; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java index ef25aa9..69b5a53 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.recipes; +package eu.carrade.amaury.UHCReloaded.old.recipes; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SPlusSpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SPlusSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java index 6541aca..3dbd97d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SPlusSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spectators; +package eu.carrade.amaury.UHCReloaded.old.spectators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java index 8acba07..0e5911a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spectators; +package eu.carrade.amaury.UHCReloaded.old.spectators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import org.bukkit.Bukkit; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/VanillaSpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spectators/VanillaSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java index 81d175c..f78904d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spectators/VanillaSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spectators; +package eu.carrade.amaury.UHCReloaded.old.spectators; import org.bukkit.Bukkit; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java index 0df8262..584860e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.task; +package eu.carrade.amaury.UHCReloaded.old.task; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/task/CancelBrewTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/task/CancelBrewTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java index 0d174c5..ab8b289 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/task/CancelBrewTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.task; +package eu.carrade.amaury.UHCReloaded.old.task; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/task/FireworksOnWinnersTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/task/FireworksOnWinnersTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java index 1c4d428..548ca36 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/task/FireworksOnWinnersTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.task; +package eu.carrade.amaury.UHCReloaded.old.task; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/task/ScheduledCommandsExecutorTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/task/ScheduledCommandsExecutorTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java index e6bf661..7407393 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/task/ScheduledCommandsExecutorTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.task; +package eu.carrade.amaury.UHCReloaded.old.task; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import fr.zcraft.zlib.tools.PluginLogger; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/task/UpdateTimerTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/task/UpdateTimerTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java index 37310b1..0b6d449 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/task/UpdateTimerTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.task; +package eu.carrade.amaury.UHCReloaded.old.task; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java index 922d33f..6c06ba9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.teams; +package eu.carrade.amaury.UHCReloaded.old.teams; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.protips.ProTips; +import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.MessageSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamColor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamColor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java index e27a178..a30a525 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamColor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.teams; +package eu.carrade.amaury.UHCReloaded.old.teams; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java index 2b84fe5..cd43f38 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java @@ -29,14 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.teams; +package eu.carrade.amaury.UHCReloaded.old.teams; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.gui.teams.editor.TeamEditDeleteGUI; -import eu.carrade.amaury.UHCReloaded.gui.teams.editor.TeamEditGUI; -import eu.carrade.amaury.UHCReloaded.gui.teams.editor.TeamEditMembersGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditDeleteGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditMembersGUI; import fr.zcraft.zlib.components.configuration.ConfigurationParseException; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.zlib.components.gui.Gui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java index 2b352d8..8710b28 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java @@ -29,14 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams; +package eu.carrade.amaury.UHCReloaded.old.teams; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.gui.teams.builder.TeamBuilderStepColorGUI; -import eu.carrade.amaury.UHCReloaded.gui.teams.editor.TeamEditGUI; -import eu.carrade.amaury.UHCReloaded.teams.TeamManager; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.builder.TeamBuilderStepColorGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditGUI; import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import fr.zcraft.zlib.components.gui.ExplorerGui; import fr.zcraft.zlib.components.gui.Gui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java index ccb0edd..39fd851 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.teams; +package eu.carrade.amaury.UHCReloaded.old.teams; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java index d23acc0..06ca947 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.builder; +package eu.carrade.amaury.UHCReloaded.old.teams.builder; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; import eu.carrade.amaury.UHCReloaded.utils.TextUtils; import fr.zcraft.zlib.components.gui.ActionGui; import fr.zcraft.zlib.components.gui.GuiUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepColorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepColorGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java index 1faf91c..0a3361f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepColorGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.builder; +package eu.carrade.amaury.UHCReloaded.old.teams.builder; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import eu.carrade.amaury.UHCReloaded.utils.TextUtils; import fr.zcraft.zlib.components.gui.Gui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java index bc488dc..fe6bb13 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.builder; +package eu.carrade.amaury.UHCReloaded.old.teams.builder; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.gui.GuiUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java index 23285d9..ffb4a20 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.builder; +package eu.carrade.amaury.UHCReloaded.old.teams.builder; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; import eu.carrade.amaury.UHCReloaded.utils.TextUtils; import fr.zcraft.zlib.components.gui.Gui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java index 92a432a..bb8509d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.editor; +package eu.carrade.amaury.UHCReloaded.old.teams.editor; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.gui.ActionGui; import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditColorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditColorGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java index 7eee0e9..c77444a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditColorGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.editor; +package eu.carrade.amaury.UHCReloaded.old.teams.editor; -import eu.carrade.amaury.UHCReloaded.gui.teams.builder.TeamBuilderStepColorGUI; -import eu.carrade.amaury.UHCReloaded.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.builder.TeamBuilderStepColorGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java index 0a6910d..d756078 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.editor; +package eu.carrade.amaury.UHCReloaded.old.teams.editor; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.gui.GuiUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java index a8af539..394e4a4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.editor; +package eu.carrade.amaury.UHCReloaded.old.teams.editor; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import eu.carrade.amaury.UHCReloaded.utils.TextUtils; import fr.zcraft.zlib.components.gui.Gui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java index 68f89b7..b4f516e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.gui.teams.editor; +package eu.carrade.amaury.UHCReloaded.old.teams.editor; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; import fr.zcraft.zlib.components.gui.ExplorerGui; import fr.zcraft.zlib.components.gui.GuiAction; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/timers/TimerManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/timers/TimerManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java index 878052a..48702ff 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/timers/TimerManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.timers; +package eu.carrade.amaury.UHCReloaded.old.timers; import java.util.Collection; import java.util.HashMap; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/timers/UHTimer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/timers/UHTimer.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java index 3e30e06..2058d2d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/timers/UHTimer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.timers; +package eu.carrade.amaury.UHCReloaded.old.timers; import eu.carrade.amaury.UHCReloaded.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.events.TimerStartsEvent; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java index 4512d5e..3e5f900 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java @@ -33,12 +33,12 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.borders.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.worldborders.WorldBorder; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import eu.carrade.amaury.UHCReloaded.misc.Freezer; -import eu.carrade.amaury.UHCReloaded.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; +import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java index ca48c13..e8055f2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java @@ -31,7 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.scoreboard; -import eu.carrade.amaury.UHCReloaded.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java index 4cc6763..27b74f7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.spawns.generators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java index a17a764..0cb9295 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java @@ -33,7 +33,7 @@ package eu.carrade.amaury.UHCReloaded.spawns.generators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java new file mode 100644 index 0000000..d5212da --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java @@ -0,0 +1,82 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.utils; + +import org.apache.commons.lang.StringUtils; + +import java.util.Arrays; +import java.util.List; + + +public class ModulesUtils +{ + /** + * Tries to find a class from its name, by combining suffixes, packages, capitalization. + * + * @param name The class base name to search for. + * @param optionalPackage An optional package to search in. + * @param optionalSuffix An optional suffix to test, appended to the class name. + * @param superClass The superclass this class must have. + * @param The superclass type this class must have. + * + * @return The {@link Class}, if found; else, {@code null}. + */ + public static Class getClassFromName(final String name, final String optionalPackage, final String optionalSuffix, final Class superClass) + { + final List possibilities = Arrays.asList( + optionalPackage + "." + name, + optionalPackage + "." + name + optionalSuffix, + optionalPackage + "." + StringUtils.capitalize(name), + optionalPackage + "." + StringUtils.capitalize(name) + optionalSuffix, + optionalPackage + "." + StringUtils.capitalize(name.toLowerCase()), + optionalPackage + "." + StringUtils.capitalize(name.toLowerCase()) + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name), + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name) + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + optionalSuffix, + name + ); + + for (String clazzName : possibilities) + { + try + { + final Class clazz = Class.forName(clazzName); + if (superClass.isAssignableFrom(clazz)) return (Class) clazz; + } + catch (ClassNotFoundException e) { /* The search continues... */ } + } + + return null; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5f65b60..9606056 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,8 @@ name: UHPlugin description: UltraHardcore Reloaded main: eu.carrade.amaury.UHCReloaded.UHCReloaded -version: 1.5 +load: STARTUP +version: 2.0-alpha author: "Amaury Carrade" authors: [azenet, "João Roda"] @@ -18,29 +19,29 @@ commands: uh: description: UltraHardcore Reloaded base command usage: / - see / for available subcommands. - t: - description: Allows an user to send a message to his team. - usage: / - - g: - description: Allows an user to send a message to everyone. - usage: / - - togglechat: - description: Allows an user to toggle the chat between the global chat and a team chat. - usage: / - - join: - description: Use this to join an UltraHardcore team. - usage: / [player] - - leave: - description: Use this to quit your current UltraHardcore team. - usage: / [player] - - teams: - description: Displays a GUI to manage the UHCReloaded teams - usage: / +# t: +# description: Allows an user to send a message to his team. +# usage: / +# +# g: +# description: Allows an user to send a message to everyone. +# usage: / +# +# togglechat: +# description: Allows an user to toggle the chat between the global chat and a team chat. +# usage: / +# +# join: +# description: Use this to join an UltraHardcore team. +# usage: / [player] +# +# leave: +# description: Use this to quit your current UltraHardcore team. +# usage: / [player] +# +# teams: +# description: Displays a GUI to manage the UHCReloaded teams +# usage: / permissions: diff --git a/src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java b/src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java new file mode 100644 index 0000000..69b5ed8 --- /dev/null +++ b/src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java @@ -0,0 +1,229 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded; + +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import org.junit.Assert; +import org.junit.ComparisonFailure; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +public class SidebarInjectorTest +{ + private static void assertListsEquals(final String message, final List expected, final List actual) + { + if (expected == actual) return; + + if (expected.size() != actual.size()) + Assert.fail(message + " - Lists size differ (expected <" + expected.size() + "> but got <" + actual.size() + ">)"); + + for (int i = 0; i < expected.size(); i++) + { + final T expectedValue = expected.get(i); + final T actualValue = actual.get(i); + + if (!expectedValue.equals(actualValue)) + { + if (expectedValue instanceof String && actualValue instanceof String) + { + final String completeMessage = (message == null ? "" : message + " - ") + "Lists first differ at index " + i + ":"; + throw new ComparisonFailure(completeMessage, (String) expectedValue, (String) actualValue); + } + else + { + Assert.fail((message == null ? "" : message + " - ") + "Lists first differ at index " + i + ": expected <" + expected.toString() + "> but got <" + actual.toString() + ">"); + } + } + } + } + + @Test + public void testBasicInjector() + { + assertListsEquals( + "Items added without priority or spacing should be left as is and in order", + Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4", "Line 5", "Line 6"), + new SidebarInjector() + .injectLines("Line 1", "Line 2", "Line 3") + .injectLines("Line 4") + .injectLines("Line 5", "Line 6") + .buildLines() + ); + } + + @Test + public void testPriorityInInjector() + { + assertListsEquals( + "Items added with priority should be ordered according to theses, regardless of the inclusion order", + Arrays.asList("Line 4", "Line 1", "Line 2", "Line 3", "Line 5", "Line 6"), + new SidebarInjector() + .injectLines("Line 1", "Line 2", "Line 3") + .injectLines(SidebarInjector.SidebarPriority.TOP,"Line 4") + .injectLines("Line 5", "Line 6") + .buildLines() + ); + + assertListsEquals( + "Items added with multiple priorities should be ordered according to theses, regardless of the inclusion order", + Arrays.asList("Line 5", "Line 6", "Line 4", "Line 1", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines(SidebarInjector.SidebarPriority.BOTTOM, "Line 1", "Line 2", "Line 3") + .injectLines(SidebarInjector.SidebarPriority.TOP,"Line 4") + .injectLines(SidebarInjector.SidebarPriority.VERY_TOP, "Line 5", "Line 6") + .buildLines() + ); + + assertListsEquals( + "Items added without priority or spacing should be left as is and in order", + Arrays.asList("Line 1", "Line 2", "Line 4", "Line 3", "Line 5", "Line 6"), + new SidebarInjector() + .injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, "Line 6") + .injectLines(SidebarInjector.SidebarPriority.BOTTOM, "Line 5") + .injectLines(SidebarInjector.SidebarPriority.MIDDLE, "Line 4") + .injectLines("Line 3") + .injectLines(SidebarInjector.SidebarPriority.TOP, "Line 2") + .injectLines(SidebarInjector.SidebarPriority.VERY_TOP, "Line 1") + .buildLines() + ); + } + + @Test + public void testSpacesInInjector() + { + assertListsEquals( + "If spaces are required around the only element, they are not added", + Collections.singletonList("Line 1"), + new SidebarInjector() + .injectLines(true, "Line 1") + .buildLines() + ); + + assertListsEquals( + "If spaces are required above the first element, it is not added", + Arrays.asList("Line 1", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines(true, false, "Line 1") + .injectLines("Line 2", "Line 3") + .buildLines() + ); + + assertListsEquals( + "If spaces are required around the first element, it is added after but not before", + Arrays.asList("Line 1", "", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines(true, "Line 1") + .injectLines("Line 2", "Line 3") + .buildLines() + ); + + assertListsEquals( + "If spaces are required below the last element, it is not added", + Arrays.asList("Line 1", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines("Line 1") + .injectLines(false, true, "Line 2", "Line 3") + .buildLines() + ); + + assertListsEquals( + "If spaces are required around the last element, it is added before but not after", + Arrays.asList("Line 1", "Line 2", "", "Line 3", "Line 4"), + new SidebarInjector() + .injectLines("Line 1", "Line 2") + .injectLines(true, "Line 3", "Line 4") + .buildLines() + ); + + assertListsEquals( + "If spaces are required after an element and before the next, it is added only once", + Arrays.asList("Line 1", "Line 2", "", "Line 3", "Line 4"), + new SidebarInjector() + .injectLines(true, "Line 1", "Line 2") + .injectLines(true, "Line 3", "Line 4") + .buildLines() + ); + } + + @Test + public void testSpacesAndPrioritiesInInjector() + { + assertListsEquals( + "If spaces are required above the first element, it is not added (with priorities)", + Arrays.asList("Line 1", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines("Line 2", "Line 3") + .injectLines(SidebarInjector.SidebarPriority.TOP, true, false, "Line 1") + .buildLines() + ); + + assertListsEquals( + "If spaces are required around the first element, it is added after but not before", + Arrays.asList("Line 1", "", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines("Line 2", "Line 3") + .injectLines(SidebarInjector.SidebarPriority.VERY_TOP, true, "Line 1") + .buildLines() + ); + + assertListsEquals( + "If spaces are required below the last element, it is not added", + Arrays.asList("Line 1", "Line 2", "Line 3"), + new SidebarInjector() + .injectLines(SidebarInjector.SidebarPriority.BOTTOM, false, true, "Line 2", "Line 3") + .injectLines("Line 1") + .buildLines() + ); + + assertListsEquals( + "If spaces are required around the last element, it is added before but not after", + Arrays.asList("Line 1", "Line 2", "", "Line 3", "Line 4"), + new SidebarInjector() + .injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, true, "Line 3", "Line 4") + .injectLines("Line 1", "Line 2") + .buildLines() + ); + + assertListsEquals( + "If spaces are required after an element and before the next, it is added only once", + Arrays.asList("Line 1", "Line 2", "", "Line 3", "Line 4"), + new SidebarInjector() + .injectLines(true, "Line 1", "Line 2") + .injectLines(SidebarInjector.SidebarPriority.MIDDLE,true, "Line 3", "Line 4") + .buildLines() + ); + } +} From dbc0b074d3ccd9ddecc02767f5880dc344e2a6f7 Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Wed, 17 Oct 2018 14:42:52 +0200 Subject: [PATCH 02/91] Timers, & parts of spawns/borders --- .../amaury/UHCReloaded/UHCReloaded.java | 125 ++++-- .../carrade/amaury/UHCReloaded/UHConfig.java | 14 +- .../UHCReloaded/game/UHGameManager.java | 67 ++- .../core/border/BorderManager.java} | 30 +- .../core/border/BorderModule.java} | 151 +++---- .../core/border}/BorderWarningTask.java | 29 +- .../modules/core/border/Config.java | 87 ++++ .../core/border}/MapShape.java | 14 +- .../CannotGenerateWallsException.java | 2 +- .../exceptions/UnknownWallGenerator.java | 2 +- .../generators/CircularWallGenerator.java | 2 +- .../generators/SquaredWallGenerator.java | 2 +- .../border}/generators/WallGenerator.java | 2 +- .../core/border}/generators/WallPosition.java | 2 +- .../core/border}/shapes/CircularMapShape.java | 2 +- .../border}/shapes/MapShapeDescriptor.java | 2 +- .../core/border}/shapes/SquaredMapShape.java | 2 +- .../worldborders/BrettflanWorldBorder.java | 4 +- .../border}/worldborders/FakeWorldBorder.java | 4 +- .../worldborders/VanillaWorldBorder.java | 4 +- .../border}/worldborders/WorldBorder.java | 23 +- .../modules/core/game/GameModule.java | 25 +- .../core/game/commands/StartCommand.java | 52 +++ .../modules/core/spawns/Config.java | 54 +++ .../{ => modules/core}/spawns/Generator.java | 10 +- .../core/spawns/SpawnsModule.java} | 71 ++-- .../CannotGenerateSpawnPointsException.java | 2 +- .../exceptions/UnknownGeneratorException.java | 2 +- .../CircularSpawnPointsGenerator.java | 9 +- .../generators/GridSpawnPointsGenerator.java | 15 +- .../RandomSpawnPointsGenerator.java | 13 +- .../generators/SpawnPointsGenerator.java | 4 +- .../modules/core/timers/TimeDelta.java | 141 +++++++ .../core/timers/Timer.java} | 235 +++++------ .../core/timers/TimersModule.java} | 126 +++--- .../core/timers/commands/TimersCommand.java | 388 ++++++++++++++++++ .../core/timers}/events/TimerEndsEvent.java | 10 +- .../core/timers}/events/TimerStartsEvent.java | 10 +- .../old/commands/commands/UHRootCommand.java | 2 - .../commands/uh/UHGenerateWallsCommand.java | 34 +- .../commands/commands/uh/UHTimersCommand.java | 106 ----- .../uh/border/UHBorderCheckCommand.java | 3 +- .../uh/border/UHBorderGetCommand.java | 17 +- .../uh/border/UHBorderSetCommand.java | 139 ++++--- .../uh/border/UHBorderWarningCommand.java | 4 +- .../uh/spawns/UHSpawnsAddCommand.java | 4 +- .../uh/spawns/UHSpawnsDumpCommand.java | 8 +- .../uh/spawns/UHSpawnsGenerateCommand.java | 38 +- .../uh/spawns/UHSpawnsListCommand.java | 3 +- .../uh/spawns/UHSpawnsRemoveCommand.java | 5 +- .../uh/spawns/UHSpawnsResetCommand.java | 2 +- .../uh/timers/UHTimersAddCommand.java | 113 ----- .../uh/timers/UHTimersDisplayCommand.java | 103 ----- .../uh/timers/UHTimersHideCommand.java | 103 ----- .../uh/timers/UHTimersListCommand.java | 125 ------ .../uh/timers/UHTimersPauseCommand.java | 104 ----- .../uh/timers/UHTimersRemoveCommand.java | 106 ----- .../uh/timers/UHTimersResumeCommand.java | 104 ----- .../uh/timers/UHTimersSetCommand.java | 126 ------ .../uh/timers/UHTimersStartCommand.java | 109 ----- .../uh/timers/UHTimersStopCommand.java | 104 ----- .../old/listeners/GameListener.java | 54 +-- .../amaury/UHCReloaded/old/misc/Freezer.java | 4 +- .../UHCReloaded/scoreboard/GameSidebar.java | 26 +- src/main/resources/config.yml | 14 +- 65 files changed, 1449 insertions(+), 1848 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/task/UpdateTimerTask.java => modules/core/border/BorderManager.java} (75%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders/BorderManager.java => modules/core/border/BorderModule.java} (71%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/task => modules/core/border}/BorderWarningTask.java (73%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/MapShape.java (86%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/exceptions/CannotGenerateWallsException.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/exceptions/UnknownWallGenerator.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/generators/CircularWallGenerator.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/generators/SquaredWallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/generators/WallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/generators/WallPosition.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/shapes/CircularMapShape.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/shapes/MapShapeDescriptor.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/shapes/SquaredMapShape.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/worldborders/BrettflanWorldBorder.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/worldborders/FakeWorldBorder.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/worldborders/VanillaWorldBorder.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/borders => modules/core/border}/worldborders/WorldBorder.java (89%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/Generator.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{spawns/SpawnsManager.java => modules/core/spawns/SpawnsModule.java} (84%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/exceptions/CannotGenerateSpawnPointsException.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/exceptions/UnknownGeneratorException.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/generators/CircularSpawnPointsGenerator.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/generators/GridSpawnPointsGenerator.java (93%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/generators/RandomSpawnPointsGenerator.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core}/spawns/generators/SpawnPointsGenerator.java (94%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/timers/UHTimer.java => modules/core/timers/Timer.java} (56%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/timers/TimerManager.java => modules/core/timers/TimersModule.java} (56%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core/timers}/events/TimerEndsEvent.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => modules/core/timers}/events/TimerStartsEvent.java (90%) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index f81ad28..fdc7900 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -36,12 +36,15 @@ import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.events.modules.AllModulesLoadedEvent; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderManager; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesManagerModule; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; -import eu.carrade.amaury.UHCReloaded.old.borders.BorderManager; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; @@ -56,9 +59,7 @@ import eu.carrade.amaury.UHCReloaded.old.spectators.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager; import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; -import eu.carrade.amaury.UHCReloaded.old.timers.TimerManager; import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; -import eu.carrade.amaury.UHCReloaded.spawns.SpawnsManager; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.Commands; @@ -73,6 +74,7 @@ import fr.zcraft.zlib.tools.reflection.Reflection; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.command.CommandMap; import org.bukkit.command.PluginCommand; import org.bukkit.event.EventHandler; @@ -108,8 +110,13 @@ public class UHCReloaded extends ZPlugin implements Listener private Scoreboard scoreboard = null; + private World worldNormal = null; + private World worldNether = null; + private World worldTheEnd = null; + + private boolean worldsLoaded = false; + private TeamManager teamManager = null; - private SpawnsManager spawnsManager = null; private UHGameManager gameManager = null; private SpectatorsManager spectatorsManager = null; private ScoreboardManager scoreboardManager = null; @@ -119,7 +126,6 @@ public class UHCReloaded extends ZPlugin implements Listener private BorderManager borderManager = null; private RecipesManager recipesManager = null; private TeamChatManager teamChatManager = null; - private TimerManager timerManager = null; private RuntimeCommandsExecutor runtimeCommandsExecutor = null; @@ -130,8 +136,6 @@ public class UHCReloaded extends ZPlugin implements Listener private UHDynmapIntegration dynmapintegration = null; private UHProtocolLibIntegrationWrapper protocollibintegrationwrapper = null; - private boolean worldsLoaded = false; - @Override public void onEnable() @@ -162,12 +166,23 @@ public void onEnable() /* *** Core modules *** */ registerModules( - ModulesManagerModule.class, // Manages the modules from the game/commands + ModulesManagerModule.class, // Manages the modules from the game/commands. + SidebarModule.class, // Manages the sidebar and provides hooks for other modules. // Must be loaded before the game-related modules. + TeamsModule.class, // Manages the teams (for both team & solo games). // Must be loaded before the game-related modules. - GameModule.class // Manages the game progression + + TimersModule.class, // Manages the time in everything. + + BorderModule.class, // Manages the border of the map. + // Must be loaded before the spawns module. + + SpawnsModule.class, // Manages the spawn points and teleportation. + // Must be loaded before the game-related modules. + + GameModule.class // Manages the game progression. ); @@ -185,12 +200,7 @@ public void onEnable() if (!getServer().getWorlds().isEmpty()) { - scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); - - loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); - collectCommandsFromModules(); - - worldsLoaded = true; + onEnableWhenWorldsAvailable(); } @@ -199,6 +209,25 @@ public void onEnable() PluginLogger.info(I.t("Ultra Hardcore plugin loaded.")); } + /** + * Run when the worlds are available (on plugin enabled if reloaded, on worlds ready else). + */ + private void onEnableWhenWorldsAvailable() + { + scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); + + RunTask.nextTick(() -> { + worldNormal = setDefaultWorld(World.Environment.NORMAL, UHConfig.WORLDS.OVERWORLD.get()); + worldNether = setDefaultWorld(World.Environment.NETHER, UHConfig.WORLDS.NETHER.get()); + worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get()); + + loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); + collectCommandsFromModules(); + }); + + worldsLoaded = true; + } + /** @@ -404,21 +433,34 @@ public Scoreboard getScoreboard() return scoreboard; } + /** + * @param environment An environment. + * @return The world to use for this environment in the game. + */ + public World getWorld(final World.Environment environment) + { + if (environment == null) return worldNormal; + + switch (environment) + { + case NORMAL: + return worldNormal; + + case NETHER: + return worldNether; + + case THE_END: + default: + return worldTheEnd; + } + } + @EventHandler (priority = EventPriority.LOWEST) public final void onWorldsLoaded(WorldLoadEvent e) { - if (!worldsLoaded) - { - RunTask.nextTick(() -> { - loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); - collectCommandsFromModules(); - }); - - worldsLoaded = true; - scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); - } + if (!worldsLoaded) onEnableWhenWorldsAvailable(); } @EventHandler @@ -515,6 +557,23 @@ private void collectCommandsFromModules() }); } + private World setDefaultWorld(final World.Environment environment, final String worldName) + { + final World userWorld = Bukkit.getWorld(worldName); + + // If the world is valid, it is used as-is. + if (userWorld != null && userWorld.getEnvironment() == environment) return userWorld; + + // Else we use the first world we found with the right type. + for (final World world : Bukkit.getWorlds()) + { + if (world.getEnvironment() == environment) return world; + } + + // We finally fallback on the first world regardless of its type to have at least something. + return Bukkit.getWorlds().get(0); + } + @@ -575,14 +634,6 @@ public PlayerListHeaderFooterManager getPlayerListHeaderFooterManager() return playerListHeaderFooterManager; } - /** - * Returns the spawns points manager. - */ - public SpawnsManager getSpawnsManager() - { - return spawnsManager; - } - /** * Returns the border manager. */ @@ -607,14 +658,6 @@ public TeamChatManager getTeamChatManager() return teamChatManager; } - /** - * Returns the timer manager. - */ - public TimerManager getTimerManager() - { - return timerManager; - } - /** * Returns the manager used to manage the commands executed after the start/the end of the * game (or any other moment using the generic API). diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index a3ae421..ffa93a0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -1,7 +1,7 @@ package eu.carrade.amaury.UHCReloaded; import eu.carrade.amaury.UHCReloaded.game.Cage; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.configuration.Configuration; @@ -26,6 +26,18 @@ public class UHConfig extends Configuration static public final ConfigurationMap MODULES = map("modules", String.class, Boolean.class); + static public final WorldsSection WORLDS = section("worlds", WorldsSection.class); + + static public class WorldsSection extends ConfigurationSection + { + public final ConfigurationItem OVERWORLD = item("overworld", "world"); + public final ConfigurationItem NETHER = item("nether", "world_nether"); + public final ConfigurationItem THE_END = item("the-end", "world_the_end"); + } + + + + static public final EpisodesSection EPISODES = section("episodes", EpisodesSection.class); static public class EpisodesSection extends ConfigurationSection diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index e285ac7..201434c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -37,13 +37,13 @@ import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.old.task.FireworksOnWinnersTask; import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; @@ -55,7 +55,6 @@ import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.Achievement; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Difficulty; import org.bukkit.GameMode; import org.bukkit.Location; @@ -313,34 +312,34 @@ public void start(final CommandSender sender, final Boolean slow, Boolean ignore Integer spawnsNeeded = ignoreTeams ? alivePlayersCount : aliveTeamsCount; - if (p.getSpawnsManager().getSpawnPoints().size() < spawnsNeeded) - { - if (sender instanceof Player) sender.sendMessage(""); - sender.sendMessage(I.t("{ce}Unable to start the game: not enough teleportation spots.")); - sender.sendMessage(I.t("{ci}You can use {cc}/uh spawns generate {ci} to generate the missing spawns automatically.")); - - /// In the sentence: "Or click here to generate the spawns randomly." - RawMessage.send(sender, new RawText(I.t("Or")) - .then(" ") - /// In the sentence: "Or click here to generate the spawns randomly." - .then(I.t("click here")) - .color(ChatColor.GREEN).style(ChatColor.BOLD) - .command("/uh spawns generate random") - .hover(new RawText("/uh spawns generate random")) - .then(" ") - /// In the sentence: "Or click here to generate the spawns randomly." - .then(I.t("to generate the spawns randomly.")).color(ChatColor.WHITE) - .build() - ); - - // We clears the teams created on-the-fly - onTheFlyTeams.forEach(team -> tm.removeTeam(team, true)); - - aliveTeamsCount = 0; - alivePlayersCount = 0; - - return; - } +// if (p.getSpawnsManager().getSpawnPoints().size() < spawnsNeeded) +// { +// if (sender instanceof Player) sender.sendMessage(""); +// sender.sendMessage(I.t("{ce}Unable to start the game: not enough teleportation spots.")); +// sender.sendMessage(I.t("{ci}You can use {cc}/uh spawns generate {ci} to generate the missing spawns automatically.")); +// +// /// In the sentence: "Or click here to generate the spawns randomly." +// RawMessage.send(sender, new RawText(I.t("Or")) +// .then(" ") +// /// In the sentence: "Or click here to generate the spawns randomly." +// .then(I.t("click here")) +// .color(ChatColor.GREEN).style(ChatColor.BOLD) +// .command("/uh spawns generate random") +// .hover(new RawText("/uh spawns generate random")) +// .then(" ") +// /// In the sentence: "Or click here to generate the spawns randomly." +// .then(I.t("to generate the spawns randomly.")).color(ChatColor.WHITE) +// .build() +// ); +// +// // We clears the teams created on-the-fly +// onTheFlyTeams.forEach(team -> tm.removeTeam(team, true)); +// +// aliveTeamsCount = 0; +// alivePlayersCount = 0; +// +// return; +// } /* ** MOTD (now the game WILL start) ** */ @@ -368,7 +367,7 @@ public void start(final CommandSender sender, final Boolean slow, Boolean ignore teleporter = new Teleporter(); - List spawnPoints = new ArrayList<>(p.getSpawnsManager().getSpawnPoints()); + List spawnPoints = new ArrayList<>(); // (p.getSpawnsManager().getSpawnPoints()); Collections.shuffle(spawnPoints); Queue unusedTP = new ArrayDeque<>(spawnPoints); @@ -591,10 +590,10 @@ private void startTimer() // An empty string is used for the name of the main timer, because // such a name can't be used by players. - UHTimer mainTimer = new UHTimer(""); + Timer mainTimer = new Timer(""); mainTimer.setDuration(this.getEpisodeLength()); - p.getTimerManager().registerMainTimer(mainTimer); +// p.getTimerManager().registerMainTimer(mainTimer); mainTimer.start(); } @@ -754,7 +753,7 @@ public void shiftEpisode(String shifter) // Useless for a normal start (restarted in the event), but needed if the episode was shifted. if (cause == EpisodeChangedCause.SHIFTED) { - p.getTimerManager().getMainTimer().start(); +// p.getTimerManager().getMainTimer().start(); } p.getServer().getPluginManager().callEvent(new UHEpisodeChangedEvent(episode, cause, shifter)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java similarity index 75% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java index 0b6d449..1c7e8da 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/UpdateTimerTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java @@ -29,21 +29,27 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.task; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; +package eu.carrade.amaury.UHCReloaded.modules.core.border; + +import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; -public class UpdateTimerTask extends BukkitRunnable +public class BorderManager { - @Override - public void run() - { - for (UHTimer timer : UHCReloaded.get().getTimerManager().getRunningTimers()) - { - timer.update(); - } - } + private WorldBorder border = null; + + private Integer warningSize = 0; + private BukkitRunnable warningTask = null; + + private Boolean warningFinalTimeEnabled = false; + private String warningTimerName = null; + private CommandSender warningSender = null; + + private MapShape mapShape = null; + + + } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java similarity index 71% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index c918c8d..72ae9f8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/BorderManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -29,26 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ - -package eu.carrade.amaury.UHCReloaded.old.borders; +package eu.carrade.amaury.UHCReloaded.modules.core.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.borders.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.old.borders.generators.WallGenerator; -import eu.carrade.amaury.UHCReloaded.old.borders.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.old.task.BorderWarningTask; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.Titles; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -57,51 +54,38 @@ import java.util.Set; -public class BorderManager +@ModuleInfo ( + name = "Border", + description = "Manages the border size and reduction", + settings = Config.class, + can_be_disabled = false, + internal = true +) +public class BorderModule extends UHModule { - private final boolean BORDER_SHRINKING; - private final long BORDER_SHRINKING_STARTS_AFTER; - private final long BORDER_SHRINKING_DURATION; - private final double BORDER_SHRINKING_FINAL_SIZE; - - private final UHCReloaded p; - private WorldBorder border = null; private Integer warningSize = 0; private BukkitRunnable warningTask = null; private Boolean warningFinalTimeEnabled = false; + private Timer warningTimer = null; private String warningTimerName = null; private CommandSender warningSender = null; private MapShape mapShape = null; - - public BorderManager(UHCReloaded plugin) + @Override + public void onEnable() { - p = plugin; - /// The name of the warning timer displaying the time left before the next border warningTimerName = I.t("Border shrinking"); - mapShape = UHConfig.MAP.SHAPE.get(); - if (mapShape == null) - { - PluginLogger.warning("Invalid shape '" + UHConfig.MAP.SHAPE.get() + "'; using 'squared' instead."); - mapShape = MapShape.SQUARED; - } - - - World world = UHUtils.getOverworld(); + mapShape = Config.SHAPE.get(); - if (world == null) - { - world = Bukkit.getWorlds().get(0); - PluginLogger.warning("Cannot find overworld! Using the world '{0}' instead (environment: {1}).", world.getName(), world.getEnvironment()); - } + final World world = UHCReloaded.get().getWorld(World.Environment.NORMAL); - border = WorldBorder.getInstance(world, UHConfig.MAP.BORDER.MOTOR.get(), mapShape); + border = WorldBorder.getInstance(world, Config.MOTOR.get(), mapShape); border.setShape(mapShape); border.setCenter(world.getSpawnLocation()); @@ -111,11 +95,8 @@ public BorderManager(UHCReloaded plugin) PluginLogger.info("Using {0} to set the world border.", border.getClass().getSimpleName()); - - BORDER_SHRINKING = UHConfig.MAP.BORDER.SHRINKING.ENABLED.get(); - BORDER_SHRINKING_STARTS_AFTER = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.STARTS_AFTER.get(), 30*60); // Seconds - BORDER_SHRINKING_DURATION = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.SHRINKS_DURING.get(), 60*60*2); // Same - BORDER_SHRINKING_FINAL_SIZE = UHConfig.MAP.BORDER.SHRINKING.DIAMETER_AFTER_SHRINK.get(); +// BORDER_SHRINKING_STARTS_AFTER = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.STARTS_AFTER.get(), 30*60); // Seconds +// BORDER_SHRINKING_DURATION = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.SHRINKS_DURING.get(), 60*60*2); // Same } /** @@ -159,7 +140,7 @@ public WorldBorder getBorderProxy() public boolean isInsideBorder(Location location, double diameter) { // The nether/end are not limited. - return !location.getWorld().getEnvironment().equals(Environment.NORMAL) || mapShape.getShape().isInsideBorder(location, diameter, location.getWorld().getSpawnLocation()); + return !location.getWorld().getEnvironment().equals(World.Environment.NORMAL) || mapShape.getShape().isInsideBorder(location, diameter, location.getWorld().getSpawnLocation()); } /** @@ -198,15 +179,16 @@ public double getDistanceToBorder(Location location, double diameter) */ public Set getPlayersOutside(int diameter) { - HashSet playersOutside = new HashSet(); + final Set playersOutside = new HashSet<>(); - for (final Player player : p.getGameManager().getOnlineAlivePlayers()) - { - if (!isInsideBorder(player.getLocation(), diameter)) - { - playersOutside.add(player); - } - } + // TODO +// for (final Player player : UHCReloaded.getModule(GameModule.class).getOnlineAlivePlayers()) +// { +// if (!isInsideBorder(player.getLocation(), diameter)) +// { +// playersOutside.add(player); +// } +// } return playersOutside; } @@ -260,12 +242,12 @@ public void setWarningSize(int diameter, int timeLeft, CommandSender sender) if (timeLeft != 0) { - UHTimer timer = new UHTimer(this.warningTimerName); - timer.setDuration(timeLeft * 60); + warningTimer = new Timer(this.warningTimerName); + warningTimer.setDuration(timeLeft * 60); - p.getTimerManager().registerTimer(timer); + UHCReloaded.getModule(TimersModule.class).registerTimer(warningTimer); - timer.start(); + warningTimer.start(); } if (sender != null) @@ -276,7 +258,7 @@ public void setWarningSize(int diameter, int timeLeft, CommandSender sender) RunTask.timer( warningTask = new BorderWarningTask(), 20L, - 20L * p.getConfig().getInt("map.border.warningInterval", 90) + 20L * Config.WARNING_INTERVAL.get() ); } @@ -294,18 +276,6 @@ public void setWarningSize(int diameter) setWarningSize(diameter, 0, null); } - /** - * Returns the UHTimer object representing the countdown before the next border reduction. - * - *

Returns {@code null} if there isn't any countdown running currently.

- * - * @return The timer. - */ - public UHTimer getWarningTimer() - { - return p.getTimerManager().getTimer(this.warningTimerName); - } - /** * Stops the display of the warning messages. */ @@ -320,11 +290,10 @@ public void cancelWarning() catch (IllegalStateException ignored) {} } - UHTimer timer = getWarningTimer(); - if (timer != null) + if (warningTimer != null) { - timer.stop(); - p.getTimerManager().unregisterTimer(timer); + warningTimer.stop(); + UHCReloaded.getModule(TimersModule.class).unregisterTimer(warningTimer); } } @@ -393,21 +362,21 @@ else if (distance > 25) * Generates the walls in the given world, following the current border configuration. * * @param world The world were the walls will be built in. - * @throws CannotGenerateWallsException + * @throws CannotGenerateWallsException If an error occurred while generating the wall. */ public void generateWalls(World world) throws CannotGenerateWallsException { - Integer wallHeight = UHConfig.MAP.WALL.HEIGHT.get(); + Integer wallHeight = Config.WALL.HEIGHT.get(); - Material wallBlockAir = UHConfig.MAP.WALL.BLOCK.REPLACE_AIR.get(); - Material wallBlockSolid = UHConfig.MAP.WALL.BLOCK.REPLACE_SOLID.get(); + Material wallBlockAir = Config.WALL.BLOCK.REPLACE_AIR.get(); + Material wallBlockSolid = Config.WALL.BLOCK.REPLACE_SOLID.get(); if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid()) { throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config"); } - WallGenerator generator = mapShape.getWallGeneratorInstance(wallBlockAir, wallBlockSolid); + final WallGenerator generator = mapShape.getWallGeneratorInstance(wallBlockAir, wallBlockSolid); if (generator != null) generator.build(world, getCurrentBorderDiameter(), wallHeight); else @@ -419,18 +388,18 @@ public void generateWalls(World world) throws CannotGenerateWallsException */ public void scheduleBorderReduction() { - if (BORDER_SHRINKING) - { - RunTask.later(() -> { - Integer secondsPerBlock = (int) Math.rint(BORDER_SHRINKING_DURATION / (border.getDiameter() - BORDER_SHRINKING_FINAL_SIZE)) * 2; - - border.setDiameter(BORDER_SHRINKING_FINAL_SIZE, BORDER_SHRINKING_DURATION); - - Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); - - Bukkit.broadcastMessage(I.t("{red}{bold}The border begins to shrink...")); - Bukkit.broadcastMessage(I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, BORDER_SHRINKING_FINAL_SIZE)); - }, BORDER_SHRINKING_STARTS_AFTER * 20l); - } +// if (BORDER_SHRINKING) +// { +// RunTask.later(() -> { +// Integer secondsPerBlock = (int) Math.rint(BORDER_SHRINKING_DURATION / (border.getDiameter() - BORDER_SHRINKING_FINAL_SIZE)) * 2; +// +// border.setDiameter(BORDER_SHRINKING_FINAL_SIZE, BORDER_SHRINKING_DURATION); +// +// Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); +// +// Bukkit.broadcastMessage(I.t("{red}{bold}The border begins to shrink...")); +// Bukkit.broadcastMessage(I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, BORDER_SHRINKING_FINAL_SIZE)); +// }, BORDER_SHRINKING_STARTS_AFTER * 20l); +// } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java similarity index 73% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java index 584860e..755eb47 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java @@ -29,10 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.task; +package eu.carrade.amaury.UHCReloaded.modules.core.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -40,33 +39,29 @@ public class BorderWarningTask extends BukkitRunnable { - private final UHCReloaded p; - - public BorderWarningTask() - { - this.p = UHCReloaded.get(); - } + private final BorderModule module = UHCReloaded.getModule(BorderModule.class); @Override public void run() { - if (p.getFreezer().getGlobalFreezeState()) - { - return; // No messages are sent if the game is frozen. - } +// final FreezerModule freezer = UHCReloaded.getModule(FreezerModule.class); +// if (freezer != null && freezer.getGlobalFreezeState()) +// { +// return; // No messages are sent if the game is frozen. +// } // Message sent to all players outside the border - for (Player player : p.getBorderManager().getPlayersOutside(p.getBorderManager().getWarningSize())) + for (Player player : module.getPlayersOutside(module.getWarningSize())) { - double distance = p.getBorderManager().getDistanceToBorder(player.getLocation(), p.getBorderManager().getWarningSize()); + double distance = module.getDistanceToBorder(player.getLocation(), module.getWarningSize()); - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) + if (module.getMapShape() == MapShape.CIRCULAR) { - player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", p.getBorderManager().getWarningSize())); + player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", module.getWarningSize())); } else { - player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", p.getBorderManager().getWarningSize())); + player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", module.getWarningSize())); } player.sendMessage(I.tn("{ci}You have {0} block to go before being inside.", "{ci}You have {0} blocks to go before being inside.", (int) distance)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java new file mode 100644 index 0000000..f4f528e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java @@ -0,0 +1,87 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.border; + +import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import org.bukkit.Material; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem SIZE = item("size", 2000); + public static final ConfigurationItem SHAPE = item("shape", MapShape.SQUARED); + + public static final ConfigurationItem MOTOR = item("motor", WorldBorder.WorldBorderMotor.VANILLA); + public static final ConfigurationItem DAMAGES_BUFFER = item("damagesBuffer", 5d); + public static final ConfigurationItem DAMAGES_AMOUNT = item("damagesAmount", 0.2); + public static final ConfigurationItem WARNING_DISTANCE = item("warningDistance", 5); + + public static final ShrinkingSection SHRINKING = section("shrinking", ShrinkingSection.class); + + static public class ShrinkingSection extends ConfigurationSection + { + public final ConfigurationItem ENABLED = item("enabled", false); + public final ConfigurationItem STARTS_AFTER = item("startsAfter", "30:00"); + public final ConfigurationItem SHRINKS_DURING = item("shrinksDuring", "2:00:00"); + public final ConfigurationItem DIAMETER_AFTER_SHRINK = item("diameterAfterShrink", 200); + } + + public static final ConfigurationItem WARNING_INTERVAL = item("warningInterval", 90); + + public static final WallSection WALL = section("wall", WallSection.class); + + static public class WallSection extends ConfigurationSection + { + public final ConfigurationItem HEIGHT = item("height", 128); + + public final BlockSection BLOCK = section("block", BlockSection.class); + + static public class BlockSection extends ConfigurationSection + { + public final ConfigurationItem REPLACE_AIR = item("replaceAir", Material.GLASS); + public final ConfigurationItem REPLACE_SOLID = item("replaceSolid", Material.BEDROCK); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java index 842dc14..a2e2438 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/MapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders; +package eu.carrade.amaury.UHCReloaded.modules.core.border; -import eu.carrade.amaury.UHCReloaded.old.borders.generators.CircularWallGenerator; -import eu.carrade.amaury.UHCReloaded.old.borders.generators.SquaredWallGenerator; -import eu.carrade.amaury.UHCReloaded.old.borders.generators.WallGenerator; -import eu.carrade.amaury.UHCReloaded.old.borders.shapes.CircularMapShape; -import eu.carrade.amaury.UHCReloaded.old.borders.shapes.MapShapeDescriptor; -import eu.carrade.amaury.UHCReloaded.old.borders.shapes.SquaredMapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.CircularWallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.SquaredWallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.CircularMapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.MapShapeDescriptor; +import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.SquaredMapShape; import fr.zcraft.zlib.tools.PluginLogger; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java index f8345fc..5cbb9c4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions; public class CannotGenerateWallsException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java index 887d25c..68829ce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions; public class UnknownWallGenerator extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java index 8c0eb8d..51e8164 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java index 47e896c..7239677 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java index bd93415..bc8a868 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java index 618dd21..426d731 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; /** * Used to determine in witch wall we are, to get the "inner" block. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java index 4018844..9539cb6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/CircularMapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.shapes; +package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java index cb9930c..b156f88 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/MapShapeDescriptor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.shapes; +package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java index 42307c7..d842194 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/shapes/SquaredMapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.shapes; +package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java index 9462a3b..b03c467 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; import com.wimbli.WorldBorder.BorderData; import com.wimbli.WorldBorder.Config; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java index f8e386a..6818f56 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java index 7e72fa6..c3ed1cf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java index 67ea144..7ce4b3b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/borders/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.borders.worldborders; +package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; @@ -154,7 +154,7 @@ public void init() {} * * @return An instance of a WorldBorder proxy. */ - public static WorldBorder getInstance(World world, String motor, MapShape shape) + public static WorldBorder getInstance(World world, WorldBorderMotor motor, MapShape shape) { // For circular shapes, the vanilla motor cannot be used. // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). @@ -171,7 +171,7 @@ public static WorldBorder getInstance(World world, String motor, MapShape shape) } else { - if (motor.equalsIgnoreCase("vanilla") || !UHCReloaded.get().getWorldBorderIntegration().isWBIntegrationEnabled()) + if (motor == WorldBorderMotor.VANILLA || !UHCReloaded.get().getWorldBorderIntegration().isWBIntegrationEnabled()) { return new VanillaWorldBorder(world); } @@ -181,4 +181,19 @@ public static WorldBorder getInstance(World world, String motor, MapShape shape) } } } + + public enum WorldBorderMotor + { + /** + * Uses the vanilla world border (for squared borders only). + */ + VANILLA, + + /** + * Uses the Brettflan's WorldBorder plugin (for both squared and circular). + * + * If set for squared world borders and WorldBorder is not installed, fallbacks to vanilla. + */ + BRETTFLAN + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 94830b0..28320de 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -33,14 +33,18 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.StartCommand; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Listener; +import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; @@ -65,6 +69,12 @@ protected void onEnable() } + @Override + public List> getCommands() + { + return Collections.singletonList(StartCommand.class); + } + @Override public void injectIntoSidebar(Player player, SidebarInjector injector) { @@ -74,9 +84,22 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) ); } + /** + * @return the current phase of the game. + */ + public GamePhase getPhase() + { + return phase; + } + + /** + * Changes the phase of the game. + * + * @param phase The new phase (must be after the current one, else nothing is done). + */ public void setPhase(GamePhase phase) { - if (this.phase != phase) + if (this.phase != phase && phase.ordinal() > this.phase.ordinal()) { final GamePhase oldPhase = this.phase; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java new file mode 100644 index 0000000..d645889 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java @@ -0,0 +1,52 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.commands.WithFlags; + + +@CommandInfo (name = "start", usageParameters = "[--slow]") +@WithFlags ({"slow"}) +public class StartCommand extends Command +{ + @Override + protected void run() throws CommandException + { + UHCReloaded.getModule(GameModule.class).setPhase(GamePhase.STARTING); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java new file mode 100644 index 0000000..75918a6 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java @@ -0,0 +1,54 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.spawns; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationList; +import org.bukkit.Location; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem AVOID_WATER = item("avoid-water", true); + public static final ConfigurationList SPAWN_POINTS = list("spawn-points", Location.class); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/Generator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/Generator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java index 8351b77..56daea5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/Generator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java @@ -30,13 +30,13 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns; -import eu.carrade.amaury.UHCReloaded.spawns.generators.CircularSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.spawns.generators.GridSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.spawns.generators.RandomSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.spawns.generators.SpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.CircularSpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.GridSpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.RandomSpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.SpawnPointsGenerator; import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.reflection.Reflection; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/SpawnsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/SpawnsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java index 728250c..1e71bda 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/SpawnsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java @@ -29,41 +29,46 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ - -package eu.carrade.amaury.UHCReloaded.spawns; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.UnknownGeneratorException; -import eu.carrade.amaury.UHCReloaded.spawns.generators.SpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.SpawnPointsGenerator; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.util.Vector; import java.util.LinkedList; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; -public class SpawnsManager +@ModuleInfo ( + name = "Spawns", + description = "Manages the spawns point and allow users to generate them randomly", + settings = Config.class, + internal = true, + can_be_disabled = false +) +public class SpawnsModule extends UHModule { - private final boolean AVOID_WATER; - - private UHCReloaded p; - private LinkedList spawnPoints = new LinkedList<>(); + private List spawnPoints = new LinkedList<>(); + private BorderModule borderModule; - - public SpawnsManager(UHCReloaded plugin) + @Override + protected void onEnable() { - this.p = plugin; - - AVOID_WATER = UHConfig.MAP.SPAWN_POINTS.DONT_GENERATE_ABOVE_WATER.get(); + borderModule = UHCReloaded.getModule(BorderModule.class); + spawnPoints.addAll(Config.SPAWN_POINTS); } + /** * Adds a spawn point at (x;z) in the default world. * @@ -71,9 +76,9 @@ public SpawnsManager(UHCReloaded plugin) */ public void addSpawnPoint(final Vector vec) { - addSpawnPoint(p.getServer().getWorlds().get(0), vec.getX(), vec.getZ()); + addSpawnPoint(UHCReloaded.get().getWorld(World.Environment.NORMAL), vec.getX(), vec.getZ()); } - + /** * Adds a spawn point at (x;z) in the default world. * @@ -82,7 +87,7 @@ public void addSpawnPoint(final Vector vec) */ public void addSpawnPoint(final Double x, final Double z) { - addSpawnPoint(p.getServer().getWorlds().get(0), x, z); + addSpawnPoint(UHCReloaded.get().getWorld(World.Environment.NORMAL), x, z); } /** @@ -109,16 +114,16 @@ public void addSpawnPoint(final World world, final Double x, final Double z) */ public void addSpawnPoint(final Location location) { - Location spawnPoint = location.clone(); + final Location spawnPoint = location.clone(); // Initial fall, except in the nether. - if (!(spawnPoint.getWorld().getEnvironment() == Environment.NETHER)) + if (!(spawnPoint.getWorld().getEnvironment() == World.Environment.NETHER)) { spawnPoint.setY(location.getWorld().getHighestBlockYAt(location.getBlockX(), location.getBlockZ()) + 120); } else { - Location safeSpot = UHUtils.searchSafeSpot(location); + final Location safeSpot = UHUtils.searchSafeSpot(location); if (safeSpot == null) { throw new RuntimeException("Unable to find a safe spot to set the spawn point " + location.toString()); @@ -127,7 +132,7 @@ public void addSpawnPoint(final Location location) spawnPoint.setY(safeSpot.getY()); } - if (!p.getBorderManager().isInsideBorder(spawnPoint)) + if (!borderModule.isInsideBorder(spawnPoint)) { throw new IllegalArgumentException("The given spawn location is outside the current border"); } @@ -160,10 +165,10 @@ public boolean removeSpawnPoint(Location location, boolean precise) final List toRemove = getSpawnPoints().stream() .filter(spawn -> location.getWorld().equals(spawn.getWorld())) .filter(spawn -> precise - && location.getX() == spawn.getX() - && location.getZ() == spawn.getZ() || !precise - && location.getBlockX() == spawn.getBlockX() - && location.getBlockZ() == spawn.getBlockZ()) + && location.getX() == spawn.getX() + && location.getZ() == spawn.getZ() || !precise + && location.getBlockX() == spawn.getBlockX() + && location.getBlockZ() == spawn.getBlockZ()) .collect(Collectors.toCollection(LinkedList::new)); for (Location spawnToRemove : toRemove) @@ -195,7 +200,7 @@ public void reset() public int importSpawnPointsFromConfig() { int spawnCount = 0; - + for (Vector position: UHConfig.SPAWN_POINTS) { addSpawnPoint(position); @@ -284,8 +289,10 @@ public void generateSpawnPoints(Generator generator, World world, int spawnCount */ public void generateSpawnPoints(SpawnPointsGenerator generator, World world, int spawnCount, int regionDiameter, int minimalDistanceBetweenTwoPoints, double xCenter, double zCenter) throws CannotGenerateSpawnPointsException { - final Set spawnPoints = generator.generate(world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, xCenter, zCenter, AVOID_WATER); - - spawnPoints.forEach(this::addSpawnPoint); + generator.generate( + world, spawnCount, + regionDiameter, minimalDistanceBetweenTwoPoints, + xCenter, zCenter, Config.AVOID_WATER.get() + ).forEach(this::addSpawnPoint); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/CannotGenerateSpawnPointsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/CannotGenerateSpawnPointsException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java index b8289c8..f25df32 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/CannotGenerateSpawnPointsException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions; public class CannotGenerateSpawnPointsException extends Exception diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/UnknownGeneratorException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/UnknownGeneratorException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java index 1ab5892..8e8dfda 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/UnknownGeneratorException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions; public class UnknownGeneratorException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/CircularSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index 10aa435..c0c4dd3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -30,10 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -48,7 +49,7 @@ public class CircularSpawnPointsGenerator implements SpawnPointsGenerator { - private final UHCReloaded p = UHCReloaded.get(); + private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); /** * Generates spawn points in concentric circles. @@ -127,7 +128,7 @@ public Set generate(final World world, final int spawnCount, final int currentAngle += angleBetweenTwoPoints; // Just in case - if (!p.getBorderManager().isInsideBorder(point, regionDiameter)) + if (!borderModule.isInsideBorder(point, regionDiameter)) { continue; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java index 27b74f7..eadca2c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -29,11 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -47,7 +48,7 @@ public class GridSpawnPointsGenerator implements SpawnPointsGenerator { - private final UHCReloaded p = UHCReloaded.get(); + private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); /** * Generates spawn points in a grid. @@ -81,7 +82,7 @@ public Set generate(final World world, final int spawnCount, final int // The points are on a grid int neededColumnsCount = (int) Math.ceil(Math.sqrt(spawnCount)); - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) + if (borderModule.getMapShape() == MapShape.CIRCULAR) { // If the border is circular, the distance between two points needs to be decreased. // The space available is divided by PI/4, so the column count is multiplied by @@ -134,7 +135,7 @@ public Set generate(final World world, final int spawnCount, final int currentPoint = currentSquareStartPoint.clone(); // First point - if (p.getBorderManager().isInsideBorder(currentPoint, regionDiameter) && UHUtils.searchSafeSpot(currentPoint) != null) + if (borderModule.isInsideBorder(currentPoint, regionDiameter) && UHUtils.searchSafeSpot(currentPoint) != null) { generatedPoints.add(currentPoint.clone()); countGeneratedPoints++; @@ -156,7 +157,7 @@ public Set generate(final World world, final int spawnCount, final int plottedSize += distanceBetweenTwoPoints; // Inside the border? - if (!p.getBorderManager().isInsideBorder(currentPoint, regionDiameter)) + if (!borderModule.isInsideBorder(currentPoint, regionDiameter)) { continue; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index 0cb9295..3f00d7e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -30,11 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -53,7 +54,7 @@ public class RandomSpawnPointsGenerator implements SpawnPointsGenerator { private final Random random = new Random(); - private final UHCReloaded p = UHCReloaded.get(); + private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); /** * Generates randomly some spawn points in the map, with a minimal distance. @@ -87,7 +88,7 @@ public Set generate(final World world, final int spawnCount, final int final double surfacePrivatePartsAroundSpawnPoints = (int) (spawnCount * (Math.PI * minimalDistanceBetweenTwoPointsSquared)); final double surfaceRegion; - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) + if (borderModule.getMapShape() == MapShape.CIRCULAR) { surfaceRegion = (Math.PI * Math.pow(regionDiameter, 2)) / 4; } @@ -151,7 +152,7 @@ public Set generate(final World world, final int spawnCount, final int random((int) (zCenter - Math.floor(regionDiameter / 2)), (int) (zCenter + (int) Math.floor(regionDiameter / 2)))); // Inside the region? - if (!p.getBorderManager().isInsideBorder(randomPoint, regionDiameter)) + if (!borderModule.isInsideBorder(randomPoint, regionDiameter)) { continue; // outside: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java index 3342a25..8bb1207 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.spawns.generators; +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java new file mode 100644 index 0000000..186eb04 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java @@ -0,0 +1,141 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.timers; + +import fr.zcraft.zlib.components.configuration.ConfigurationParseException; +import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; +import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; + +import java.util.Objects; + + +public class TimeDelta +{ + private final long seconds; + + static + { + ConfigurationValueHandlers.registerHandlers(TimeDelta.class); + } + + /** + * Constructs a time delta. + * + * @param seconds The number of seconds in this delta. + */ + public TimeDelta(long seconds) + { + this.seconds = seconds; + } + + /** + * Constructs a time delta. + * + * @param hours The number of hours. + * @param minutes The number of minutes. + * @param seconds The number of seconds. + */ + public TimeDelta(long hours, long minutes, long seconds) + { + this(seconds + minutes * 60 + hours * 3600); + } + + /** + * Constructs a time delta from a raw string representing a time. + * + *

Allowed formats: + * + *

    + *
  • mm – number of minutes;
  • + *
  • mm:ss – minutes and seconds;
  • + *
  • hh:mm:ss – hours, minutes and seconds.
  • + *
+ * + * @param rawTime The raw time text. + * + * @throws IllegalArgumentException if the text is not formatted as above. + * @throws NumberFormatException if the text between the colons cannot be converted in integers. + */ + public TimeDelta(final String rawTime) throws IllegalArgumentException, NumberFormatException + { + final String[] split = rawTime.split(":"); + + if (rawTime.isEmpty() || split.length > 3) + { + throw new IllegalArgumentException("Badly formatted string in TimeDelta(String); formats allowed are mm, mm:ss or hh:mm:ss."); + } + + if (split.length == 1) // "mm" + { + this.seconds = Integer.valueOf(split[0]) * 60; + } + else if (split.length == 2) // "mm:ss" + { + this.seconds = Integer.valueOf(split[0]) * 60 + Integer.valueOf(split[1]); + } + else // "hh:mm:ss" + { + this.seconds = Integer.valueOf(split[0]) * 3600 + Integer.valueOf(split[1]) * 60 + Integer.valueOf(split[2]); + } + } + + public long getSeconds() + { + return seconds; + } + + @Override + public boolean equals(Object o) + { + return this == o || o != null && getClass() == o.getClass() && seconds == ((TimeDelta) o).seconds; + } + + @Override + public int hashCode() + { + return Objects.hash(seconds); + } + + + @ConfigurationValueHandler + public static TimeDelta handleTimeDelta(String rawDelta) throws ConfigurationParseException + { + try + { + return new TimeDelta(rawDelta); + } + catch (IllegalArgumentException e) + { + throw new ConfigurationParseException("Invalid time delta format", rawDelta); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java similarity index 56% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java index 2058d2d..b5273b8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/UHTimer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java @@ -30,10 +30,10 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.timers; +package eu.carrade.amaury.UHCReloaded.modules.core.timers; -import eu.carrade.amaury.UHCReloaded.events.TimerEndsEvent; -import eu.carrade.amaury.UHCReloaded.events.TimerStartsEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; import fr.zcraft.zlib.components.i18n.I; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -49,7 +49,7 @@ * * @author Amaury Carrade */ -public class UHTimer +public class Timer { private static final NumberFormat formatter = new DecimalFormat("00"); @@ -58,29 +58,20 @@ public class UHTimer private Boolean registered = false; private Boolean running = false; private Boolean displayed = false; + private Boolean nameDisplayed = true; private Long startTime = 0L; private Integer duration = 0; // seconds - // Cached values - private Integer hoursLeft = 0; - private Integer minutesLeft = 0; - private Integer secondsLeft = 0; - - // Old values, used by the scoreboard to reset the scores. - private Integer oldHoursLeft = -1; - private Integer oldMinutesLeft = -1; - private Integer oldSecondsLeft = -1; - // Pause private Boolean paused = false; private Long pauseTime = 0L; + private Integer elapsedWhenPaused = 0; - // Display this timer following the format "hh:mm:ss"? - private Boolean displayHoursInTimer = false; + private Boolean system = false; - public UHTimer(String name) + public Timer(String name) { Validate.notNull(name, "The name cannot be null"); @@ -88,6 +79,17 @@ public UHTimer(String name) this.name = name; } + public Timer(final String name, final int seconds) + { + this(name); + setDuration(seconds); + } + + public Timer(final String name, final TimeDelta duration) + { + this(name, Math.toIntExact(duration.getSeconds())); + } + /** * Sets the duration of the timer, in seconds. * @@ -96,12 +98,16 @@ public UHTimer(String name) public void setDuration(int seconds) { this.duration = seconds; + } - this.hoursLeft = (int) Math.floor(this.duration / 3600); - this.minutesLeft = (int) (Math.floor(this.duration / 60) - (this.hoursLeft * 60)); - this.secondsLeft = this.duration - (this.minutesLeft * 60 + this.hoursLeft * 3600); - - this.displayHoursInTimer = (this.hoursLeft != 0); + /** + * Sets the duration of the timer. + * + * @param duration The duration. + */ + public void setDuration(TimeDelta duration) + { + this.duration = Math.toIntExact(duration.getSeconds()); } /** @@ -143,45 +149,20 @@ private void stop(boolean wasUp) } else { - this.running = false; - this.startTime = 0L; - - this.hoursLeft = 0; - this.minutesLeft = 0; - this.secondsLeft = 0; - - this.oldHoursLeft = 0; - this.oldMinutesLeft = 0; - this.oldSecondsLeft = 0; + running = false; + startTime = 0L; } } } /** - * Updates the timer. + * Updates the timer to check if it is up and terminate it. */ public void update() { - if (running && !paused) + if (running && !paused && getElapsed() >= getDuration()) { - oldHoursLeft = hoursLeft; - oldMinutesLeft = minutesLeft; - oldSecondsLeft = secondsLeft; - - long timeSinceStart = System.currentTimeMillis() - this.startTime; // ms - - if (timeSinceStart >= getDuration() * 1000) - { - stop(true); - } - else - { - int countSecondsLeft = (int) (getDuration() - Math.floor(timeSinceStart / 1000)); - - secondsLeft = countSecondsLeft % 60; - minutesLeft = (countSecondsLeft % 3600) / 60; - hoursLeft = (int) Math.floor(countSecondsLeft / 3600); - } + stop(true); } } @@ -194,29 +175,35 @@ public void update() */ public void setPaused(boolean pause) { - if (this.running) + if (running) { // The pause is only set once (as example if the user executes /uh freeze all twice). - if (pause && !this.paused) + if (pause != paused) { - this.paused = true; - this.pauseTime = System.currentTimeMillis(); - } - - if (!pause && this.paused) - { - // We have to add to the time of the start of the episode the elapsed time - // during the pause. - this.startTime += (System.currentTimeMillis() - this.pauseTime); - this.pauseTime = 0l; - - this.paused = false; + if (pause) + { + elapsedWhenPaused = getElapsed(); + + paused = true; + pauseTime = System.currentTimeMillis(); + } + + else + { + // We have to add to the time of the start of the episode the elapsed time + // during the pause. + startTime += (System.currentTimeMillis() - pauseTime); + pauseTime = 0L; + + paused = false; + elapsedWhenPaused = 0; + } } } } /** - * Checks if the timer is registered in the TimerManager. + * Checks if the timer is registered in the TimersModule. * * @return true if the timer is registered. */ @@ -269,7 +256,7 @@ public Boolean isRunning() } /** - * Checks if the timer is currently displayed in the scoreboard. + * Checks if the timer is currently displayed in the sidebar. * * @return {@code true} if displayed. */ @@ -279,7 +266,7 @@ public Boolean isDisplayed() } /** - * Display or hide this timer in/from the scoreboard. + * Display or hide this timer in/from the sidebar. * * @param displayed {@code true} to display, and {@code false} to hide. */ @@ -289,79 +276,75 @@ public void setDisplayed(Boolean displayed) } /** - * Returns the duration of the timer, in seconds. + * Checks if the name of this timer should be displayed in the sidebar. * - * @return The duration. + * @return {@code true} if name displayed. */ - public Integer getDuration() + public Boolean isNameDisplayed() { - return duration; + return nameDisplayed; } /** - * Returns the number of hours left until the end of this countdown. + * Displays or hides the timer's name in/from the sidebar. * - * @return The number of hours left. + * @param nameDisplayed {@code true} to display, and {@code false} to hide. */ - public Integer getHoursLeft() + public void setNameDisplayed(Boolean nameDisplayed) { - return hoursLeft; + this.nameDisplayed = nameDisplayed; } /** - * Returns the number of minutes left until the end of this countdown. - * - * @return The number of minutes left. + * @return {@code true} if this is a system timer that cannot be altered by the user. */ - public Integer getMinutesLeft() + public Boolean isSystem() { - return minutesLeft; + return system; } /** - * Returns the number of seconds left until the end of this countdown. + * Sets if this timer is a system timer that cannot be altered by the user. * - * @return The number of seconds left. + * @param system {@code true} if this timer is an internal system timer. */ - public Integer getSecondsLeft() + public void setSystem(Boolean system) { - return secondsLeft; + this.system = system; } /** - * Returns the number of hours left until the end of this countdown, before the last update. - *

- * Used by the scoreboard, to remove the old score. + * Returns the duration of the timer, in seconds. * - * @return The old number of hours left, or -1 if the timer was never updated. + * @return The duration. */ - public Integer getOldHoursLeft() + public Integer getDuration() { - return oldHoursLeft; + return duration; } /** - * Returns the number of minutes left until the end of this countdown, before the last update. - *

- * Used by the scoreboard, to remove the old score. - * - * @return The old number of minutes left, or -1 if the timer was never updated. + * @return The elapsed time since the beginning of the timer (not including pauses), in seconds. */ - public Integer getOldMinutesLeft() + public int getElapsed() { - return oldMinutesLeft; + if (isRunning()) + { + if (isPaused()) + return elapsedWhenPaused; + else + return (int) Math.floor((System.currentTimeMillis() - startTime) / 1000); + } + + else return 0; } /** - * Returns the number of seconds left until the end of this countdown, before the last update. - *

- * Used by the scoreboard, to remove the old score. - * - * @return The old number of seconds left, or -1 if the timer was never updated. + * @return The number of seconds left before this timer is up. */ - public Integer getOldSecondsLeft() + public int getTimeLeft() { - return oldSecondsLeft; + return getDuration() - getElapsed(); } /** @@ -374,45 +357,45 @@ public Boolean isPaused() return paused; } - /** - * Returns true if this timer is displayed as "hh:mm:ss" in the scoreboard. - * - * @return true if this timer is displayed as "hh:mm:ss" in the scoreboard. - */ - public Boolean getDisplayHoursInTimer() + @Override + public String toString() { - return displayHoursInTimer; + return formatTime(getTimeLeft()); } @Override public boolean equals(Object other) { - return other instanceof UHTimer && ((UHTimer) other).getName().equals(this.getName()); + return other instanceof Timer && ((Timer) other).getName().equals(this.getName()); } @Override - public String toString() + public int hashCode() { - return toString(displayHoursInTimer); + return id.hashCode(); } - public String toString(boolean displayHours) + /** + * Formats a given number of seconds into [hh:]mm:ss. + * + * @param seconds The number of seconds. + * @return The formatted time (includes color codes). + */ + public static String formatTime(final int seconds) { - if (displayHours) + final int secondsLeft = seconds % 60; + final int minutesLeft = (seconds % 3600) / 60; + final int hoursLeft = (int) Math.floor(seconds / 3600); + + if (hoursLeft != 0) { /// Timer. {0} = hours; {1} = minutes; {2} = seconds. - return I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), formatter.format(minutesLeft), formatter.format(secondsLeft)); + return ChatColor.WHITE + I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), formatter.format(minutesLeft), formatter.format(secondsLeft)); } else { /// Timer. {0} = minutes; {1} = seconds. - return I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft)); + return ChatColor.WHITE +I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft)); } } - - @Override - public int hashCode() - { - return id.hashCode(); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java similarity index 56% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java index 48702ff..f43538f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/timers/TimerManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java @@ -30,53 +30,90 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.timers; - +package eu.carrade.amaury.UHCReloaded.modules.core.timers; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.commands.TimersCommand; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.apache.commons.lang3.tuple.Pair; +import org.bukkit.entity.Player; + +import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; +import java.util.stream.Collectors; -public class TimerManager +@ModuleInfo ( + name = "Timers", + description = "The timekeeper of the whole UHCReloaded plugin & companions", + internal = true, + can_be_disabled = false +) +public class TimersModule extends UHModule { - private Map timers = new ConcurrentHashMap<>(); - private UHTimer mainTimer = null; + private Set timers = new CopyOnWriteArraySet<>(); /** * Cached list of the running timers */ - private Map runningTimers = new ConcurrentHashMap<>(); + private Set runningTimers = new CopyOnWriteArraySet<>(); /** * List of the timers to resume if running timers are paused. * - * @see {@link #pauseAllRunning(boolean)}. + * @see #pauseAllRunning(boolean) */ - private Set timersToResume = new CopyOnWriteArraySet<>(); - + private Set timersToResume = new CopyOnWriteArraySet<>(); /** - * Registers the main timer, used to display the episodes countdown. - * - * @param timer The timer. + * Sidebar cache. */ - public void registerMainTimer(UHTimer timer) + private List> sidebarInjection = new LinkedList<>(); + + + @Override + protected void onEnable() { - this.mainTimer = timer; - timer.setRegistered(true); + RunTask.timer(() -> timers.forEach(Timer::update), 1L, 20L); } - /** - * Returns the main timer, used to display the episodes countdown. - * - * @return The main timer. - */ - public UHTimer getMainTimer() + + @Override + public List> getCommands() { - return this.mainTimer; + return Collections.singletonList(TimersCommand.class); + } + + + @Override + public void prepareInjectionIntoSidebar() + { + sidebarInjection.clear(); + sidebarInjection = timers.stream() + .filter(Timer::isDisplayed) + .map(timer -> Pair.of(timer.isNameDisplayed() ? timer.getDisplayName() : null, timer.toString())) + .collect(Collectors.toList()); + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + sidebarInjection.forEach(timer -> { + final List lines; + + if (timer.getLeft() == null) lines = Collections.singletonList(timer.getRight()); + else lines = Arrays.asList(timer.getLeft(), timer.getRight()); + + injector.injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, true, lines); + }); } /** @@ -85,14 +122,14 @@ public UHTimer getMainTimer() * @param timer The timer to register. * @throws IllegalArgumentException if a timer with the same name is already registered. */ - public void registerTimer(UHTimer timer) + public void registerTimer(final Timer timer) { - if (timers.get(timer.getName()) != null) + if (timers.contains(timer)) { - throw new IllegalArgumentException("A timer with the name " + timer.getName() + " is already registered."); + throw new IllegalArgumentException("The timer " + timer.getName() + " is already registered."); } - timers.put(timer.getName(), timer); + timers.add(timer); timer.setRegistered(true); } @@ -104,10 +141,10 @@ public void registerTimer(UHTimer timer) * * @param timer The timer to unregister. */ - public void unregisterTimer(UHTimer timer) + public void unregisterTimer(final Timer timer) { - timers.remove(timer.getName()); - runningTimers.remove(timer.getName()); + timers.remove(timer); + runningTimers.remove(timer); timer.setRegistered(false); } @@ -117,16 +154,7 @@ public void unregisterTimer(UHTimer timer) */ public void updateStartedTimersList() { - runningTimers = new HashMap<>(); - - if (getMainTimer() != null && getMainTimer().isRunning()) - { - runningTimers.put(getMainTimer().getName(), getMainTimer()); - } - - timers.values().stream() - .filter(UHTimer::isRunning) - .forEach(timer -> runningTimers.put(timer.getName(), timer)); + runningTimers = timers.stream().filter(Timer::isRunning).collect(Collectors.toSet()); } /** @@ -134,11 +162,11 @@ public void updateStartedTimersList() * * @param name The name of the timer. * - * @return The timer, or null if there isn't any timer with this name. + * @return The first timer with this name, or null if there isn't any timer with this name. */ - public UHTimer getTimer(String name) + public Timer getTimer(final String name) { - return timers.get(name); + return timers.stream().filter(timer -> timer.getName().equals(name)).findFirst().orElse(null); } /** @@ -146,9 +174,9 @@ public UHTimer getTimer(String name) * * @return The collection. */ - public Collection getTimers() + public Collection getTimers() { - return timers.values(); + return Collections.unmodifiableSet(timers); } /** @@ -156,9 +184,9 @@ public Collection getTimers() * * @return The collection. */ - public Collection getRunningTimers() + public Collection getRunningTimers() { - return runningTimers.values(); + return Collections.unmodifiableSet(runningTimers); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java new file mode 100644 index 0000000..86c0e11 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java @@ -0,0 +1,388 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.timers.commands; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.commands.WithFlags; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.components.rawtext.RawTextPart; +import fr.zcraft.zlib.tools.text.MessageSender; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.util.Collection; + + +@CommandInfo (name = "timers", usageParameters = "[add|display|hide|list|pause|resume|remove|set|start|stop|help]", aliases = {"timer"}) +@WithFlags +public class TimersCommand extends Command +{ + private final TimersModule timersModule = UHCReloaded.getModule(TimersModule.class); + + @Override + protected void run() throws CommandException + { + if (args.length == 0) + { + list(); + return; + } + + switch (args[0].toLowerCase()) + { + case "add": + add(); break; + + case "display": + display(); break; + + case "hide": + hide(); break; + + case "list": + list(); break; + + case "pause": + pause(); break; + + case "resume": + resume(); break; + + case "remove": + remove(); break; + + case "set": + set(); break; + + case "start": + start(); break; + + case "stop": + stop(); break; + + case "help": + default: + help(); + } + } + + private void help() + { + info(I.t("{blue}{bold}Command help for {cc}{bold}/uh timers")); + info(I.t("{cc}/uh timers add {ci}: adds a timer.")); + info(I.t("{cc}/uh timers display <title ...> [--without-name] {ci}: displays a timer in the scoreboard. Automatic when a timer is started.")); + info(I.t("{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. Don't stops the timer.")); + info(I.t("{cc}/uh timers list {ci}: lists the registered timers.")); + info(I.t("{cc}/uh timers pause <title ...> {ci}: pauses a timer.")); + info(I.t("{cc}/uh timers resume <title ...> {ci}: resumes a timer.")); + info(I.t("{cc}/uh timers remove <title ...> {ci}: deletes a timer.")); + info(I.t("{cc}/uh timers set <duration> <title ...> {ci}: sets the duration of a timer.")); + info(I.t("{cc}/uh timers start <title ...> {ci}: starts a timer.")); + info(I.t("{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be removed from the scoreboard.")); + } + + private void add() throws CommandException + { + if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name.")); + + final String name = UHUtils.getStringFromCommandArguments(args, 2); + + if (timersModule.getTimer(name) != null) + throwInvalidArgument(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", name)); + + final Timer timer = new Timer(name, getTimeDeltaParameter(1)); + timersModule.registerTimer(timer); + + success(I.t("{cs}The timer {0}{cs} (duration {1}) has been registered.", timer.getDisplayName(), args[1])); + } + + private void display() throws CommandException + { + final Timer timer = getTimerParameter(1); + + timer.setDisplayed(true); + timer.setNameDisplayed(!hasFlag("without-name")); + + reply(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName())); + } + + private void hide() throws CommandException + { + final Timer timer = getTimerParameter(1); + + timer.setDisplayed(false); + + reply(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName())); + } + + private void list() + { + final Collection<Timer> timers = timersModule.getTimers(); + + info(""); + info(I.tn("{ci}{0} timer is registered.", "{ci}{0} timers are registered.", timers.size())); + + for (final Timer timer : timers) + { + final RawTextPart timerText = new RawText() + .then(" • ").color(timer.isRunning() ? (timer.isPaused() ? ChatColor.YELLOW : ChatColor.GREEN) : ChatColor.RED) + .then(timer.getDisplayName()) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n") + .then(timer.isRunning() ? (timer.isPaused() ? I.t("Paused") : I.t("Running")) : I.t("Not started")) + .then("\n\n") + .then(timer.toString() + (timer.isRunning() ? " " + I.t("{gray}(total: {0}{gray})", Timer.formatTime(timer.getDuration())) : "")) + .then(timer.isSystem() ? "\n\n" + I.t("{gray}{bold}System timer") : "") + .then(timer.isSystem() ? "\n" + I.t("{gray}This timer is a system timer, it cannot be modified (you can still display or hide it to/from the sidebar).") : "") + ) + .then(" ") + .then("[ \u272F ]") + .color(timer.isDisplayed() ? ChatColor.DARK_PURPLE : ChatColor.LIGHT_PURPLE) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(timer.isDisplayed() ? I.t("{white}Hide this timer from the sidebar") : I.t("{white}Show this timer in the sidebar")) + ) + .command(TimersCommand.class, timer.isDisplayed() ? "hide" : "display", timer.getName(), "--from-list-command") + .then(" "); + + if (!timer.isSystem()) + { + if (!timer.isRunning()) + { + timerText + .then("[ \u25B6 ]") + .style(ChatColor.GREEN) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Start this timer")) + ) + .command(TimersCommand.class, "start", timer.getName(), "--from-list-command"); + } + else + { + timerText + .then("[ \u2B1B ]") + .style(ChatColor.RED) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Stop this timer")) + ) + .command(TimersCommand.class, "stop", timer.getName(), "--from-list-command"); + } + + timerText.then(" "); + + if (timer.isRunning()) + { + timerText + .then("[ \u2759 \u2759 ]") + .style(timer.isPaused() ? ChatColor.GOLD : ChatColor.YELLOW) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(timer.isPaused() ? I.t("{white}Resume this timer") : I.t("{white}Pause this timer")) + ) + .command(TimersCommand.class, timer.isPaused() ? "resume" : "pause", timer.getName(), "--from-list-command") + .then(" "); + } + + timerText + .then("[ × ]") + .style(ChatColor.DARK_RED) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Delete this timer")) + ) + .command(TimersCommand.class, "remove", timer.getName(), "--from-list-command"); + } + + send(timerText.build()); + } + + if (sender instanceof Player) + { + send( + /// Button in /uh timers + new RawText(I.t("[ Create a new timer ]")) + .color(ChatColor.GREEN) + .hover(I.t("{white}Click here to create a timer\n{gray}/uh timers add mm:ss <name>")) + .suggest(TimersCommand.class, "add", "") + + /// Button in /uh timers + .then(" ").then(I.t("[ Display Help ]")) + .color(ChatColor.YELLOW) + .hover(I.t("{white}Get some help about the commands\n{gray}/uh timers help")) + .command(TimersCommand.class, "help") + .build() + ); + } + } + + private void pause() throws CommandException + { + final Timer timer = getTimerParameter(1); + + if (timer.isSystem()) throwNotAuthorized(); + + timer.setPaused(true); + + reply(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName())); + } + + private void resume() throws CommandException + { + final Timer timer = getTimerParameter(1); + + if (timer.isSystem()) throwNotAuthorized(); + + timer.setPaused(false); + + reply(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName())); + } + + private void remove() throws CommandException + { + final Timer timer = getTimerParameter(1); + + if (timer.isSystem()) throwNotAuthorized(); + + timer.stop(); + timersModule.unregisterTimer(timer); + + reply(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName())); + } + + private void set() throws CommandException + { + if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name.")); + + final Timer timer = getTimerParameter(2); + if (timer.isSystem()) throwNotAuthorized(); + + timer.setDuration(getTimeDeltaParameter(1)); + + success(I.t("{cs}The duration of the timer {0}{cs} is now {1}.", timer.getDisplayName(), args[1])); + } + + private void start() throws CommandException + { + final Timer timer = getTimerParameter(1); + + if (timer.isSystem()) throwNotAuthorized(); + + if (!hasFlag("--hidden")) + { + timer.setDisplayed(true); + timer.setNameDisplayed(!hasFlag("without-name")); + } + + if (timer.isRunning()) timer.stop(); + timer.start(); + + reply(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName())); + } + + private void stop() throws CommandException + { + final Timer timer = getTimerParameter(1); + + if (timer.isSystem()) throwNotAuthorized(); + + timer.stop(); + + reply(I.t("{cs}The timer {0}{cs} was stopped.", timer.getDisplayName())); + } + + + private void reply(final String reply) throws CommandException + { + if (hasFlag("from-list-command") && sender instanceof Player) + { + MessageSender.sendActionBarMessage(playerSender(), reply); + list(); + } + + else success(reply); + } + + + private Timer getTimerParameter(int index) throws CommandException + { + try + { + final String timerName = UHUtils.getStringFromCommandArguments(args, index); + final Timer timer = UHCReloaded.getModule(TimersModule.class).getTimer(timerName); + + if (timer == null) + throwInvalidArgument(I.t("{ce}This timer is not registered.", timerName)); + + return timer; + } + catch (IllegalArgumentException e) + { + throwInvalidArgument(I.t("A timer name is required as argument #{0}", index + 1)); + return null; + } + } + + private TimeDelta getTimeDeltaParameter(final int index) throws CommandException + { + try + { + return new TimeDelta(args[index]); + } + catch (final ArrayIndexOutOfBoundsException e) + { + throwInvalidArgument(I.t("A duration is required as argument #{0}. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1)); + return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings + } + catch (final IllegalArgumentException e) + { + throwInvalidArgument(I.t("The duration provided as argument #{0} is invalid. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1)); + return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java index 626fc2b..4fe5a45 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.modules.core.timers.events; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -44,12 +44,12 @@ */ public final class TimerEndsEvent extends Event { - private UHTimer timer; + private Timer timer; private Boolean timerWasUp = false; private Boolean restart = false; - public TimerEndsEvent(UHTimer timer, Boolean timerUp) + public TimerEndsEvent(Timer timer, Boolean timerUp) { this.timer = timer; @@ -61,7 +61,7 @@ public TimerEndsEvent(UHTimer timer, Boolean timerUp) * * @return the timer. */ - public UHTimer getTimer() + public Timer getTimer() { return timer; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java index b4c191c..f015d16 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.modules.core.timers.events; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -44,9 +44,9 @@ */ public final class TimerStartsEvent extends Event { - private UHTimer timer; + private Timer timer; - public TimerStartsEvent(UHTimer timer) + public TimerStartsEvent(Timer timer) { this.timer = timer; } @@ -56,7 +56,7 @@ public TimerStartsEvent(UHTimer timer) * * @return */ - public UHTimer getTimer() + public Timer getTimer() { return timer; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 0ec6754..03d7f6e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -54,7 +54,6 @@ import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPCommand; import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPSpawnCommand; import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTeamCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTimersCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; @@ -94,7 +93,6 @@ public UHRootCommand(UHCReloaded plugin) // Misc registerSubCommand(new UHFinishCommand(p)); registerSubCommand(new UHFreezeCommand(p)); - registerSubCommand(new UHTimersCommand(p)); registerSubCommand(new UHTPCommand(p)); registerSubCommand(new UHInfosCommand(p)); registerSubCommand(new UHRulesCommand(p)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java index 5a92695..ea42728 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java @@ -32,7 +32,6 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.exceptions.CannotGenerateWallsException; import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; @@ -90,23 +89,22 @@ else if (sender instanceof BlockCommandSender) sender.sendMessage(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName())); } - try - { - p.getBorderManager().generateWalls(world); - - } - catch (CannotGenerateWallsException e) - { - sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); - return; - - } - catch (Exception e) - { - sender.sendMessage(I.t("{ce}An error occurred, see console for details.")); - e.printStackTrace(); - return; - } +// try +// { +// p.getBorderManager().generateWalls(world); +// } +// catch (CannotGenerateWallsException e) +// { +// sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); +// return; +// +// } +// catch (Exception e) +// { +// sender.sendMessage(I.t("{ce}An error occurred, see console for details.")); +// e.printStackTrace(); +// return; +// } sender.sendMessage(I.t("{cst}Generation done.")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java deleted file mode 100644 index 04f0526..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTimersCommand.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersAddCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersDisplayCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersHideCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersListCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersPauseCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersRemoveCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersResumeCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersSetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStartCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers.UHTimersStopCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -/** - * This command manages timers. - * - * Usage: /uh timers < add | set | display | hide | start | pause | resume | stop | remove | list > - */ -@Command (name = "timers") -public class UHTimersCommand extends AbstractCommand -{ - public UHTimersCommand(UHCReloaded plugin) - { - registerSubCommand(new UHTimersAddCommand(plugin)); - registerSubCommand(new UHTimersSetCommand(plugin)); - registerSubCommand(new UHTimersDisplayCommand(plugin)); - registerSubCommand(new UHTimersHideCommand(plugin)); - registerSubCommand(new UHTimersStartCommand(plugin)); - registerSubCommand(new UHTimersPauseCommand(plugin)); - registerSubCommand(new UHTimersResumeCommand(plugin)); - registerSubCommand(new UHTimersStopCommand(plugin)); - registerSubCommand(new UHTimersRemoveCommand(plugin)); - registerSubCommand(new UHTimersListCommand(plugin)); - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Collections.singletonList(I.t("{aqua}------ Timers commands ------")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers {ci}: manages the timers. See /uh timers for details.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java index 7dc54ee..51b7bdd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java @@ -64,8 +64,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand { try { - p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0])); - +// p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0])); } catch (NumberFormatException e) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java index f319394..66cab42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java @@ -32,7 +32,6 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; @@ -55,14 +54,14 @@ public UHBorderGetCommand(UHCReloaded p) @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException { - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) - { - sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter())); - } - else - { - sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter())); - } +// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) +// { +// sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter())); +// } +// else +// { +// sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter())); +// } } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java index 916d686..ec83ece 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java @@ -32,7 +32,6 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; @@ -56,75 +55,75 @@ public UHBorderSetCommand(UHCReloaded p) @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException { - // /uh border set - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - // /uh border set <?> - else if (args.length == 1) - { - try - { - final int newDiameter = Integer.valueOf(args[0]); - - // Some players are outside - if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0) - { - sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); - sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); - - if (!p.getWorldBorderIntegration().isWBIntegrationEnabled()) - { - sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); - } - - p.getBorderManager().sendCheckMessage(sender, newDiameter); - } - else - { - p.getBorderManager().setCurrentBorderDiameter(newDiameter); - - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) - { - p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); - } - else - { - p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); - } - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); - } - } - - // /uh border set <?> force - else if (args.length == 2 && args[1].equalsIgnoreCase("force")) - { - try - { - Integer newDiameter = Integer.valueOf(args[0]); - - p.getBorderManager().setCurrentBorderDiameter(newDiameter); - - if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) - { - p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); - } - else - { - p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); - } - } +// // /uh border set +// if (args.length == 0) +// { +// throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); +// } +// +// // /uh border set <?> +// else if (args.length == 1) +// { +// try +// { +// final int newDiameter = Integer.valueOf(args[0]); +// +// // Some players are outside +// if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0) +// { +// sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); +// sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); +// +// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled()) +// { +// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); +// } +// +// p.getBorderManager().sendCheckMessage(sender, newDiameter); +// } +// else +// { +// p.getBorderManager().setCurrentBorderDiameter(newDiameter); +// +// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) +// { +// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); +// } +// else +// { +// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); +// } +// } +// } +// catch (NumberFormatException e) +// { +// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); +// } +// } +// +// // /uh border set <?> force +// else if (args.length == 2 && args[1].equalsIgnoreCase("force")) +// { +// try +// { +// Integer newDiameter = Integer.valueOf(args[0]); +// +// p.getBorderManager().setCurrentBorderDiameter(newDiameter); +// +// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) +// { +// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); +// } +// else +// { +// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); +// } +// } +// catch (NumberFormatException e) +// { +// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); +// } +// } } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java index 481bd91..807e3d7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java @@ -69,7 +69,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand } else if (args[0].equalsIgnoreCase("cancel")) { // /uh border warning cancel - p.getBorderManager().cancelWarning(); + // p.getBorderManager().cancelWarning(); sender.sendMessage(I.t("{cs}Warning canceled.")); } else @@ -85,7 +85,7 @@ else if (args[0].equalsIgnoreCase("cancel")) warnTime = Integer.parseInt(args[1]); } - p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender); + // p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender); sender.sendMessage(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", WARNING_INTERVAL)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java index 12347b2..9df5607 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java @@ -93,7 +93,7 @@ else if (sender instanceof BlockCommandSender) Player pl = (Player) sender; // Just a way to avoid casts everywhere. try { - p.getSpawnsManager().addSpawnPoint(pl.getLocation()); + // p.getSpawnsManager().addSpawnPoint(pl.getLocation()); sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ()))); } catch (IllegalArgumentException e) @@ -118,7 +118,7 @@ else if (args.length == 1) { try { - p.getSpawnsManager().addSpawnPoint(world, Double.parseDouble(args[0]), Double.parseDouble(args[1])); + // p.getSpawnsManager().addSpawnPoint(world, Double.parseDouble(args[0]), Double.parseDouble(args[1])); sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[0], args[1])); } catch (NumberFormatException e) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java index 45c6fed..cf1cddf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java @@ -75,10 +75,10 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand spanwsInWorlds.put(world, new LinkedList<>()); } - for (Location spawn : p.getSpawnsManager().getSpawnPoints()) - { - spanwsInWorlds.get(spawn.getWorld()).add(spawn); - } +// for (Location spawn : p.getSpawnsManager().getSpawnPoints()) +// { +// spanwsInWorlds.get(spawn.getWorld()).add(spawn); +// } StringBuilder dump = new StringBuilder(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java index 35bfeba..50640bf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java @@ -32,13 +32,11 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.Generator; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.spawns.Generator; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.spawns.exceptions.UnknownGeneratorException; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.World; @@ -73,7 +71,6 @@ public UHSpawnsGenerateCommand(UHCReloaded plugin) @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException { - if (args.length == 0) { // Help throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); @@ -82,7 +79,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand String generationMethod = args[0]; // Default values - int size = p.getBorderManager().getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border + int size = 0; //p.getBorderManager().getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border int distanceMinBetweenTwoPoints = 250; World world = p.getServer().getWorlds().get(0); double xCenter = world.getSpawnLocation().getX(); @@ -195,22 +192,21 @@ else if (sender instanceof BlockCommandSender) } - try - { - p.getSpawnsManager().generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); - - } - catch (UnknownGeneratorException e) - { - sender.sendMessage(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod)); - return; - - } - catch (CannotGenerateSpawnPointsException e) - { - sender.sendMessage(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); - return; - } +// try +// { +// p.getSpawnsManager().generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); +// } +// catch (UnknownGeneratorException e) +// { +// sender.sendMessage(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod)); +// return; +// +// } +// catch (CannotGenerateSpawnPointsException e) +// { +// sender.sendMessage(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); +// return; +// } sender.sendMessage(I.t("{cs}Successfully generated the asked spawn points.")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java index 87700e8..eecf361 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java @@ -40,6 +40,7 @@ import org.bukkit.World; import org.bukkit.command.CommandSender; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -68,7 +69,7 @@ public UHSpawnsListCommand(UHCReloaded plugin) @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException { - List<Location> spawnPoints = p.getSpawnsManager().getSpawnPoints(); + List<Location> spawnPoints = new ArrayList<>(); // p.getSpawnsManager().getSpawnPoints(); if (spawnPoints.size() == 0) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java index db1e09e..b0f3917 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java @@ -36,7 +36,6 @@ import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -76,7 +75,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand else { Player pl = (Player) sender; // Just a way to avoid casts everywhere. - p.getSpawnsManager().removeSpawnPoint(pl.getLocation(), false); + // p.getSpawnsManager().removeSpawnPoint(pl.getLocation(), false); sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", pl.getWorld().getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ()))); } } @@ -98,7 +97,7 @@ else if (args.length == 1) world = p.getServer().getWorlds().get(0); } - p.getSpawnsManager().removeSpawnPoint(new Location(world, Double.parseDouble(args[2]), 0, Double.parseDouble(args[3])), true); + // p.getSpawnsManager().removeSpawnPoint(new Location(world, Double.parseDouble(args[2]), 0, Double.parseDouble(args[3])), true); sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", p.getServer().getWorlds().get(0).getName(), args[2], args[3])); } catch (NumberFormatException e) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java index 3f8cc14..f06e09a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java @@ -63,7 +63,7 @@ public UHSpawnsResetCommand(UHCReloaded plugin) @Override public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException { - p.getSpawnsManager().reset(); + // p.getSpawnsManager().reset(); sender.sendMessage(I.t("{cs}All the spawn points were removed.")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java deleted file mode 100644 index 36fa46d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersAddCommand.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - - -/** - * Usage: /uh timers add <duration> <name ...> - */ -@Command (name = "add") -public class UHTimersAddCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersAddCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - - if (args.length < 2) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - else - { - try - { - Integer duration = UHUtils.string2Time(args[0]); - String timerName = UHUtils.getStringFromCommandArguments(args, 1); - - if (p.getTimerManager().getTimer(timerName) != null) - { - sender.sendMessage(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", timerName)); - return; - } - - UHTimer timer = new UHTimer(timerName); - timer.setDuration(duration); - - p.getTimerManager().registerTimer(timer); - sender.sendMessage(I.t("{cs}The timer {0}{cs} (duration {1}) has been registered.", timer.getDisplayName(), args[0])); - - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}The duration' syntax is invalid; accepted formats are mm, mm:ss or hh:mm:ss.")); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers add <duration> <title ...> {ci}: adds a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java deleted file mode 100644 index c6e4504..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersDisplayCommand.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "display") -public class UHTimersDisplayCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersDisplayCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - sender.sendMessage(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers display <title ...> {ci}: displays a timer in the scoreboard. Automatic when a timer is started.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java deleted file mode 100644 index 3575b22..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersHideCommand.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "hide") -public class UHTimersHideCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersHideCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - - UHTimer timer = p.getTimerManager().getTimer(timerName); - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - sender.sendMessage(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. Don't stops the timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java deleted file mode 100644 index ac08925..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersListCommand.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - - -@Command (name = "list") -public class UHTimersListCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersListCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - Collection<UHTimer> timers = p.getTimerManager().getTimers(); - - sender.sendMessage(I.tn("{ci}{0} timer is registered.", "{ci}{0} timers are registered.", timers.size())); - - for (UHTimer timer : timers) - { - if (timer.isRunning()) - { - if (timer.isPaused()) - { - sender.sendMessage(I.tn("{yellow} • {{ci}{0}{ci} - total {1} second - {2}", "{yellow} • {{ci}{0}{ci} - total {1} seconds - {2}", - timer.getDuration(), - timer.getDisplayName(), - timer.getDuration(), - timer.toString() - )); - } - else - { - sender.sendMessage(I.tn("{green} • {ci}{0}{ci} - total {1} second - {2}", "{green} • {ci}{0}{ci} - total {1} seconds - {2}", - timer.getDuration(), - timer.getDisplayName(), - timer.getDuration(), - timer.toString() - )); - } - } - else - { - sender.sendMessage(I.tn("{red} • {ci}{0}{ci} - total {1} second", "{red} • {ci}{0}{ci} - total {1} seconds", - timer.getDuration(), - timer.getDisplayName(), - timer.getDuration() - )); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers list {ci}: lists the registered timers.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java deleted file mode 100644 index edff3a6..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersPauseCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "pause") -public class UHTimersPauseCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersPauseCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - timer.setPaused(true); - sender.sendMessage(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers pause <title ...> {ci}: pauses a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java deleted file mode 100644 index 3b47183..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersRemoveCommand.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "remove") -public class UHTimersRemoveCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersRemoveCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - p.getTimerManager().unregisterTimer(timer); - timer.stop(); - - sender.sendMessage(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers remove <title ...> {ci}: deletes a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java deleted file mode 100644 index aeb4b2c..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersResumeCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "resume") -public class UHTimersResumeCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersResumeCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - timer.setPaused(false); - sender.sendMessage(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers resume <title ...> {ci}: resumes a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java deleted file mode 100644 index 08cce95..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersSetCommand.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -/** - * Usage: /uh timers set <duration> <name ...> - */ -@Command (name = "set") -public class UHTimersSetCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersSetCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - - if (args.length < 2) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - else - { - try - { - Integer duration = UHUtils.string2Time(args[0]); - String timerName = UHUtils.getStringFromCommandArguments(args, 1); - - UHTimer timer = p.getTimerManager().getTimer(timerName); - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - timer.setDuration(duration); - sender.sendMessage(I.t("{cs}The duration of the timer {0}{cs} is now {1}.", timer.getDisplayName(), args[0])); - - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}The duration' syntax is invalid; accepted formats are mm, mm:ss or hh:mm:ss.")); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - - if (args.length >= 2) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 1), suggestions, args.length - 2); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers set <duration> <title ...> {ci}: sets the duration of a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java deleted file mode 100644 index 398440f..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStartCommand.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "start") -public class UHTimersStartCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersStartCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - if (timer.isRunning()) - { - timer.stop(); - } - - timer.start(); - sender.sendMessage(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers start <title ...> {ci}: starts a timer.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java deleted file mode 100644 index 6107a46..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/timers/UHTimersStopCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.timers; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "stop") -public class UHTimersStopCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTimersStopCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - String timerName = UHUtils.getStringFromCommandArguments(args, 0); - UHTimer timer = p.getTimerManager().getTimer(timerName); - - if (timer == null) - { - sender.sendMessage(I.t("{ce}This timer is not registered.")); - return; - } - - timer.stop(); - sender.sendMessage(I.t("{cs}The timer {0}{cs} was stopped.", timer.getDisplayName())); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - List<String> suggestions = new ArrayList<>(); - - for (UHTimer timer : p.getTimerManager().getTimers()) - { - suggestions.add(timer.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be removed from the scoreboard.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 5c6276f..5897dc2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -35,8 +35,8 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.events.EpisodeChangedCause; -import eu.carrade.amaury.UHCReloaded.events.TimerEndsEvent; -import eu.carrade.amaury.UHCReloaded.events.TimerStartsEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.events.UHGameEndsEvent; import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; @@ -560,24 +560,24 @@ else if (p.getTeamChatManager().isOtherTeamChatEnabled(ev.getPlayer())) @EventHandler public void onTimerEnds(final TimerEndsEvent ev) { - p.getTimerManager().updateStartedTimersList(); - - if (ev.getTimer().equals(p.getTimerManager().getMainTimer())) - { - // If this timer is the main one, we shifts an episode. - p.getGameManager().shiftEpisode(); - ev.setRestart(true); - } - else - { - ev.getTimer().setDisplayed(false); - } - - if (ev.getTimer().equals(p.getBorderManager().getWarningTimer()) && ev.wasTimerUp()) - { - p.getBorderManager().getWarningSender().sendMessage(I.t("{cs}The timer before the new border is up!")); - p.getBorderManager().sendCheckMessage(p.getBorderManager().getWarningSender(), p.getBorderManager().getWarningSize()); - } +// p.getTimerManager().updateStartedTimersList(); +// +// if (ev.getTimer().equals(p.getTimerManager().getMainTimer())) +// { +// // If this timer is the main one, we shifts an episode. +// p.getGameManager().shiftEpisode(); +// ev.setRestart(true); +// } +// else +// { +// ev.getTimer().setDisplayed(false); +// } +// +// if (ev.getTimer().equals(p.getBorderManager().getWarningTimer()) && ev.wasTimerUp()) +// { +// p.getBorderManager().getWarningSender().sendMessage(I.t("{cs}The timer before the new border is up!")); +// p.getBorderManager().sendCheckMessage(p.getBorderManager().getWarningSender(), p.getBorderManager().getWarningSize()); +// } } /** @@ -588,12 +588,12 @@ public void onTimerEnds(final TimerEndsEvent ev) @EventHandler public void onTimerStarts(final TimerStartsEvent ev) { - p.getTimerManager().updateStartedTimersList(); - - if (!ev.getTimer().equals(p.getTimerManager().getMainTimer())) - { - ev.getTimer().setDisplayed(true); - } +// p.getTimerManager().updateStartedTimersList(); +// +// if (!ev.getTimer().equals(p.getTimerManager().getMainTimer())) +// { +// ev.getTimer().setDisplayed(true); +// } } @@ -665,7 +665,7 @@ public void onGameStarts(final UHGameStartsEvent ev) p.getRuntimeCommandsExecutor().registerCommandsInScheduler(RuntimeCommandsExecutor.AFTER_GAME_START); // Border shrinking - p.getBorderManager().scheduleBorderReduction(); +// p.getBorderManager().scheduleBorderReduction(); // MOTD p.getMOTDManager().updateMOTDDuringGame(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java index 6f25beb..359c0e3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java @@ -118,7 +118,7 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) .forEach(entity -> freezeCreature((Creature) entity, true)); // Freezes the timers. - p.getTimerManager().pauseAllRunning(true); + // TODO p.getTimerManager().pauseAllRunning(true); } else @@ -136,7 +136,7 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) .forEach(entity -> freezeCreature((Creature) entity, false)); // Unfreezes the timers. - p.getTimerManager().pauseAllRunning(false); + // TODO p.getTimerManager().pauseAllRunning(false); } updateListenerRegistration(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java index 3e5f900..dcdcf3d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java @@ -33,12 +33,12 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.borders.MapShape; -import eu.carrade.amaury.UHCReloaded.old.borders.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.old.timers.UHTimer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; @@ -56,7 +56,7 @@ public class GameSidebar extends Sidebar { private final UHGameManager gameManager; - private final WorldBorder border; + private final WorldBorder border = null; private final boolean EPISODES_ENABLED; private final boolean EPISODES_IN_SIDEBAR; @@ -92,7 +92,7 @@ public class GameSidebar extends Sidebar public GameSidebar() { gameManager = UHCReloaded.get().getGameManager(); - border = UHCReloaded.get().getBorderManager().getBorderProxy(); + // border = UHCReloaded.get().getBorderManager().getBorderProxy(); EPISODES_ENABLED = UHConfig.EPISODES.ENABLED.get(); EPISODES_IN_SIDEBAR = UHConfig.SCOREBOARD.EPISODE.get(); @@ -116,7 +116,7 @@ public GameSidebar() BORDER_DISPLAY_DIAMETER = UHConfig.SCOREBOARD.BORDER.DISPLAY_DIAMETER.get(); - FROOZEN_NULL_TIMER_TEXT = new UHTimer("").toString(); + FROOZEN_NULL_TIMER_TEXT = new Timer("").toString(); setAsync(true); setAutoRefreshDelay(20); @@ -181,8 +181,8 @@ public void preRender() sidebarTimers.add(FROOZEN_NULL_TIMER_TEXT); else { - final UHTimer mainTimer = UHCReloaded.get().getTimerManager().getMainTimer(); - if (mainTimer != null) sidebarTimers.add(mainTimer.toString()); + //final Timer mainTimer = UHCReloaded.get().getTimerManager().getMainTimer(); + //if (mainTimer != null) sidebarTimers.add(mainTimer.toString()); } } } @@ -357,11 +357,11 @@ private void insertBorder(List<String> sidebar) */ private void insertTimers(List<String> sidebar) { - UHCReloaded.get().getTimerManager().getTimers().stream().filter(UHTimer::isDisplayed).forEach(timer -> { - sidebar.add(timer.getDisplayName()); - sidebar.add(timer.toString()); - sidebar.add(""); - }); +// UHCReloaded.get().getTimerManager().getTimers().stream().filter(Timer::isDisplayed).forEach(timer -> { +// sidebar.add(timer.getDisplayName()); +// sidebar.add(timer.toString()); +// sidebar.add(""); +// }); } /** diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b5d5558..bb43f46 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,8 +13,18 @@ # Available languages: en_US, fr_FR, pt_PT, pt_BR, cs_CZ, zh_CN. # Empty value: system language. -lang: - +lang: + +# The modules to load & enable. You can add modules provided by other plugins. +# Each module's configuration is in plugins/UHPlugin/modules/<modulename>.yml . +modules: + +# The worlds to use as main worlds. +# If not found, fallbacks on the first world found with the right type. +worlds: + overworld: world + nether: world_nether + the_end: world_the_end episodes: From 091c3e60a3cd15459c898a0248f911f8a9b450eb Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 22 Nov 2018 02:30:00 +0100 Subject: [PATCH 03/91] Continuous improvements on modules and border modules. - NEW: Finished border modules (split into four different modules) and commands. - OPT: Improved modules discovery from string, with better handling of modules in sub-packages. - NEW: Added toString method to TimeDelta (displaying mm:ss or hh:mm:ss). - NEW: Commands should be registerable anytime now, including when the game is started/ended. - NEW: Added a specific logger for each module. - NEW: Added shortcuts classes for better and easier development and module/logger access from non-main module class. - OPT: Improved /uh modules with colored dot for status and ordered modules by status/internal/name. - OPT: The log is more verbose. --- .../amaury/UHCReloaded/UHCReloaded.java | 80 ++++--- .../amaury/UHCReloaded/core/ModuleInfo.java | 2 +- .../amaury/UHCReloaded/core/ModuleLogger.java | 108 ++++++++++ .../UHCReloaded/core/ModuleWrapper.java | 23 +- .../amaury/UHCReloaded/core/UHModule.java | 12 ++ .../events}/AllModulesLoadedEvent.java | 2 +- .../events}/ModuleLoadedEvent.java | 10 +- .../events}/ModuleUnloadedEvent.java | 2 +- .../UHCReloaded/game/UHGameManager.java | 8 +- .../modules/border/check/CheckCommand.java | 63 ++++++ .../modules/border/check/CheckModule.java | 55 +++++ .../modules/border/walls/Config.java | 62 ++++++ .../modules/border/walls/WallsCommand.java | 89 ++++++++ .../modules/border/walls/WallsModule.java | 98 +++++++++ .../CannotGenerateWallsException.java | 2 +- .../exceptions/UnknownWallGenerator.java | 4 +- .../generators/CircularWallGenerator.java | 2 +- .../generators/SquaredWallGenerator.java | 2 +- .../walls}/generators/WallGenerator.java | 34 ++- .../walls}/generators/WallPosition.java | 2 +- .../warning}/BorderWarningTask.java | 21 +- .../modules/border/warning/Config.java | 51 +++++ .../border/warning/WarningCommand.java | 102 +++++++++ .../modules/border/warning/WarningModule.java | 198 ++++++++++++++++++ .../modules/core/border/BorderManager.java | 55 ----- .../modules/core/border/BorderModule.java | 182 ++-------------- .../modules/core/border/Config.java | 23 +- .../modules/core/border/MapShape.java | 60 +----- .../core/border/commands/BorderCommand.java | 179 ++++++++++++++++ .../border/events/BorderChangedEvent.java | 65 ++++++ .../worldborders/BrettflanWorldBorder.java | 6 + .../border/worldborders/FakeWorldBorder.java | 6 + .../worldborders/VanillaWorldBorder.java | 6 + .../core/border/worldborders/WorldBorder.java | 5 + .../modules/core/game/GameModule.java | 6 +- .../game/events/GamePhaseChangedEvent.java | 10 +- .../modules/core/modules/ModulesCommand.java | 37 +++- .../modules/core/timers/TimeDelta.java | 21 ++ .../old/commands/commands/UHRootCommand.java | 26 +-- .../commands/commands/uh/UHBorderCommand.java | 97 --------- .../commands/uh/UHGenerateWallsCommand.java | 143 ------------- .../commands/commands/uh/UHTeamCommand.java | 127 ----------- .../uh/border/UHBorderCheckCommand.java | 93 -------- .../uh/border/UHBorderGetCommand.java | 84 -------- .../uh/border/UHBorderSetCommand.java | 151 ------------- .../uh/border/UHBorderWarningCommand.java | 121 ----------- .../commands/uh/team/UHTeamAddCommand.java | 166 --------------- .../commands/uh/team/UHTeamBannerCommand.java | 111 ---------- .../uh/team/UHTeamBannerResetCommand.java | 110 ---------- .../commands/uh/team/UHTeamGUICommand.java | 82 -------- .../commands/uh/team/UHTeamJoinCommand.java | 185 ---------------- .../commands/uh/team/UHTeamLeaveCommand.java | 145 ------------- .../commands/uh/team/UHTeamListCommand.java | 122 ----------- .../commands/uh/team/UHTeamRemoveCommand.java | 121 ----------- .../commands/uh/team/UHTeamResetCommand.java | 95 --------- .../commands/uh/team/UHTeamSpyCommand.java | 125 ----------- .../{ => old}/events/EpisodeChangedCause.java | 2 +- .../events/UHEpisodeChangedEvent.java | 2 +- .../{ => old}/events/UHGameEndsEvent.java | 2 +- .../{ => old}/events/UHGameStartsEvent.java | 2 +- .../{ => old}/events/UHPlayerDeathEvent.java | 2 +- .../events/UHPlayerResurrectedEvent.java | 2 +- .../{ => old}/events/UHTeamDeathEvent.java | 2 +- .../old/listeners/BeforeGameListener.java | 2 +- .../old/listeners/GameListener.java | 14 +- .../scoreboard/ScoreboardListener.java | 4 +- .../amaury/UHCReloaded/shortcuts/UR.java | 86 ++++++++ .../UHCReloaded/utils/ModulesUtils.java | 21 +- src/main/resources/config.yml | 5 + 69 files changed, 1447 insertions(+), 2496 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/AllModulesLoadedEvent.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/ModuleLoadedEvent.java (89%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{events/modules => core/events}/ModuleUnloadedEvent.java (97%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/exceptions/CannotGenerateWallsException.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/exceptions/UnknownWallGenerator.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/CircularWallGenerator.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/SquaredWallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/WallGenerator.java (84%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/walls}/generators/WallPosition.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{core/border => border/warning}/BorderWarningTask.java (72%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/EpisodeChangedCause.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHEpisodeChangedEvent.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHGameEndsEvent.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHGameStartsEvent.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHPlayerDeathEvent.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHPlayerResurrectedEvent.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{ => old}/events/UHTeamDeathEvent.java (97%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index fdc7900..11a4b50 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -34,9 +34,9 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.events.modules.AllModulesLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; @@ -49,12 +49,7 @@ import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; -import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; -import eu.carrade.amaury.UHCReloaded.old.misc.MOTDManager; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.old.misc.PlayerListHeaderFooterManager; -import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager; -import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; +import eu.carrade.amaury.UHCReloaded.old.misc.*; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; import eu.carrade.amaury.UHCReloaded.old.spectators.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager; @@ -87,16 +82,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.function.BiConsumer; import java.util.stream.Collectors; @@ -123,7 +109,6 @@ public class UHCReloaded extends ZPlugin implements Listener private MOTDManager motdManager = null; private RulesManager rulesManager = null; private PlayerListHeaderFooterManager playerListHeaderFooterManager = null; - private BorderManager borderManager = null; private RecipesManager recipesManager = null; private TeamChatManager teamChatManager = null; @@ -222,7 +207,6 @@ private void onEnableWhenWorldsAvailable() worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get()); loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); - collectCommandsFromModules(); }); worldsLoaded = true; @@ -326,7 +310,7 @@ public void registerModule(final String module) private void registerModule(final String module, boolean enabledAtStartup) { final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( - module, + module.replace('-', '.'), "eu.carrade.amaury.UHCReloaded.modules", "Module", UHModule.class @@ -369,6 +353,8 @@ private void loadModules(final ModuleInfo.ModuleLoadTime loadTime) loadedPriorities.add(loadTime); + collectCommandsFromModules(); + getServer().getPluginManager().callEvent(new AllModulesLoadedEvent(loadTime)); } @@ -379,7 +365,7 @@ private void loadModules(final ModuleInfo.ModuleLoadTime loadTime) * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or * {@link #registerModule(String)} before. */ - public void loadModule(Class<? extends UHModule> moduleClass) + public void loadModule(final Class<? extends UHModule> moduleClass) { final ModuleWrapper module = modules.get(moduleClass); @@ -396,7 +382,7 @@ public void loadModule(Class<? extends UHModule> moduleClass) * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or * {@link #registerModule(String)} before. */ - public void unloadModule(Class<? extends UHModule> moduleClass) + public void unloadModule(final Class<? extends UHModule> moduleClass) { final ModuleWrapper module = modules.get(moduleClass); @@ -415,7 +401,7 @@ public void unloadModule(Class<? extends UHModule> moduleClass) * * @return The module's instance. */ - public static <M extends UHModule> M getModule(Class<M> moduleClass) + public static <M extends UHModule> M getModule(final Class<M> moduleClass) { final ModuleWrapper module = get().modules.get(moduleClass); @@ -458,7 +444,7 @@ public World getWorld(final World.Environment environment) @EventHandler (priority = EventPriority.LOWEST) - public final void onWorldsLoaded(WorldLoadEvent e) + public final void onWorldsLoaded(final WorldLoadEvent e) { if (!worldsLoaded) onEnableWhenWorldsAvailable(); } @@ -466,6 +452,8 @@ public final void onWorldsLoaded(WorldLoadEvent e) @EventHandler public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { + PluginLogger.info("Game phase changed to {0}.", ev.getNewPhase()); + switch (ev.getNewPhase()) { case IN_GAME: @@ -478,6 +466,12 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) } } + @EventHandler + public void onModuleLoaded(final ModuleLoadedEvent e) + { + PluginLogger.info("Module {0} loaded.", e.getModule().getName()); + } + @EventHandler (priority = EventPriority.LOWEST) public final void onPlayerJoin(final PlayerJoinEvent ev) { @@ -506,7 +500,7 @@ private void collectCommandsFromModules() // As they are not registered in the plugin.yml, for each command, we have to force-register // the name manually. - final List<org.bukkit.command.Command> pluginCommands = new ArrayList<>(); + final Map<org.bukkit.command.Command, Class<? extends Command>> pluginCommands = new HashMap<>(); final Set<String> registered = new HashSet<>(); try @@ -514,16 +508,16 @@ private void collectCommandsFromModules() final Constructor<PluginCommand> pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); pluginCommandConstructor.setAccessible(true); - for (final String commandName : commandAliases.keySet()) + for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) { try { - pluginCommands.add(pluginCommandConstructor.newInstance(commandName, this)); - registered.add(commandName); + pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), this), commandAlias.getValue()); + registered.add(commandAlias.getKey()); } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { - PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandName); + PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandAlias); } } @@ -531,10 +525,22 @@ private void collectCommandsFromModules() { final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); - String prefix = getDescription().getPrefix(); - if (prefix == null) prefix = getDescription().getName().toLowerCase(); + String mutPrefix = getDescription().getPrefix(); + if (mutPrefix == null) mutPrefix = getDescription().getName().toLowerCase(); + + final String prefix = mutPrefix; - commandMap.registerAll(prefix, pluginCommands); + pluginCommands.forEach((pluginCommand, commandClass) -> + { + if (commandMap.register(prefix, pluginCommand)) + { + PluginLogger.info( + "Hot-registered new command /{0} for class “{1}”.", + pluginCommand.getName(), + commandClass.getName().replace("eu.carrade.amaury.UHCReloaded.", "...") + ); + } + }); } catch (NoSuchFieldException | IllegalAccessException e) { @@ -634,14 +640,6 @@ public PlayerListHeaderFooterManager getPlayerListHeaderFooterManager() return playerListHeaderFooterManager; } - /** - * Returns the border manager. - */ - public BorderManager getBorderManager() - { - return borderManager; - } - /** * Returns the recipe manager. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index 0972341..4797487 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -95,7 +95,7 @@ enum ModuleLoadTime /** * Loads the module at startup, before the worlds are loaded. * - * Please note that most core modules (an localization) are not loaded at this point. Use that + * Please note that most core modules (and localization) are not loaded at this point. Use that * for modules altering the world generation. */ STARTUP, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java new file mode 100644 index 0000000..7d5c3c6 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -0,0 +1,108 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import fr.zcraft.zlib.core.ZLib; + +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class ModuleLogger extends Logger +{ + private final String loggerName; + + ModuleLogger(Class<?extends UHModule> module) + { + super(ZLib.getPlugin().getClass().getCanonicalName(), null); + + setParent(ZLib.getPlugin().getLogger()); + setLevel(Level.ALL); + + loggerName = "[" + ZLib.getPlugin().getName() + "] [" + ModuleWrapper.computeModuleName(module) + " Module] "; + } + + @Override + public void log(LogRecord logRecord) + { + logRecord.setMessage(loggerName + logRecord.getMessage()); + super.log(logRecord); + } + + public void log(Level level, String message, Throwable ex, Object... args) + { + log(level, message, args); + log(level, "Exception : ", ex); + } + + public void info(String message, Object...args) + { + log(Level.INFO, message, args); + } + + public void warning(String message, Object... args) + { + log(Level.WARNING, message, args); + } + + public void warning(String message, Throwable ex) + { + log(Level.WARNING, message, ex); + } + + public void warning(String message, Throwable ex, Object... args) + { + log(Level.WARNING, message, ex, args); + } + + public void error(String message) + { + log(Level.SEVERE, message); + } + + public void error(String message, Throwable ex) + { + log(Level.SEVERE, message, ex); + } + + public void error(String message, Throwable ex, Object... args) + { + log(Level.SEVERE, message, ex, args); + } + + public void error(String message, Object... args) + { + log(Level.SEVERE, message, args); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 239c1fc..243d766 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -32,8 +32,8 @@ package eu.carrade.amaury.UHCReloaded.core; import com.google.common.base.CaseFormat; -import eu.carrade.amaury.UHCReloaded.events.modules.ModuleLoadedEvent; -import eu.carrade.amaury.UHCReloaded.events.modules.ModuleUnloadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.PluginLogger; @@ -73,7 +73,7 @@ public ModuleWrapper( final Class<? extends ConfigurationInstance> moduleConfiguration, final String settingsFileName) { - this.name = name; + this.name = computeModuleName(moduleClass); this.description = description; this.internal = internal; this.enabledAtStartup = enabledAtStartup; @@ -91,7 +91,8 @@ public ModuleWrapper( public void enable() { instance = ZLib.loadComponent(moduleClass); - Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(instance)); + + Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this)); } /** @@ -127,9 +128,7 @@ public void setEnabledAtStartup(boolean enabledAtStartup) */ public String getName() { - return name != null && !name.isEmpty() - ? name - : StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); + return name; } /** @@ -240,4 +239,14 @@ public UHModule get() { return instance; } + + static String computeModuleName(Class<? extends UHModule> moduleClass) + { + final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); + + if (info == null || info.name().isEmpty()) + return StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); + + else return info.name(); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java index 35f45b0..64e94e4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java @@ -44,6 +44,13 @@ public abstract class UHModule extends ZLibComponent implements Listener { + protected ModuleLogger logger; + + public UHModule() + { + logger = new ModuleLogger(getClass()); + } + /** * Called when the configuration is loaded. */ @@ -81,4 +88,9 @@ public void prepareInjectionIntoSidebar() {} * @param injector The injector will allows you to inject content in specific parts of the sidebar. */ public void injectIntoSidebar(final Player player, final SidebarInjector injector) {} + + public ModuleLogger log() + { + return logger; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java index 33b0136..e4ebb7f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/AllModulesLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events.modules; +package eu.carrade.amaury.UHCReloaded.core.events; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java index 5d460ba..5180f8d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events.modules; +package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -43,10 +43,10 @@ public class ModuleLoadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final UHModule module; + private final ModuleWrapper module; - public ModuleLoadedEvent(final UHModule module) + public ModuleLoadedEvent(final ModuleWrapper module) { this.module = module; } @@ -54,7 +54,7 @@ public ModuleLoadedEvent(final UHModule module) /** * @return the loaded module. */ - public UHModule getModule() + public ModuleWrapper getModule() { return module; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java index 9c59e73..51f8b22 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/modules/ModuleUnloadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events.modules; +package eu.carrade.amaury.UHCReloaded.core.events; import eu.carrade.amaury.UHCReloaded.core.UHModule; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index 201434c..f26d263 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -33,10 +33,10 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.events.EpisodeChangedCause; -import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; +import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java new file mode 100644 index 0000000..d7d697f --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java @@ -0,0 +1,63 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.check; + +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; + +@CommandInfo(name = "border-check", usageParameters = "<radius>", aliases = {"bordercheck", "bcheck", "bc"}) +public class CheckCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length == 0) + { + throwInvalidArgument(I.t("You must provide a check radius.")); + } + + try + { + UR.module(BorderModule.class).sendCheckMessage(sender, Integer.valueOf(args[0])); + } + catch (NumberFormatException e) + { + sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java new file mode 100644 index 0000000..7630216 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java @@ -0,0 +1,55 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.check; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.commands.Command; + +import java.util.Collections; +import java.util.List; + +@ModuleInfo ( + name = "Border Check", + description = "Offers a command to check how far players are from a given border size.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START +) +public class CheckModule extends UHModule +{ + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(CheckCommand.class); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java new file mode 100644 index 0000000..64542e2 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java @@ -0,0 +1,62 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.walls; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import org.bukkit.Material; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Integer> HEIGHT = item("height", 128); + + public static final BlockSection BLOCK = section("block", BlockSection.class); + + static public class BlockSection extends ConfigurationSection + { + public final ConfigurationItem<Material> REPLACE_AIR = item("replaceAir", Material.GLASS); + public final ConfigurationItem<Material> REPLACE_SOLID = item("replaceSolid", Material.BEDROCK); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java new file mode 100644 index 0000000..23a7a7b --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java @@ -0,0 +1,89 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.walls; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.World; +import org.bukkit.command.BlockCommandSender; +import org.bukkit.entity.Player; + +@CommandInfo(name = "build-walls", aliases = {"buildwalls", "generate-walls", "generatewalls"}) +public class WallsCommand extends Command +{ + @Override + protected void run() throws CommandException + { + info(I.t("{cst}Generating the walls...")); + + final World world; + + if (sender instanceof Player) + { + world = ((Player) sender).getWorld(); + } + else if (sender instanceof BlockCommandSender) + { + world = ((BlockCommandSender) sender).getBlock().getWorld(); + } + else + { + world = UHCReloaded.get().getWorld(World.Environment.NORMAL); + info(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName())); + } + + try + { + UHCReloaded.getModule(WallsModule.class).generateWalls(world); + } + catch (CannotGenerateWallsException e) + { + error(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); + return; + + } + catch (Exception e) + { + error(I.t("{ce}An error occurred, see console for details.")); + e.printStackTrace(); + return; + } + + success(I.t("{cst}Generation done.")); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java new file mode 100644 index 0000000..11d5351 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java @@ -0,0 +1,98 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.walls; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.UnknownWallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.border.walls.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Material; +import org.bukkit.World; + +import java.util.Collections; +import java.util.List; + + +@ModuleInfo ( + name = "Walls generator", + description = "Generates a solid wall around the arena", + when = ModuleInfo.ModuleLoadTime.POST_WORLD, + settings = Config.class +) +public class WallsModule extends UHModule +{ + private BorderModule borderModule; + + @Override + protected void onEnable() + { + borderModule = UHCReloaded.getModule(BorderModule.class); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(WallsCommand.class); + } + + /** + * Generates the walls in the given world, following the current border configuration. + * + * @param world The world were the walls will be built in. + * @throws CannotGenerateWallsException If an error occurred while generating the wall. + */ + public void generateWalls(final World world) throws CannotGenerateWallsException + { + final Integer wallHeight = Config.HEIGHT.get(); + + final Material wallBlockAir = Config.BLOCK.REPLACE_AIR.get(); + final Material wallBlockSolid = Config.BLOCK.REPLACE_SOLID.get(); + + if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid()) + { + throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config"); + } + + final WallGenerator generator = WallGenerator.fromShape(borderModule.getMapShape(), wallBlockAir, wallBlockSolid); + + if (generator != null) + generator.build(world, borderModule.getCurrentBorderDiameter(), wallHeight); + else + throw new UnknownWallGenerator("Unable to load walls generator."); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java index 5cbb9c4..c47db3a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions; public class CannotGenerateWallsException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java index 68829ce..fa31faf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions; -public class UnknownWallGenerator extends Exception +public class UnknownWallGenerator extends CannotGenerateWallsException { public UnknownWallGenerator(String message) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java index 51e8164..e6158f6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java index 7239677..6a54e7d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java index bc8a868..225a21b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java @@ -30,8 +30,10 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import org.apache.commons.lang3.Validate; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -46,8 +48,8 @@ public abstract class WallGenerator public WallGenerator(Material wallBlockAir, Material wallBlockSolid) { - this.wallBlockAir = wallBlockAir; - this.wallBlockSolid = wallBlockSolid; + this.wallBlockAir = wallBlockAir != null ? wallBlockAir : Material.GLASS; + this.wallBlockSolid = wallBlockSolid != null ? wallBlockSolid : Material.BEDROCK; } @@ -186,4 +188,30 @@ public int getBlocksSet() { return blocksSet; } + + /** + * Returns a new instance of the wall generator for the given shape. + * + * @param shape The shape. + * @param wallBlockAir The block to use to replace air. + * @param wallBlockSolid The block to use to replace solid blocks. + * + * @return The instance. + * @see WallGenerator#WallGenerator(Material, Material) + */ + public static WallGenerator fromShape(final MapShape shape, final Material wallBlockAir, final Material wallBlockSolid) + { + Validate.notNull(shape, "Map shape must not be null."); + + switch (shape) + { + case CIRCULAR: + return new CircularWallGenerator(wallBlockAir, wallBlockSolid); + + case SQUARED: + return new SquaredWallGenerator(wallBlockAir, wallBlockSolid); + } + + return null; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java index 426d731..873b7b9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.generators; +package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; /** * Used to determine in witch wall we are, to get the "inner" block. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java similarity index 72% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java index 755eb47..be7d87a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java @@ -29,9 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border; +package eu.carrade.amaury.UHCReloaded.modules.border.warning; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -39,29 +41,30 @@ public class BorderWarningTask extends BukkitRunnable { - private final BorderModule module = UHCReloaded.getModule(BorderModule.class); + private final BorderModule borderModule = UR.module(BorderModule.class); + private final WarningModule warningModule = UR.module(WarningModule.class); @Override public void run() { -// final FreezerModule freezer = UHCReloaded.getModule(FreezerModule.class); +// final FreezerModule freezer = UR.module(FreezerModule.class); // if (freezer != null && freezer.getGlobalFreezeState()) // { // return; // No messages are sent if the game is frozen. // } // Message sent to all players outside the border - for (Player player : module.getPlayersOutside(module.getWarningSize())) + for (Player player : borderModule.getPlayersOutside(warningModule.getWarningSize())) { - double distance = module.getDistanceToBorder(player.getLocation(), module.getWarningSize()); + double distance = borderModule.getDistanceToBorder(player.getLocation(), warningModule.getWarningSize()); - if (module.getMapShape() == MapShape.CIRCULAR) + if (borderModule.getMapShape() == MapShape.CIRCULAR) { - player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", module.getWarningSize())); + player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", warningModule.getWarningSize())); } else { - player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", module.getWarningSize())); + player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", warningModule.getWarningSize())); } player.sendMessage(I.tn("{ci}You have {0} block to go before being inside.", "{ci}You have {0} blocks to go before being inside.", (int) distance)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java new file mode 100644 index 0000000..c88b807 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java @@ -0,0 +1,51 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.warning; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Integer> WARNING_INTERVAL = item("warningInterval", 90); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java new file mode 100644 index 0000000..2b08ba5 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java @@ -0,0 +1,102 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.warning; + +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; + +import java.util.List; + +@CommandInfo ( + name = "border-warning", + usageParameters = "<future border size | cancel> [time delta (minutes or mm:ss or hh:mm:ss) until border reduction]", + aliases = {"borderwarning", "borderwarn", "bw"} +) +public class WarningCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final WarningModule warnings = UR.module(WarningModule.class); + + // /uh border warning + if (args.length == 0) + { + throwInvalidArgument(I.t("Missing future border size.")); + } + + // /uh border warning cancel + else if (args[0].equalsIgnoreCase("cancel")) + { + warnings.cancelWarning(); + success(I.t("{cs}Warning canceled.")); + } + + // /uh border warning <?> + // or + // /uh border warning <?> <?> + else + { + try + { + final int warnDiameter = Integer.parseInt(args[0]); + TimeDelta warnTime = null; + + // /uh border warning <?> <?> + if (args.length >= 2) + { + warnTime = new TimeDelta(args[1]); + } + + warnings.setWarningSize(warnDiameter, warnTime, sender); + success(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", Config.WARNING_INTERVAL.get())); + + } + catch (NumberFormatException e) + { + error(I.t("{ce}“{0}” is not a number...", args[0])); + } + } + } + + @Override + protected List<String> complete() throws CommandException + { + return args.length == 1 ? getMatchingSubset(args[0], "cancel") : null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java new file mode 100644 index 0000000..7b6d60c --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java @@ -0,0 +1,198 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.border.warning; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.command.CommandSender; +import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.Collections; +import java.util.List; + +@ModuleInfo ( + name = "Border Warning", + description = "Warns players about the future border size", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class WarningModule extends UHModule +{ + private BorderModule borderModule; + + private Integer warningSize = 0; + private BukkitRunnable warningTask = null; + + private Boolean warningFinalTimeEnabled = false; + private Timer warningTimer = null; + private String warningTimerName = null; + private CommandSender warningSender = null; + + + @Override + protected void onEnable() + { + /// The name of the warning timer displaying the time left before the next border + warningTimerName = I.t("Border shrinking"); + + borderModule = UR.module(BorderModule.class); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(WarningCommand.class); + } + + /** + * Returns the size of the future border, used in the warning messages sent to the + * players out of this future border. + * + * @return the future border diameter. + */ + public int getWarningSize() + { + return this.warningSize; + } + + /** + * @return true if there is currently a warning with a time left displayed. + */ + public boolean getWarningFinalTimeEnabled() + { + return this.warningFinalTimeEnabled; + } + + /** + * @return the sender of the last warning configured. + */ + public CommandSender getWarningSender() + { + return this.warningSender; + } + + /** + * Sets the size of the future border, used in the warning messages sent to the + * players out of this future border. + * + * This also starts the display of the warning messages, every 90 seconds by default + * (configurable, see config.yml, map.border.warningInterval). + * + * If timeLeft is not null, the time available for the players to go inside the future + * border is displayed in the warning message. + * + * @param diameter The future diameter. + * @param timeLeft The time available for the players to go inside the future border. + * @param sender The user who requested this change. + */ + public void setWarningSize(final int diameter, final TimeDelta timeLeft, final CommandSender sender) + { + cancelWarning(); + + this.warningSize = diameter; + + if (timeLeft != null) + { + warningTimer = new Timer(this.warningTimerName); + warningTimer.setDuration((int) timeLeft.getSeconds()); + + UR.module(TimersModule.class).registerTimer(warningTimer); + + warningTimer.start(); + } + + if (sender != null) + { + this.warningSender = sender; + } + + RunTask.timer( + warningTask = new BorderWarningTask(), + 20L, + 20L * Config.WARNING_INTERVAL.get() + ); + } + + /** + * Sets the size of the future border, used in the warning messages sent to the + * players out of this future border. + * + * This also starts the display of the warning messages, every 90 seconds by default + * (configurable, see config.yml, map.border.warningInterval). + * + * @param diameter The diameter of the future border. + */ + public void setWarningSize(final int diameter) + { + setWarningSize(diameter, null, null); + } + + /** + * Stops the display of the warning messages. + */ + public void cancelWarning() + { + if (warningTask != null) + { + try + { + warningTask.cancel(); + } + catch (IllegalStateException ignored) {} + } + + if (warningTimer != null) + { + warningTimer.stop(); + UR.module(TimersModule.class).unregisterTimer(warningTimer); + } + } + + + @EventHandler + public void onBorderChanged(final BorderChangedEvent ev) + { + cancelWarning(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java deleted file mode 100644 index 1c7e8da..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.modules.core.border; - -import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import org.bukkit.command.CommandSender; -import org.bukkit.scheduler.BukkitRunnable; - - -public class BorderManager -{ - private WorldBorder border = null; - - private Integer warningSize = 0; - private BukkitRunnable warningTask = null; - - private Boolean warningFinalTimeEnabled = false; - private String warningTimerName = null; - private CommandSender warningSender = null; - - private MapShape mapShape = null; - - - -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 72ae9f8..2058df9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -35,22 +35,21 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.core.border.commands.BorderCommand; +import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; +import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; @@ -63,24 +62,12 @@ ) public class BorderModule extends UHModule { - private WorldBorder border = null; - - private Integer warningSize = 0; - private BukkitRunnable warningTask = null; - - private Boolean warningFinalTimeEnabled = false; - private Timer warningTimer = null; - private String warningTimerName = null; - private CommandSender warningSender = null; - private MapShape mapShape = null; + private WorldBorder border = null; @Override public void onEnable() { - /// The name of the warning timer displaying the time left before the next border - warningTimerName = I.t("Border shrinking"); - mapShape = Config.SHAPE.get(); final World world = UHCReloaded.get().getWorld(World.Environment.NORMAL); @@ -93,10 +80,13 @@ public void onEnable() border.init(); - PluginLogger.info("Using {0} to set the world border.", border.getClass().getSimpleName()); + log().info("Using {0} to set the world border.", border.getClass().getSimpleName()); + } -// BORDER_SHRINKING_STARTS_AFTER = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.STARTS_AFTER.get(), 30*60); // Seconds -// BORDER_SHRINKING_DURATION = UHUtils.string2Time(UHConfig.MAP.BORDER.SHRINKING.SHRINKS_DURING.get(), 60*60*2); // Same + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(BorderCommand.class); } /** @@ -182,7 +172,7 @@ public Set<Player> getPlayersOutside(int diameter) final Set<Player> playersOutside = new HashSet<>(); // TODO -// for (final Player player : UHCReloaded.getModule(GameModule.class).getOnlineAlivePlayers()) +// for (final Player player : UR.module(GameModule.class).getOnlineAlivePlayers()) // { // if (!isInsideBorder(player.getLocation(), diameter)) // { @@ -193,110 +183,6 @@ public Set<Player> getPlayersOutside(int diameter) return playersOutside; } - /** - * Returns the size of the future border, used in the warning messages sent to the - * players out of this future border. - * - * @return the future border diameter. - */ - public int getWarningSize() - { - return this.warningSize; - } - - /** - * @return true if there is currently a warning with a time left displayed. - */ - public boolean getWarningFinalTimeEnabled() - { - return this.warningFinalTimeEnabled; - } - - /** - * @return the sender of the last warning configured. - */ - public CommandSender getWarningSender() - { - return this.warningSender; - } - - /** - * Sets the size of the future border, used in the warning messages sent to the - * players out of this future border. - * - * This also starts the display of the warning messages, every 90 seconds by default - * (configurable, see config.yml, map.border.warningInterval). - * - * If timeLeft is not null, the time available for the players to go inside the future - * border is displayed in the warning message. - * - * @param diameter The future diameter. - * @param timeLeft The time available for the players to go inside the future border (minutes). - * @param sender The user who requested this change. - */ - public void setWarningSize(int diameter, int timeLeft, CommandSender sender) - { - cancelWarning(); - - this.warningSize = diameter; - - if (timeLeft != 0) - { - warningTimer = new Timer(this.warningTimerName); - warningTimer.setDuration(timeLeft * 60); - - UHCReloaded.getModule(TimersModule.class).registerTimer(warningTimer); - - warningTimer.start(); - } - - if (sender != null) - { - this.warningSender = sender; - } - - RunTask.timer( - warningTask = new BorderWarningTask(), - 20L, - 20L * Config.WARNING_INTERVAL.get() - ); - } - - /** - * Sets the size of the future border, used in the warning messages sent to the - * players out of this future border. - * - * This also starts the display of the warning messages, every 90 seconds by default - * (configurable, see config.yml, map.border.warningInterval). - * - * @param diameter The diameter of the future border. - */ - public void setWarningSize(int diameter) - { - setWarningSize(diameter, 0, null); - } - - /** - * Stops the display of the warning messages. - */ - public void cancelWarning() - { - if (warningTask != null) - { - try - { - warningTask.cancel(); - } - catch (IllegalStateException ignored) {} - } - - if (warningTimer != null) - { - warningTimer.stop(); - UHCReloaded.getModule(TimersModule.class).unregisterTimer(warningTimer); - } - } - /** * @return the current border diameter. */ @@ -316,21 +202,20 @@ public int getCurrentBorderDiameter() */ public void setCurrentBorderDiameter(int diameter) { - cancelWarning(); - border.setDiameter(diameter); + Bukkit.getPluginManager().callEvent(new BorderChangedEvent(diameter)); } - /** * Sends a list of the players outside the given border to the specified sender. * * @param to The player/console to send the check. * @param diameter The diameter of the border to be checked. */ - public void sendCheckMessage(CommandSender to, int diameter) + public void sendCheckMessage(final CommandSender to, final int diameter) { - Set<Player> playersOutside = getPlayersOutside(diameter); + final BorderModule borderModule = UR.module(BorderModule.class); + final Set<Player> playersOutside = borderModule.getPlayersOutside(diameter); if (playersOutside.size() == 0) { @@ -339,9 +224,9 @@ public void sendCheckMessage(CommandSender to, int diameter) else { to.sendMessage(I.t("{ci}There are {0} players outside the given border.", String.valueOf(playersOutside.size()))); - for (Player player : getPlayersOutside(diameter)) + for (Player player : borderModule.getPlayersOutside(diameter)) { - double distance = getDistanceToBorder(player.getLocation(), diameter); + double distance = borderModule.getDistanceToBorder(player.getLocation(), diameter); if (distance > 150) { to.sendMessage(I.t("{lightpurple} - {red}{0}{ci} (far away from the border)", player.getName())); @@ -358,31 +243,6 @@ else if (distance > 25) } } - /** - * Generates the walls in the given world, following the current border configuration. - * - * @param world The world were the walls will be built in. - * @throws CannotGenerateWallsException If an error occurred while generating the wall. - */ - public void generateWalls(World world) throws CannotGenerateWallsException - { - Integer wallHeight = Config.WALL.HEIGHT.get(); - - Material wallBlockAir = Config.WALL.BLOCK.REPLACE_AIR.get(); - Material wallBlockSolid = Config.WALL.BLOCK.REPLACE_SOLID.get(); - - if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid()) - { - throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config"); - } - - final WallGenerator generator = mapShape.getWallGeneratorInstance(wallBlockAir, wallBlockSolid); - if (generator != null) - generator.build(world, getCurrentBorderDiameter(), wallHeight); - else - throw new CannotGenerateWallsException("Unable to load walls generator."); - } - /** * Schedules the automatic border reduction, if enabled in the configuration. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java index f4f528e..c15d00f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java @@ -32,10 +32,10 @@ package eu.carrade.amaury.UHCReloaded.modules.core.border; import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; import fr.zcraft.zlib.components.configuration.ConfigurationSection; -import org.bukkit.Material; import java.io.File; @@ -63,25 +63,8 @@ public Config(File file) static public class ShrinkingSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<String> STARTS_AFTER = item("startsAfter", "30:00"); - public final ConfigurationItem<String> SHRINKS_DURING = item("shrinksDuring", "2:00:00"); + public final ConfigurationItem<TimeDelta> STARTS_AFTER = item("startsAfter", new TimeDelta(0, 30, 0)); + public final ConfigurationItem<TimeDelta> SHRINKS_DURING = item("shrinksDuring", new TimeDelta(2, 0, 0)); public final ConfigurationItem<Integer> DIAMETER_AFTER_SHRINK = item("diameterAfterShrink", 200); } - - public static final ConfigurationItem<Integer> WARNING_INTERVAL = item("warningInterval", 90); - - public static final WallSection WALL = section("wall", WallSection.class); - - static public class WallSection extends ConfigurationSection - { - public final ConfigurationItem<Integer> HEIGHT = item("height", 128); - - public final BlockSection BLOCK = section("block", BlockSection.class); - - static public class BlockSection extends ConfigurationSection - { - public final ConfigurationItem<Material> REPLACE_AIR = item("replaceAir", Material.GLASS); - public final ConfigurationItem<Material> REPLACE_SOLID = item("replaceSolid", Material.BEDROCK); - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java index a2e2438..362a2af 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java @@ -31,55 +31,27 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.border; -import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.CircularWallGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.SquaredWallGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.border.generators.WallGenerator; import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.CircularMapShape; import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.MapShapeDescriptor; import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.SquaredMapShape; -import fr.zcraft.zlib.tools.PluginLogger; -import org.bukkit.Material; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; public enum MapShape { - CIRCULAR(new CircularMapShape(), CircularWallGenerator.class), - SQUARED(new SquaredMapShape(), SquaredWallGenerator.class); + CIRCULAR(new CircularMapShape()), + SQUARED(new SquaredMapShape()), + + ; private MapShapeDescriptor shape; - private Class<? extends WallGenerator> generatorClass; /** - * @param generator The wall generator class associated with this shape. + * @param shape The shape descriptor to use for border-checks. */ - MapShape(MapShapeDescriptor shape, Class<? extends WallGenerator> generator) + MapShape(MapShapeDescriptor shape) { this.shape = shape; - this.generatorClass = generator; - } - - /** - * Returns a new instance of the wall generator for this shape. - * - * @return The instance. - */ - public WallGenerator getWallGeneratorInstance(Material wallBlockAir, Material wallBlockSolid) - { - try - { - Constructor constructor = generatorClass.getConstructor(Material.class, Material.class); - return (WallGenerator) constructor.newInstance(wallBlockAir, wallBlockSolid); - - } - catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) - { - PluginLogger.error("Cannot instantiate the walls generator: invalid class.", e); - return null; - } } /** @@ -91,24 +63,4 @@ public MapShapeDescriptor getShape() { return shape; } - - /** - * Returns a shape based on his name. - * - * <p>Not case sensitive.</p> - * - * @param name The name. - * @return The MapShape, or {@code null} if not found. - */ - public static MapShape fromString(String name) - { - try - { - return MapShape.valueOf(name.trim().toUpperCase()); - } - catch (IllegalArgumentException e) - { - return null; - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java new file mode 100644 index 0000000..27d50d2 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java @@ -0,0 +1,179 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.border.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; + + +@CommandInfo (name = "border", usageParameters = "[new diameter] [duration]", aliases = "b") +public class BorderCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final BorderModule border = UR.module(BorderModule.class); + + // No arguments: displays current size + if (args.length == 0) + { + if (border.getMapShape() == MapShape.CIRCULAR) + { + sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", border.getCurrentBorderDiameter())); + } + else + { + sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", border.getCurrentBorderDiameter())); + } + } + + else + { + // /uh border <radius> + if (args.length == 1) + { + try + { + final int newDiameter = Integer.valueOf(args[0]); + + // Some players are outside + if (border.getPlayersOutside(newDiameter).size() != 0) + { + sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); + sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); + +// TODO WorldBorder plugin +// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled()) +// { +// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); +// } + + border.sendCheckMessage(sender, newDiameter); + } + else + { + border.setCurrentBorderDiameter(newDiameter); + + if (border.getMapShape() == MapShape.CIRCULAR) + { + Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); + } + else + { + Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); + } + } + } + catch (NumberFormatException e) + { + error(I.t("{ce}“{0}” is not a number...", args[0])); + } + } + + // /uh border <radius> force + else if (args.length == 2 && args[1].equalsIgnoreCase("force")) + { + try + { + final Integer newDiameter = Integer.valueOf(args[0]); + + border.setCurrentBorderDiameter(newDiameter); + + if (border.getMapShape() == MapShape.CIRCULAR) + { + Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); + } + else + { + Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); + } + } + catch (NumberFormatException e) + { + error(I.t("{ce}“{0}” is not a number...", args[0])); + } + } + + // /uh border <radius> <duration> + else if (args.length == 2) + { + if (!border.getBorderProxy().supportsProgressiveResize()) + { + error(I.t("The border motor ({0}) does not supports progressive resizes.", border.getBorderProxy().getClass().getSimpleName())); + } + + final Integer newDiameter; + final TimeDelta delta; + + try + { + newDiameter = Integer.valueOf(args[0]); + } + catch (NumberFormatException e) + { + error(I.t("{ce}“{0}” is not a number...", args[0])); + return; + } + + try + { + delta = new TimeDelta(args[1]); + } + catch (IllegalArgumentException e) + { + error(I.t("{ce}“{0}” is not a valid time delta... Accepted formats are mm, mm:ss or hh:mm:ss.", args[1])); + return; + } + + border.getBorderProxy().setDiameter(newDiameter, delta.getSeconds() * 20L); + + if (border.getMapShape() == MapShape.CIRCULAR) + { + Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map will be set to {0} block over {1}.", "{lightpurple}The diameter of the map will be set to {0} blocks over {1}.", newDiameter, newDiameter, delta)); + } + else + { + Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map will be set to {0}×{0} over {1}.", newDiameter, delta)); + } + } + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java new file mode 100644 index 0000000..67bb055 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java @@ -0,0 +1,65 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.border.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class BorderChangedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final int newDiameter; + + public BorderChangedEvent(final int newDiameter) + { + this.newDiameter = newDiameter; + } + + public int getNewDiameter() + { + return newDiameter; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java index b03c467..e5e3a0c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -222,4 +222,10 @@ public void setShape(MapShape shape) { border.setShape(shape == MapShape.CIRCULAR); } + + @Override + public boolean supportsProgressiveResize() + { + return true; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java index 6818f56..e90fcdf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java @@ -133,4 +133,10 @@ public void setShape(MapShape shape) { this.shape = shape; } + + @Override + public boolean supportsProgressiveResize() + { + return false; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java index c3ed1cf..d084305 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java @@ -163,4 +163,10 @@ public MapShape getShape() @Override public void setShape(MapShape shape) {} + + @Override + public boolean supportsProgressiveResize() + { + return true; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java index 7ce4b3b..787ad81 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java @@ -145,6 +145,11 @@ public void init() {} */ public abstract void setShape(MapShape shape); + /** + * @return {@code true} if this border supports progressive resizes using {@link #setDiameter(double, long)}. + */ + public abstract boolean supportsProgressiveResize(); + /** * Returns a new instance of a WorldBorder proxy using the requested types. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 28320de..9835b86 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -58,7 +58,7 @@ ) public class GameModule extends UHModule implements Listener { - private GamePhase phase = GamePhase.WAIT; + private GamePhase phase = null; private final Set<UUID> players = new HashSet<>(); private final Set<UUID> spectators = new HashSet<>(); @@ -66,7 +66,7 @@ public class GameModule extends UHModule implements Listener @Override protected void onEnable() { - + setPhase(GamePhase.WAIT); } @Override @@ -99,7 +99,7 @@ public GamePhase getPhase() */ public void setPhase(GamePhase phase) { - if (this.phase != phase && phase.ordinal() > this.phase.ordinal()) + if (this.phase == null || (this.phase != phase && phase.ordinal() > this.phase.ordinal())) { final GamePhase oldPhase = this.phase; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java index c2392cf..f30ea0d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java @@ -37,7 +37,7 @@ /** - * Fired after a module was loaded. + * Fired when the game phase changes. */ public class GamePhaseChangedEvent extends Event { @@ -52,11 +52,19 @@ public GamePhaseChangedEvent(final GamePhase oldPhase, final GamePhase newPhase) this.newPhase = newPhase; } + /** + * The old phase. May be {@code null} if this is the first phase ever (i.e. {@link GamePhase#WAIT}). + * + * @return The old phase. + */ public GamePhase getOldPhase() { return oldPhase; } + /** + * @return The new phase. + */ public GamePhase getNewPhase() { return newPhase; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java index db67d31..2786599 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -38,7 +38,8 @@ import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; -import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; @CommandInfo (name = "modules", usageParameters = "[list|enable|disable]", aliases = {"module"}) @@ -47,9 +48,39 @@ public class ModulesCommand extends Command @Override protected void run() throws CommandException { - final Collection<ModuleWrapper> modules = UHCReloaded.get().getModules(); + final Set<ModuleWrapper> modules = new TreeSet<>((module1, module2) -> { + if (module1.equals(module2)) return 0; + + if (module1.isEnabled() != module2.isEnabled()) return module1.isEnabled() ? -1 : 1; + + if (module1.getWhen() != module2.getWhen()) + return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal()); + + if (module1.isInternal() != module2.isInternal()) return module1.isInternal() ? -1 : 1; + + return module1.getName().compareTo(module2.getName()); + }); + + modules.addAll(UHCReloaded.get().getModules()); success(I.tn("{0} module registered", "{0} modules registered", modules.size())); - modules.forEach(module -> info(I.t("- {0} ({1} - {2})", module.getName(), module.isEnabled() ? "enabled" : "disabled", module.getWhen()))); + modules.forEach(module -> { + if (module.isEnabled()) + { + info(I.t( + "{green} • {white}{0} (enabled - {1})", + module.getName(), + module.getWhen() + )); + } + else + { + info(I.t( + "{red} • {white}{0} (disabled - {1})", + module.getName(), + module.getWhen() + )); + } + }); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java index 186eb04..06beaa2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java @@ -35,11 +35,15 @@ import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.Objects; public class TimeDelta { + private static final NumberFormat formatter = new DecimalFormat("00"); + private final long seconds; static @@ -113,6 +117,23 @@ public long getSeconds() return seconds; } + @Override + public String toString() + { + final long secondsLeft = seconds % 60; + final long minutesLeft = (seconds % 3600) / 60; + final long hoursLeft = (long) Math.floor(seconds / 3600.0); + + if (hoursLeft != 0) + { + return formatter.format(hoursLeft) + ":" + formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft); + } + else + { + return formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft); + } + } + @Override public boolean equals(Object o) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 03d7f6e..7dce0ce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -32,28 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHAboutCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHBorderCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedAllCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFeedCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFinishCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHFreezeCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHGenerateWallsCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealAllCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHHealCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHInfosCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHKillCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHLoadPlayersCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHResurrectCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHRulesCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHShiftCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpawnsCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHSpectatorsCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHStartCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPBackCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTPSpawnCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.UHTeamCommand; +import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.*; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; @@ -75,10 +54,7 @@ public UHRootCommand(UHCReloaded plugin) registerSubCommand(new UHStartCommand(p)); registerSubCommand(new UHShiftCommand(p)); registerSubCommand(new UHSpawnsCommand(p)); - registerSubCommand(new UHTeamCommand(p)); - registerSubCommand(new UHBorderCommand(p)); registerSubCommand(new UHSpectatorsCommand(p)); - registerSubCommand(new UHGenerateWallsCommand(p)); // Bugs registerSubCommand(new UHHealCommand(p)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java deleted file mode 100644 index 5386e47..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHBorderCommand.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderCheckCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderGetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderSetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border.UHBorderWarningCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - - -/** - * This command manages borders (gets current, checks if players are out, sets a new size, warns players - * about the future size). - * - * Usage: /uh border (doc) - * Usage: /uh border <get|set [force]|warning|check> - */ -@Command (name = "border") -public class UHBorderCommand extends AbstractCommand -{ - public UHBorderCommand(UHCReloaded p) - { - registerSubCommand(new UHBorderGetCommand(p)); - registerSubCommand(new UHBorderSetCommand(p)); - registerSubCommand(new UHBorderWarningCommand(p)); - registerSubCommand(new UHBorderCheckCommand(p)); - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Collections.singletonList(I.t("{aqua}------ Border commands ------")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh border {ci}: manages borders. Execute /uh border for details.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java deleted file mode 100644 index ea42728..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHGenerateWallsCommand.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.World; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -/** - * This command generates the walls around the map. - * - * Usage: /uh generatewalls - */ -@Command (name = "generatewalls") -public class UHGenerateWallsCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHGenerateWallsCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - sender.sendMessage(I.t("{cst}Generating the walls...")); - - final World world; - - if (sender instanceof Player) - { - world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { - world = ((BlockCommandSender) sender).getBlock().getWorld(); - } - else - { - world = p.getServer().getWorlds().get(0); - sender.sendMessage(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName())); - } - -// try -// { -// p.getBorderManager().generateWalls(world); -// } -// catch (CannotGenerateWallsException e) -// { -// sender.sendMessage(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); -// return; -// -// } -// catch (Exception e) -// { -// sender.sendMessage(I.t("{ce}An error occurred, see console for details.")); -// e.printStackTrace(); -// return; -// } - - sender.sendMessage(I.t("{cst}Generation done.")); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh generatewalls {ci}: generates the walls according to the configuration.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java deleted file mode 100644 index 1d7d766..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTeamCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamAddCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamBannerResetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamGUICommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamJoinCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamLeaveCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamListCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamRemoveCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamResetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamSpyCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * This command is used to manage the teams. - * - * Usage: /uh team (for the doc). - * Usage: /uh team <add|remove|join|leave|banner|list|spy|reset> (see doc for details). - */ -@Command (name = "team") -public class UHTeamCommand extends AbstractCommand -{ - public UHTeamCommand(UHCReloaded plugin) - { - registerSubCommand(new UHTeamAddCommand(plugin)); - registerSubCommand(new UHTeamRemoveCommand(plugin)); - registerSubCommand(new UHTeamJoinCommand(plugin)); - registerSubCommand(new UHTeamLeaveCommand(plugin)); - registerSubCommand(new UHTeamBannerCommand()); - registerSubCommand(new UHTeamBannerResetCommand()); - registerSubCommand(new UHTeamListCommand(plugin)); - registerSubCommand(new UHTeamSpyCommand(plugin)); - registerSubCommand(new UHTeamResetCommand(plugin)); - registerSubCommand(new UHTeamGUICommand(plugin)); - } - - /** - * This will be executed if this command is called without argument, - * or if there isn't any sub-command executor registered. - * - * @param sender The sender. - * @param args The arguments passed to the command. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - /** - * The result of this method will be added to the tab-complete suggestions for this command. - * - * @param sender The sender. - * @param args The arguments. - * - * @return The suggestions to add. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Arrays.asList( - I.t("{aqua}------ Team commands ------"), - I.t("{cc}/join [player] <team ...> {ci}: adds “player” (or the sender) inside the given team. Without arguments, displays the chat-based team selector."), - I.t("{cc}/leave [player] {ci}: removes “player” (or the sender) from his team.") - ); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team {ci}: manages the teams. Execute /uh team for details.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java deleted file mode 100644 index 51b7bdd..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderCheckCommand.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -@Command (name = "check") -public class UHBorderCheckCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHBorderCheckCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // /uh border check - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - // /uh border check <?> - else - { - try - { -// p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0])); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh border check <diameter>{ci}: returns a list of the players outside the given border size.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java deleted file mode 100644 index 66cab42..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderGetCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -@Command (name = "get") -public class UHBorderGetCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHBorderGetCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { -// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) -// { -// sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", p.getBorderManager().getCurrentBorderDiameter())); -// } -// else -// { -// sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter())); -// } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh border get{ci}: returns the current size of the map.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java deleted file mode 100644 index ec83ece..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderSetCommand.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -@Command (name = "set") -public class UHBorderSetCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHBorderSetCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { -// // /uh border set -// if (args.length == 0) -// { -// throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); -// } -// -// // /uh border set <?> -// else if (args.length == 1) -// { -// try -// { -// final int newDiameter = Integer.valueOf(args[0]); -// -// // Some players are outside -// if (p.getBorderManager().getPlayersOutside(newDiameter).size() != 0) -// { -// sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); -// sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); -// -// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled()) -// { -// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); -// } -// -// p.getBorderManager().sendCheckMessage(sender, newDiameter); -// } -// else -// { -// p.getBorderManager().setCurrentBorderDiameter(newDiameter); -// -// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) -// { -// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); -// } -// else -// { -// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); -// } -// } -// } -// catch (NumberFormatException e) -// { -// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); -// } -// } -// -// // /uh border set <?> force -// else if (args.length == 2 && args[1].equalsIgnoreCase("force")) -// { -// try -// { -// Integer newDiameter = Integer.valueOf(args[0]); -// -// p.getBorderManager().setCurrentBorderDiameter(newDiameter); -// -// if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) -// { -// p.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); -// } -// else -// { -// p.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); -// } -// } -// catch (NumberFormatException e) -// { -// sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); -// } -// } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 2) - { - return CommandUtils.getAutocompleteSuggestions(args[1], Collections.singletonList("force")); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh border set <diameter> [force]{ci}: changes the size of the map. If force is not given, the operation will be canceled if there is a player outside the border.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java deleted file mode 100644 index 807e3d7..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/border/UHBorderWarningCommand.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.border; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -@Command (name = "warning") -public class UHBorderWarningCommand extends AbstractCommand -{ - private final Integer WARNING_INTERVAL; - - private final UHCReloaded p; - - - public UHBorderWarningCommand(UHCReloaded p) - { - this.p = p; - - WARNING_INTERVAL = UHConfig.MAP.BORDER.WARNING_INTERVAL.get(); - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { // /uh border warning - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - else if (args[0].equalsIgnoreCase("cancel")) - { // /uh border warning cancel - // p.getBorderManager().cancelWarning(); - sender.sendMessage(I.t("{cs}Warning canceled.")); - } - else - { // /uh border warning <?> - try - { - int warnDiameter = Integer.parseInt(args[0]); - int warnTime = 0; - - // /uh border warning <?> <?> - if (args.length >= 4) - { - warnTime = Integer.parseInt(args[1]); - } - - // p.getBorderManager().setWarningSize(warnDiameter, warnTime, sender); - sender.sendMessage(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", WARNING_INTERVAL)); - - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 1) - { - return CommandUtils.getAutocompleteSuggestions(args[0], Collections.singletonList("cancel")); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Arrays.asList(I.t("{cc}/uh border warning <futureDiameter> [minutesBeforeReduction]{ci}: warns all players outside the given future diameter. It's just a notice, nothing else."), I.t("{cc}/uh border warning cancel{ci}: cancels a previously-set warning.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java deleted file mode 100644 index b00023a..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamAddCommand.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -@Command (name = "add") -public class UHTeamAddCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamAddCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // /uh team add <color> - if (args.length == 1) - { - - TeamColor color = TeamColor.fromString(args[0]); - UHTeam team; - - if (color == null) - { - sender.sendMessage(I.t("{ce}Unable to add the team, check the color name. Tip: use Tab to autocomplete.")); - } - else - { - try - { - team = p.getTeamManager().addTeam(color); - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}This team already exists.")); - return; - } - - sender.sendMessage(I.t("{cs}Team {0}{cs} added.", team.getDisplayName())); - } - - } - else if (args.length >= 2) - { // /uh team add <color> <name ...> - - TeamColor color = TeamColor.fromString(args[0]); - UHTeam team; - - if (color == null) - { - sender.sendMessage(I.t("{ce}Unable to add the team, check the color name. Tip: use Tab to autocomplete.")); - } - else - { - String name = UHUtils.getStringFromCommandArguments(args, 1); - - try - { - team = p.getTeamManager().addTeam(color, name); - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}This team already exists.")); - return; - } - - sender.sendMessage(I.t("{cs}Team {0}{cs} added.", team.getDisplayName())); - } - - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 1) - { - List<String> colors = Arrays.asList("aqua", "black", "blue", "darkaqua", - "darkblue", "darkgray", "darkgreen", "darkpurple", "darkred", - "gold", "gray", "green", "lightpurple", "red", "white", "yellow", "?"); - - return CommandUtils.getAutocompleteSuggestions(args[0], colors); - } - - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team add <color> [<name ...>] {ci}: adds a team with the provided color.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java deleted file mode 100644 index f8ce689..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerCommand.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "banner") -public class UHTeamBannerCommand extends AbstractCommand -{ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!(sender instanceof Player)) - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this); - - final UHTeam team; - - if (args.length >= 1) - { - String name = UHUtils.getStringFromCommandArguments(args, 0); - team = UHCReloaded.get().getTeamManager().getTeam(name); - } - else - { - team = UHCReloaded.get().getTeamManager().getTeamForPlayer((Player) sender); - } - - if (team == null) - { - sender.sendMessage(I.t("{ce}Either this team does not exists, or you are not in a team.")); - } - else if (((Player) sender).getItemInHand().getType() != Material.BANNER) - { - sender.sendMessage(I.t("{ce}You must run this command with a banner in your main hand.")); - } - else - { - team.setBanner(((Player) sender).getItemInHand()); - sender.sendMessage(I.t("{cs}The banner of the team {0}{cs} was successfully updated.", team.getDisplayName())); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - ArrayList<String> teamNames = new ArrayList<>(); - - for (UHTeam team : UHCReloaded.get().getTeamManager().getTeams()) - { - teamNames.add(team.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team banner [team name ...] {ci}: updates the team's banner using the banner in the sender hand. If the team name is not provided, uses the sender's team.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java deleted file mode 100644 index 80bfaae..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamBannerResetCommand.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.bukkit.inventory.ItemStack; - - -@Command (name = "bannerreset") -public class UHTeamBannerResetCommand extends AbstractCommand -{ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - UHTeam team = null; - - if (args.length >= 1) - { - String name = UHUtils.getStringFromCommandArguments(args, 0); - team = UHCReloaded.get().getTeamManager().getTeam(name); - } - else if (sender instanceof Player) - { - team = UHCReloaded.get().getTeamManager().getTeamForPlayer((Player) sender); - } - else - { - /// Error message of /uh team bannerreset from the console without name - sender.sendMessage(I.t("{ce}From the console, you must provide a team name.")); - } - - - if (team == null) - { - sender.sendMessage(I.t("{ce}Either this team does not exists, or you are not in a team.")); - } - else - { - team.setBanner((ItemStack) null); - sender.sendMessage(I.t("{cs}The banner of the team {0}{cs} was successfully reset to the default one.", team.getDisplayName())); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - ArrayList<String> teamNames = new ArrayList<>(); - - for (UHTeam team : UHCReloaded.get().getTeamManager().getTeams()) - { - teamNames.add(team.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team bannerreset [team name ...] {ci}: resets the banner of the team to the default. If the team name is not provided, uses the sender's team.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java deleted file mode 100644 index 3016b6d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamGUICommand.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "gui", noPermission = true, inheritPermission = false) -public class UHTeamGUICommand extends AbstractCommand -{ - public UHTeamGUICommand(UHCReloaded plugin) {} - - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this); - } - - Gui.open((Player) sender, new TeamsSelectorGUI()); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team gui {ci}: opens a GUI to join and manage the teams.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java deleted file mode 100644 index e37737d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamJoinCommand.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -/** - * This class is used for both /uh team join and /join commands. - * - * @see {@link eu.carrade.amaury.UHCReloaded.old.commands.commands.JoinCommand}. - */ -@Command (name = "join") -public class UHTeamJoinCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamJoinCommand(UHCReloaded plugin) - { - p = plugin; - } - - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(final CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - - UHTeam team; - - String targetName = ""; - Boolean self = null; - - // /... join <team>? - team = p.getTeamManager().getTeam(UHUtils.getStringFromCommandArguments(args, 0)); - if (team != null) - { - if (sender instanceof Player) - { - targetName = sender.getName(); - self = true; - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - } - - // /... join <player> <team>? - else if (args.length >= 2) - { - team = p.getTeamManager().getTeam(UHUtils.getStringFromCommandArguments(args, 1)); - if (team != null) - { - targetName = args[0]; - self = false; - } - } - - if (team == null) - { - sender.sendMessage(I.t("{ce}This team does not exists.")); - } - else if (sender.hasPermission("uh.team.join") - || (self && sender.hasPermission("uh.player.join.self")) - || (!self && sender.hasPermission("uh.player.join.others"))) - { - final UHTeam finalTeam = team; - OfflinePlayersLoader.loadPlayer(targetName, player -> { - if (player == null) - { - sender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); - - if (!Bukkit.getOnlineMode()) - sender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); - - return; - } - - finalTeam.addPlayer(player); - - if (!sender.equals(player)) - { - sender.sendMessage(I.t("{cs}The player {0} was successfully added to the team {1}", player.getName(), finalTeam.getName())); - } - }); - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED, this); - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - - if (args.length >= 2) - { - ArrayList<String> teamNames = new ArrayList<>(); - - for (UHTeam team : this.p.getTeamManager().getTeams()) - { - teamNames.add(team.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 1), teamNames, args.length - 2); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team join <player> <teamName ...> {ci}: adds a player inside the given team. The name of the team is it color, or the explicit name given.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java deleted file mode 100644 index 81963f9..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamLeaveCommand.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "leave") -public class UHTeamLeaveCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamLeaveCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - final OfflinePlayer target; - - if (args.length == 0) - { - if (sender instanceof Player) - { - target = (OfflinePlayer) sender; - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - } - - // /uh team leave <player> - else - { - target = OfflinePlayersLoader.getOfflinePlayer(args[0]); - } - - - if (target == null) - { - sender.sendMessage(I.t("{ce}The player {0} is disconnected and never logged in before!", args[0])); // args.length >= 1 here. - } - - else - { - - // Permissions check - if (sender.hasPermission("uh.team.leave") - || (target.equals(sender) && sender.hasPermission("uh.player.leave.self")) - || (!target.equals(sender) && sender.hasPermission("uh.player.leave.others"))) - { - - - p.getTeamManager().removePlayerFromTeam(target); - - if (!target.equals(sender)) - { - sender.sendMessage(I.t("{cs}The player {0} was successfully removed from his team.", target.getName())); - } - - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED); - } - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team leave <player> {ci}: removes a player from his team.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java deleted file mode 100644 index e8c57e0..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamListCommand.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "list") -public class UHTeamListCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamListCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (p.getTeamManager().getTeams().size() == 0) - { - sender.sendMessage(I.t("{ce}There isn't any team to show.")); - return; - } - - for (final UHTeam team : p.getTeamManager().getTeams()) - { - sender.sendMessage(I.tn("{0} ({1} player)", "{0} ({1} players)", team.getSize(), team.getDisplayName(), team.getSize())); - for (final OfflinePlayer player : team.getPlayers()) - { - String bullet; - if (player.isOnline()) - { - /// Online dot in /uh team list - bullet = I.t("{green} • "); - } - else - { - /// Offline dot in /uh team list - bullet = I.t("{red} • "); - } - - /// Player name after the online status dot in /uh teams list - sender.sendMessage(bullet + I.tc("teams_list", "{0}", player.getName())); - } - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team list {ci}: lists the teams and their players.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java deleted file mode 100644 index 52fb585..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamRemoveCommand.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -@Command (name = "remove") -public class UHTeamRemoveCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamRemoveCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length >= 1) - { // /uh team remove <teamName> - String name = UHUtils.getStringFromCommandArguments(args, 0); - if (!p.getTeamManager().removeTeam(name)) - { - sender.sendMessage(I.t("{ce}This team does not exists.")); - } - else - { - sender.sendMessage(I.t("{cs}Team {0} deleted.", name)); - } - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - ArrayList<String> teamNames = new ArrayList<>(); - - for (UHTeam team : this.p.getTeamManager().getTeams()) - { - teamNames.add(team.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team remove <name ...> {ci}: removes a team")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java deleted file mode 100644 index 406def8..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamResetCommand.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "reset") -public class UHTeamResetCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTeamResetCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - p.getTeamManager().reset(); - sender.sendMessage(I.t("{cs}All teams where removed.")); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team reset {ci}: removes all teams.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java deleted file mode 100644 index 7488863..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/team/UHTeamSpyCommand.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "spy") -public class UHTeamSpyCommand extends AbstractCommand -{ - private final UHCReloaded p; - - public UHTeamSpyCommand(UHCReloaded plugin) - { - p = plugin; - } - - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - Player target; - - if (args.length >= 1) - { - if (sender.hasPermission("uh.team.spy.others")) - { - target = Bukkit.getPlayer(args[0]); - if (target == null) - { - sender.sendMessage(I.t("{ce}Cannot toggle the spy mode of {0} because he/she is offline.", args[0])); - return; - } - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED, this); - } - } - else - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this); - } - - target = (Player) sender; - } - - - String message; - - if (p.getTeamChatManager().isGlobalSpy(target.getUniqueId())) - { - p.getTeamChatManager().removeGlobalSpy(target.getUniqueId()); - message = I.t("{cs}Spy mode {darkred}disabled{cs} for {0}.", target.getName()); - } - else - { - p.getTeamChatManager().addGlobalSpy(target.getUniqueId()); - message = I.t("{cs}Spy mode {darkgreen}enabled{cs} for {0}.", target.getName()); - } - - target.sendMessage(message); - if (!sender.equals(target)) - sender.sendMessage(message); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh team spy [player] {ci}: allows yourself (or the target player) to receive all the team chats (read-only). Execute again to stop.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/EpisodeChangedCause.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/EpisodeChangedCause.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java index 70bb4f4..beae2ac 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/EpisodeChangedCause.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; public enum EpisodeChangedCause { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHEpisodeChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHEpisodeChangedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java index 94a5473..e88c463 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHEpisodeChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java index 7e2eac1..83482ea 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import org.bukkit.event.Cancellable; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameStartsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameStartsEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java index 2592d7e..befefae 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameStartsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerDeathEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java index f0cbe82..c4f7e1f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import org.bukkit.entity.Player; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerResurrectedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerResurrectedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java index b71bc5b..5302037 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerResurrectedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import org.bukkit.entity.Player; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java index cf68d09..e1e549d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.events; +package eu.carrade.amaury.UHCReloaded.old.events; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java index 43706a6..6bf392b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java @@ -33,7 +33,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 5897dc2..84280ed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -34,15 +34,15 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.events.EpisodeChangedCause; +import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import eu.carrade.amaury.UHCReloaded.events.UHEpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.events.UHGameEndsEvent; -import eu.carrade.amaury.UHCReloaded.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.events.UHPlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.events.UHTeamDeathEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameEndsEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHTeamDeathEvent; import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java index ef97f3d..ed59396 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java @@ -32,8 +32,8 @@ package eu.carrade.amaury.UHCReloaded.scoreboard; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.events.UHPlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java new file mode 100644 index 0000000..9590fc5 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -0,0 +1,86 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.shortcuts; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleLogger; +import eu.carrade.amaury.UHCReloaded.core.UHModule; + + +/** + * Useful shortcuts. + */ +public final class UR +{ + /** + * Returns the plugin's instance. + */ + public static UHCReloaded get() + { + return UHCReloaded.get(); + } + + /** + * Gets a module's instance. This may return null if the module is not currently + * enabled. + * + * @param moduleClass The module's class. + * @param <M> The module's type. + * + * @return The module's instance. + */ + public static <M extends UHModule> M module(final Class<M> moduleClass) + { + return UHCReloaded.getModule(moduleClass); + } + + /** + * Returns the logger for a given module. This may return null if the module is not + * currently enabled. + * + * @param moduleClass The module's class. + * @return The module's logger. + */ + public static ModuleLogger log(final Class<? extends UHModule> moduleClass) + { + try + { + return module(moduleClass).log(); + } + catch (final NullPointerException e) + { + return null; + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java index d5212da..3b6486c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java @@ -31,6 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.utils; +import fr.zcraft.zlib.tools.PluginLogger; import org.apache.commons.lang.StringUtils; import java.util.Arrays; @@ -52,6 +53,20 @@ public class ModulesUtils */ public static <T> Class<? extends T> getClassFromName(final String name, final String optionalPackage, final String optionalSuffix, final Class<T> superClass) { + final String alternateName; + + if (name.contains(".")) + { + final String[] lastClassPathParts = name.split("\\."); + PluginLogger.info(Arrays.toString(lastClassPathParts)); + + alternateName = lastClassPathParts[lastClassPathParts.length - 1]; + } + else + { + alternateName = name; + } + final List<String> possibilities = Arrays.asList( optionalPackage + "." + name, optionalPackage + "." + name + optionalSuffix, @@ -63,11 +78,15 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name), optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name) + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + alternateName, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + alternateName + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName), + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName) + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + optionalSuffix, name ); - for (String clazzName : possibilities) + for (final String clazzName : possibilities) { try { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bb43f46..86e94d4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -17,7 +17,12 @@ lang: # The modules to load & enable. You can add modules provided by other plugins. # Each module's configuration is in plugins/UHPlugin/modules/<modulename>.yml . +# You can put internal modules or refer to modules classes from other plugins. In all +# cases, replace all dots in class paths by dashes. modules: + "border-walls": true + "border-warning": true + "border-check": true # The worlds to use as main worlds. # If not found, fallbacks on the first world found with the right type. From f2290bfe55a201ea91084a85185700f851f0ef2a Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 22 Nov 2018 16:52:00 +0100 Subject: [PATCH 04/91] Finished spawns module. - Added commands to spawn module. - Fixed spawn points generation in the Nether. --- .../core/modules/ModulesManagerModule.java | 19 + .../modules/core/spawns/SpawnsModule.java | 32 +- .../core/spawns/commands/SpawnsCommand.java | 557 ++++++++++++++++++ .../CircularSpawnPointsGenerator.java | 3 +- .../generators/GridSpawnPointsGenerator.java | 3 +- .../RandomSpawnPointsGenerator.java | 7 +- .../old/commands/UHCommandExecutor.java | 7 - .../old/commands/commands/JoinCommand.java | 68 --- .../old/commands/commands/LeaveCommand.java | 47 -- .../old/commands/commands/TeamsCommand.java | 46 -- .../old/commands/commands/UHRootCommand.java | 1 - .../commands/commands/uh/UHSpawnsCommand.java | 108 ---- .../uh/spawns/UHSpawnsAddCommand.java | 164 ------ .../uh/spawns/UHSpawnsDumpCommand.java | 128 ---- .../uh/spawns/UHSpawnsGenerateCommand.java | 281 --------- .../uh/spawns/UHSpawnsListCommand.java | 194 ------ .../uh/spawns/UHSpawnsRemoveCommand.java | 135 ----- .../uh/spawns/UHSpawnsResetCommand.java | 95 --- .../UHCReloaded/utils/ModulesUtils.java | 3 - 19 files changed, 601 insertions(+), 1297 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java index 4888b20..4a5b6e9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -34,7 +34,13 @@ import com.google.common.collect.ImmutableMap; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; import java.util.Collections; import java.util.List; @@ -62,4 +68,17 @@ public Map<String, Class<? extends Command>> getCommandsAliases() "modules", ModulesCommand.class ); } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + if (player.isOp() && UR.module(GameModule.class).getPhase() == GamePhase.WAIT) // TODO Permissions + { + injector.injectLines( + true, + I.t("{gold}To configure the game,"), + I.t("{gold}use {bold}/config") + ); + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java index 1e71bda..fe5a5af 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java @@ -36,20 +36,24 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.commands.SpawnsCommand; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.SpawnPointsGenerator; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.util.Vector; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; -@ModuleInfo ( +@ModuleInfo( name = "Spawns", description = "Manages the spawns point and allow users to generate them randomly", settings = Config.class, @@ -59,15 +63,18 @@ public class SpawnsModule extends UHModule { private List<Location> spawnPoints = new LinkedList<>(); - private BorderModule borderModule; @Override protected void onEnable() { - borderModule = UHCReloaded.getModule(BorderModule.class); spawnPoints.addAll(Config.SPAWN_POINTS); } + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(SpawnsCommand.class); + } /** * Adds a spawn point at (x;z) in the default world. @@ -107,7 +114,6 @@ public void addSpawnPoint(final World world, final Double x, final Double z) * * @param location The location. Cloned, so you can use the same location object with * modifications between two calls. - * * @throws RuntimeException If the spawn point is in the Nether and no safe spot was * found. * @throws IllegalArgumentException If the spawn point is out of the current border. @@ -132,7 +138,7 @@ public void addSpawnPoint(final Location location) spawnPoint.setY(safeSpot.getY()); } - if (!borderModule.isInsideBorder(spawnPoint)) + if (!UR.module(BorderModule.class).isInsideBorder(spawnPoint)) { throw new IllegalArgumentException("The given spawn location is outside the current border"); } @@ -157,10 +163,9 @@ public List<Location> getSpawnPoints() * @param location The location to be removed. * @param precise If true, only the spawn points at the exact same location will be removed. * Else, the points in the same block. - * * @return true if something were removed. */ - public boolean removeSpawnPoint(Location location, boolean precise) + public boolean removeSpawnPoint(final Location location, final boolean precise) { final List<Location> toRemove = getSpawnPoints().stream() .filter(spawn -> location.getWorld().equals(spawn.getWorld())) @@ -183,7 +188,7 @@ public boolean removeSpawnPoint(Location location, boolean precise) /** * Removes all registered spawn points. - * + * <p> * CANNOT BE CANCELLED. */ public void reset() @@ -201,7 +206,7 @@ public int importSpawnPointsFromConfig() { int spawnCount = 0; - for (Vector position: UHConfig.SPAWN_POINTS) + for (Vector position : UHConfig.SPAWN_POINTS) { addSpawnPoint(position); ++spawnCount; @@ -227,11 +232,10 @@ public int importSpawnPointsFromConfig() * region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the * region where the points will be generated. - * * @throws CannotGenerateSpawnPointsException In case of fail. * @throws UnknownGeneratorException If no generator was found by the given name. */ - public void generateSpawnPoints(String generatorName, World world, int spawnCount, int regionDiameter, int minimalDistanceBetweenTwoPoints, double xCenter, double zCenter) throws CannotGenerateSpawnPointsException, UnknownGeneratorException + public void generateSpawnPoints(final String generatorName, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException, UnknownGeneratorException { Generator generator = Generator.fromString(generatorName); if (generator != null) @@ -260,10 +264,9 @@ public void generateSpawnPoints(String generatorName, World world, int spawnCoun * region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the * region where the points will be generated. - * * @throws CannotGenerateSpawnPointsException In case of fail. */ - public void generateSpawnPoints(Generator generator, World world, int spawnCount, int regionDiameter, int minimalDistanceBetweenTwoPoints, double xCenter, double zCenter) throws CannotGenerateSpawnPointsException + public void generateSpawnPoints(final Generator generator, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException { generateSpawnPoints(generator.getInstance(), world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, xCenter, zCenter); } @@ -284,10 +287,9 @@ public void generateSpawnPoints(Generator generator, World world, int spawnCount * region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the * region where the points will be generated. - * * @throws CannotGenerateSpawnPointsException In case of fail. */ - public void generateSpawnPoints(SpawnPointsGenerator generator, World world, int spawnCount, int regionDiameter, int minimalDistanceBetweenTwoPoints, double xCenter, double zCenter) throws CannotGenerateSpawnPointsException + public void generateSpawnPoints(final SpawnPointsGenerator generator, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException { generator.generate( world, spawnCount, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java new file mode 100644 index 0000000..e09325a --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java @@ -0,0 +1,557 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.spawns.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.command.BlockCommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@CommandInfo( + name = "spawns", + usageParameters = "[generate | add [<x> <z>] | remove [<x> <z>] | dump | help]", + aliases = {"spawn", "s"} +) +public class SpawnsCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length == 0) + { + list(); + return; + } + + switch (args[0].toLowerCase()) + { + case "list": + list(); + return; + + case "dump": + dump(); + return; + + case "add": + add(); + return; + + case "remove": + remove(); + return; + + case "generate": + generate(); + return; + + case "reset": + reset(); + + default: + help(); + } + } + + protected void help() + { + info(I.t("{blue}{bold}Command help for {cc}{bold}/uh spawns")); + info(I.t("{cc}/uh spawns list {ci}: lists the registered spawn points.")); + info(I.t("{cc}/uh spawns dump {ci}: displays the registered spawn points in an exportable format. {gray}Use this to plot the spawn points, as example.")); + info(I.t("{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the current location of the sender or at the provided coordinates.")); + info(I.t("{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the specified coordinates, or at the current location if the sender without coordinates.")); + info(I.t("{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh spawns generate for details.")); + info(I.t("{cc}/uh spawns reset {ci}: removes all registered spawn points.")); + } + + protected void list() + { + final List<Location> spawnPoints = UR.module(SpawnsModule.class).getSpawnPoints(); + + if (spawnPoints.size() == 0) + { + if (sender instanceof Player) info(""); + info(I.t("{ce}There isn't any registered spawn point.")); + + if (args.length == 0) + { + info(""); + help(); + } + } + else + { + if (sender instanceof Player) info(""); + info(I.t("{ci}There are {0} registered spawn points.", String.valueOf(spawnPoints.size()))); + + // We want one list per world + final Map<World, List<Location>> spawnsInWorlds = new HashMap<>(); + spawnPoints.forEach(spawn -> { + spawnsInWorlds.putIfAbsent(spawn.getWorld(), new LinkedList<>()); + spawnsInWorlds.get(spawn.getWorld()).add(spawn); + }); + + for (Map.Entry<World, List<Location>> spanwsInWorld : spawnsInWorlds.entrySet()) + { + if (spanwsInWorld.getValue().size() == 0) + { + continue; + } + + info(""); + info(I.t("{lightpurple}World {0}", spanwsInWorld.getKey().getName())); + + + // Displaying this number of spawn points per line + final int spawnsPerLine = 5; + + for (int j = 0; j < Math.ceil((double) spanwsInWorld.getValue().size() / spawnsPerLine); j++) + { + final StringBuilder line = new StringBuilder(); + + for (int k = 0; k < spawnsPerLine; k++) + { + if (spanwsInWorld.getValue().size() > j * spawnsPerLine + k) + { + line.append( + getSpawnItem( + spanwsInWorld.getValue().get(j * spawnsPerLine + k).getBlockX(), + spanwsInWorld.getValue().get(j * spawnsPerLine + k).getBlockZ(), + spanwsInWorld.getKey().getEnvironment() + ) + ).append(" "); + } + } + + info(line.toString()); + } + } + } + } + + protected void dump() + { + // We want one list per world + final Map<World, List<Location>> spawnsInWorlds = new HashMap<>(); + + UR.module(SpawnsModule.class) + .getSpawnPoints() + .forEach(spawn -> { + spawnsInWorlds.putIfAbsent(spawn.getWorld(), new LinkedList<>()); + spawnsInWorlds.get(spawn.getWorld()).add(spawn); + }); + + StringBuilder dump = new StringBuilder(); + + for (Map.Entry<World, List<Location>> spawnsInWorld : spawnsInWorlds.entrySet()) + { + if (spawnsInWorld.getValue().size() == 0) + { + continue; + } + + dump.append("\n* ").append(spawnsInWorld.getKey().getName()).append("\n"); + + for (Location spawn : spawnsInWorld.getValue()) + { + dump.append(spawn.getBlockX()).append(",").append(spawn.getBlockZ()).append("\n"); + } + } + + sender.sendMessage(dump.toString()); + } + + protected void add() throws CommandException + { + // World? + final World world; + if (sender instanceof Player) + { + world = ((Player) sender).getWorld(); + } + else if (sender instanceof BlockCommandSender) + { + world = ((BlockCommandSender) sender).getBlock().getWorld(); + } + else if (args.length >= 4) + { + world = Bukkit.getWorld(args[3]); + + if (world == null) throwInvalidArgument(I.t("There is no world named {0}.", args[3])); + } + else + { + world = UR.get().getWorld(Environment.NORMAL); + } + + // /uh spawns add + if (args.length == 1) + { + try + { + UR.module(SpawnsModule.class).addSpawnPoint(playerSender().getLocation()); + success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(playerSender().getLocation().getBlockX()), String.valueOf(playerSender().getLocation().getBlockZ()))); + } + catch (IllegalArgumentException e) + { + error(I.t("{ce}You cannot add a spawn point out of the borders.")); + } + catch (RuntimeException e) + { + error(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); + } + } + + // /uh spawns add <x>: Two coordinates needed! + else if (args.length == 2) + { + throwInvalidArgument(I.t("{ce}You need to specify two coordinates.")); + } + + // /uh spawns add <x> <z> [world] + else + { + try + { + UR.module(SpawnsModule.class).addSpawnPoint(world, Double.parseDouble(args[1]), Double.parseDouble(args[2])); + success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[1], args[2])); + } + catch (NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}This is not a number!")); + } + catch (IllegalArgumentException e) + { + error(I.t("{ce}You cannot add a spawn point out of the borders.")); + } + catch (RuntimeException e) + { + error(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); + } + } + } + + protected void remove() throws CommandException + { + // /uh spawns remove + if (args.length == 1) + { + UR.module(SpawnsModule.class).removeSpawnPoint(playerSender().getLocation(), false); + success(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", playerSender().getWorld().getName(), playerSender().getLocation().getBlockX(), playerSender().getLocation().getBlockZ())); + + } + + // /uh spawns add <x>: Two coordinates needed! + else if (args.length == 2) + { + throwInvalidArgument(I.t("{ce}You need to specify two coordinates.")); + } + + // /uh spawns remove <x> <z> + else + { + try + { + final World world; + if (sender instanceof Player) + { + world = ((Player) sender).getWorld(); + } + else if (args.length >= 4) + { + world = Bukkit.getWorld(args[3]); + if (world == null) throwInvalidArgument(I.t("There is no world named {0}.", args[3])); + } + else + { + world = UR.get().getWorld(Environment.NORMAL); + } + + UR.module(SpawnsModule.class).removeSpawnPoint( + new Location( + world, Double.parseDouble(args[1]), 0, Double.parseDouble(args[2]) + ), + true + ); + success(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", world, args[1], args[2])); + } + catch (NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}This is not a number!")); + } + } + } + + protected void reset() + { + UR.module(SpawnsModule.class).reset(); + success(I.t("{cs}All the spawn points were removed.")); + } + + protected void generate() throws CommandException + { + // /uh spawns generate + if (args.length == 1) + { + if (sender instanceof Player) info(""); + + info(I.t("{aqua}Command")); + info(I.t("{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); + info(""); + info(I.t("{aqua}Shapes")); + info(I.t(" - {cc}random{ci}: generates random spawn points on the map, with a minimal distance between them.")); + info(I.t(" - {cc}grid{ci}: generates the spawn points on concentric squares, with a constant distance between two generated points.")); + info(I.t(" - {cc}circular{ci}: generates the spawn points on concentric circles, with a minimal distance between two generated points. In each circle, the angle (and the distance) between two spawn points is constant.")); + info(""); + info(I.t("{aqua} Arguments ")); + info(I.t(" - {cc}size{ci}: the size of the region where the spawn points will be generated. Squared or circular, following the shape of the map. Default: map' size.")); + info(I.t(" - {cc}distanceMin{ci}: the minimal distance between two spawn points. Default: 250 blocks.")); + info(I.t(" - {cc}count{ci}: the number of spawn points to generate. Default: the number of players or teams.")); + info(I.t(" - {cc}xCenter{ci}, {cc}zCenter{ci}: the center of the region where the points are generated. Default: world' spawn point.")); + info(I.t(" - {cc}world{ci}: the world where the spawn points will be generated.")); + + return; + } + + final String generationMethod = args[1]; + + // Default values + int size = UR.module(BorderModule.class).getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border + int distanceMinBetweenTwoPoints = 250; + World world = UR.get().getWorld(Environment.NORMAL); + double xCenter = world.getSpawnLocation().getX(); + double zCenter = world.getSpawnLocation().getZ(); + + int spawnsCount = 0; +// TODO Default to either teams (if any) or players count. +// for (final ZTeam team : ZTeams.get().getTeams()) +// { +// if (!team.isEmpty()) spawnsCount++; +// } + + if (args.length < 8) + { + if (sender instanceof Player) + { + world = ((Player) sender).getWorld(); + } + else if (sender instanceof BlockCommandSender) + { + world = ((BlockCommandSender) sender).getBlock().getWorld(); + } + + xCenter = world.getSpawnLocation().getX(); + zCenter = world.getSpawnLocation().getZ(); + } + + // What if the game is in solo, or some players are out of all team? + // Only if the spawn count is not provided of course. Else, we don't care, this count + // will be overwritten. + if (args.length < 6) + { + // Solo mode? + if (spawnsCount == 0) + { + spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - 0/* TODO UR.module(GameModule.class).getStartupSpectators().size()*/; + info(I.t("{ci}No team found: assuming the game is a solo game.")); + } + else + { + // Trying to find players without team + int playersWithoutTeam = 0; + for (Player player : Bukkit.getServer().getOnlinePlayers()) + { + if (ZTeams.get().getTeamForPlayer(player) == null) + { + playersWithoutTeam++; + } + } + + if (playersWithoutTeam != 0) + { + spawnsCount += playersWithoutTeam; + info(I.t("{ci}Some players are not in a team; their number was added to the spawn count.")); + } + } + } + + try + { + // size included + if (args.length >= 3) + { + size = Integer.parseInt(args[2]); + + // distance minimal included + if (args.length >= 4) + { + distanceMinBetweenTwoPoints = Integer.parseInt(args[3]); + + // spawn count included + if (args.length >= 5) + { + spawnsCount = Integer.parseInt(args[4]); + + // xCenter included + if (args.length >= 6) + { + xCenter = Double.parseDouble(args[5]); + + // zCenter included + if (args.length >= 7) + { + zCenter = Double.parseDouble(args[6]); + + // world included + if (args.length >= 8) + { + final World inputWorld = Bukkit.getServer().getWorld(args[7]); + + if (inputWorld != null) + { + world = inputWorld; + } + else + { + error(I.t("{ce}The world {0} doesn't exists.", args[7])); + } + } + } + } + } + } + } + } + catch (NumberFormatException e) + { + info(I.t("{ce}This is not a number!")); + info(I.t("{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); + return; + } + + + if (spawnsCount <= 0) + { + sender.sendMessage(I.t("{ci}You asked for a void generation. Thus, the generation is empty.")); + return; + } + + + try + { + UR.module(SpawnsModule.class) + .generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); + } + catch (UnknownGeneratorException e) + { + throwInvalidArgument(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod)); + + } + catch (CannotGenerateSpawnPointsException e) + { + error(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); + } + + + success(I.t("{cs}Successfully generated the asked spawn points.")); + } + + @Override + protected List<String> complete() throws CommandException + { + if (args.length == 1) + { + return getMatchingSubset(args[0], "add", "remove", "generate", "list", "dump", "reset"); + } + + else if (args.length == 2 && args[0].equalsIgnoreCase("generate")) + { + return getMatchingSubset(args[1], "circular", "grid", "random"); + } + + else if (args.length == 4 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) + { + return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), args[3]); + } + + else if (args.length == 8 && args[0].equalsIgnoreCase("generate")) + { + return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), args[7]); + } + + else return null; + } + + + private String getSpawnItem(int x, int z, Environment environment) + { + switch (environment) + { + case NORMAL: + /// A spawn point in the /uh spawns list command (in the overworld) + return I.t("{green}{0}{darkgreen};{green}{1}", x, z); + + case NETHER: + /// A spawn point in the /uh spawns list command (in the Nether) + return I.t("{red}{0}{darkred};{red}{1}", x, z); + + case THE_END: + /// A spawn point in the /uh spawns list command (in the End) + return I.t("{yellow}{0}{gold};{yellow}{1}", x, z); + + default: + /// A spawn point in the /uh spawns list command (in a custom world) + return I.t("{gray}{0}{darkgray};{gray}{1}", x, z); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index c0c4dd3..2c7b688 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -137,7 +137,8 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if (!UHUtils.isSafeSpot(surfaceAirBlock.getLocation())) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) + || UHUtils.searchSafeSpot(point) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java index eadca2c..ffefa51 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -166,7 +166,8 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if (!UHUtils.isSafeSpot(surfaceAirBlock.getLocation())) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) + || UHUtils.searchSafeSpot(currentPoint) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index 3f00d7e..de303a2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -99,7 +99,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int final double packingDensity = surfacePrivatePartsAroundSpawnPoints / surfaceRegion; - // According to Lagrange and Thue's works on circle packagings, the highest density possible is + // According to Lagrange and Thue's works on circles packaging, the highest density possible is // approximately 0.9069 (with an hexagonal arrangement of the circles). // Even with a packaging density very close to this limit, the generation time is correct. // So we uses this as a limit. @@ -119,7 +119,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // of other ones, we restarts all the generation. int currentErrorCount = 0; - // With the "avoid above water" option, if there's a lot of water, the genaration may + // With the "avoid above water" option, if there's a lot of water, the generation may // fail even if the surface seems to be ok to host the requested spawn points. // So, after 2*{points requested} points above the water, we cancels the generation. int pointsAboveWater = 0; @@ -161,7 +161,8 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if (!UHUtils.isSafeSpot(surfaceAirBlock.getLocation())) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) + || UHUtils.searchSafeSpot(randomPoint) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java index 3e20c6c..bce0a1e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java @@ -33,10 +33,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.old.commands.commands.GlobalMessageCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.JoinCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.LeaveCommand; import eu.carrade.amaury.UHCReloaded.old.commands.commands.TeamMessageCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.TeamsCommand; import eu.carrade.amaury.UHCReloaded.old.commands.commands.ToggleChatCommand; import eu.carrade.amaury.UHCReloaded.old.commands.commands.UHRootCommand; import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommandExecutor; @@ -50,10 +47,6 @@ public UHCommandExecutor(UHCReloaded p) registerCommand(new UHRootCommand(p)); // /uh - registerCommand(new JoinCommand(p)); // /join - registerCommand(new LeaveCommand(p)); // /leave - registerCommand(new TeamsCommand(p)); // /teams - registerCommand(new TeamMessageCommand(p)); // /t registerCommand(new GlobalMessageCommand(p)); // /g registerCommand(new ToggleChatCommand(p)); // /togglechat diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java deleted file mode 100644 index 86be1eb..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/JoinCommand.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamJoinCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - - -// The permissions are too complex, we need to manage them manually. -@Command (name = "join", noPermission = true, inheritPermission = false) -public class JoinCommand extends UHTeamJoinCommand -{ - private UHCReloaded p; - - public JoinCommand(UHCReloaded plugin) - { - super(plugin); - p = plugin; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0 && sender instanceof Player - && sender.hasPermission("uh.player.join.self")) - { - p.getTeamManager().displayTeamChooserChatGUI((Player) sender); - } - - else - { - super.run(sender, args); - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java deleted file mode 100644 index 3d9b056..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/LeaveCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamLeaveCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; - - -// The permissions are too complex, we need to manage them manually. -@Command (name = "leave", noPermission = true, inheritPermission = false) -public class LeaveCommand extends UHTeamLeaveCommand -{ - public LeaveCommand(UHCReloaded plugin) - { - super(plugin); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java deleted file mode 100644 index b42612d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamsCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.team.UHTeamGUICommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; - - -@Command (name = "teams", noPermission = true, inheritPermission = false) -public class TeamsCommand extends UHTeamGUICommand -{ - public TeamsCommand(UHCReloaded plugin) - { - super(plugin); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 7dce0ce..905558f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -53,7 +53,6 @@ public UHRootCommand(UHCReloaded plugin) // Game registerSubCommand(new UHStartCommand(p)); registerSubCommand(new UHShiftCommand(p)); - registerSubCommand(new UHSpawnsCommand(p)); registerSubCommand(new UHSpectatorsCommand(p)); // Bugs diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java deleted file mode 100644 index 226b007..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpawnsCommand.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsAddCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsDumpCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsGenerateCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsListCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsRemoveCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns.UHSpawnsResetCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -@Command (name = "spawns") -public class UHSpawnsCommand extends AbstractCommand -{ - public UHSpawnsCommand(UHCReloaded plugin) - { - registerSubCommand(new UHSpawnsAddCommand(plugin)); - registerSubCommand(new UHSpawnsGenerateCommand(plugin)); - registerSubCommand(new UHSpawnsListCommand(plugin)); - registerSubCommand(new UHSpawnsDumpCommand(plugin)); - registerSubCommand(new UHSpawnsRemoveCommand(plugin)); - registerSubCommand(new UHSpawnsResetCommand(plugin)); - } - - /** - * This will be executed if this command is called without argument, - * or if there isn't any sub-command executor registered. - * - * @param sender The sender. - * @param args The arguments passed to the command. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - /** - * The result of this method will be added to the tab-complete suggestions for this command. - * - * @param sender The sender. - * @param args The arguments. - * - * @return The suggestions to add. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Collections.singletonList(I.t("{aqua}------ Spawns points commands ------")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns {ci}: manages the spawn points. Execute /uh spawns for details.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java deleted file mode 100644 index 9df5607..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsAddCommand.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.World; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "add") -public class UHSpawnsAddCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsAddCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // World? - World world; - if (sender instanceof Player) - { - world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { - world = ((BlockCommandSender) sender).getBlock().getWorld(); - } - else - { - world = p.getServer().getWorlds().get(0); - } - - // /uh spawns add - if (args.length == 0) - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - else - { - Player pl = (Player) sender; // Just a way to avoid casts everywhere. - try - { - // p.getSpawnsManager().addSpawnPoint(pl.getLocation()); - sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ()))); - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}You cannot add a spawn point out of the borders.")); - } - catch (RuntimeException e) - { - sender.sendMessage(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); - } - } - } - - // /uh spawns add <x>: Two coordinates needed! - else if (args.length == 1) - { - sender.sendMessage(I.t("{ce}You need to specify two coordinates.")); - } - - // /uh spawns add <x> <z> - else - { - try - { - // p.getSpawnsManager().addSpawnPoint(world, Double.parseDouble(args[0]), Double.parseDouble(args[1])); - sender.sendMessage(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[0], args[1])); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}This is not a number!")); - } - catch (IllegalArgumentException e) - { - sender.sendMessage(I.t("{ce}You cannot add a spawn point out of the borders.")); - } - catch (RuntimeException e) - { - sender.sendMessage(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); - } - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the current location of the sender or at the provided coordinates.")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return null; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java deleted file mode 100644 index cf1cddf..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsDumpCommand.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - - -@Command (name = "dump") -public class UHSpawnsDumpCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsDumpCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // We want one list per world - Map<World, List<Location>> spanwsInWorlds = new HashMap<World, List<Location>>(); - for (World world : p.getServer().getWorlds()) - { - spanwsInWorlds.put(world, new LinkedList<>()); - } - -// for (Location spawn : p.getSpawnsManager().getSpawnPoints()) -// { -// spanwsInWorlds.get(spawn.getWorld()).add(spawn); -// } - - StringBuilder dump = new StringBuilder(); - - for (Map.Entry<World, List<Location>> spanwsInWorld : spanwsInWorlds.entrySet()) - { - if (spanwsInWorld.getValue().size() == 0) - { - continue; - } - - dump.append("\n* ").append(spanwsInWorld.getKey().getName()).append("\n"); - - for (Location spawn : spanwsInWorld.getValue()) - { - dump.append(spawn.getBlockX()).append(",").append(spawn.getBlockZ()).append("\n"); - } - } - - sender.sendMessage(dump.toString()); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns dump {ci}: displays the registered spawn points in an exportable format. {gray}Use this to plot the spawn points, as example.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java deleted file mode 100644 index 50640bf..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.Generator; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.World; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - - -@Command (name = "generate") -public class UHSpawnsGenerateCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsGenerateCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { // Help - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - String generationMethod = args[0]; - - // Default values - int size = 0; //p.getBorderManager().getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border - int distanceMinBetweenTwoPoints = 250; - World world = p.getServer().getWorlds().get(0); - double xCenter = world.getSpawnLocation().getX(); - double zCenter = world.getSpawnLocation().getZ(); - - int spawnsCount = 0; - for (final UHTeam team : p.getTeamManager().getTeams()) - { - if (!team.isEmpty()) spawnsCount++; - } - - if (args.length < 7) - { - if (sender instanceof Player) - { - world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { - world = ((BlockCommandSender) sender).getBlock().getWorld(); - } - - xCenter = world.getSpawnLocation().getX(); - zCenter = world.getSpawnLocation().getZ(); - } - - // What if the game is in solo, or some players are out of all team? - // Only if the spawn count is not provided of course. Else, we don't care, this count - // will be overwritten. - if (args.length < 5) - { - if (spawnsCount == 0) - { // Solo mode? - sender.sendMessage(I.t("{ci}No team found: assuming the game is a solo game.")); - spawnsCount = p.getServer().getOnlinePlayers().size() - p.getGameManager().getStartupSpectators().size(); - } - else - { - // Trying to find players without team - int playersWithoutTeam = 0; - for (Player player : p.getServer().getOnlinePlayers()) - { - if (p.getTeamManager().getTeamForPlayer(player) == null) - { - playersWithoutTeam++; - } - } - - if (playersWithoutTeam != 0) - { - sender.sendMessage(I.t("{ci}Some players are not in a team; their number was added to the spawn count.")); - spawnsCount += playersWithoutTeam; - } - } - } - - try - { - if (args.length >= 2) - { // size included - size = Integer.parseInt(args[1]); - - if (args.length >= 3) - { // distance minimal included - distanceMinBetweenTwoPoints = Integer.parseInt(args[2]); - - if (args.length >= 4) - { // spawn count included - spawnsCount = Integer.parseInt(args[3]); - - if (args.length >= 5) - { // xCenter included - xCenter = Double.parseDouble(args[4]); - - if (args.length >= 6) - { // zCenter included - zCenter = Double.parseDouble(args[5]); - - if (args.length >= 7) - { // world included - World inputWorld = p.getServer().getWorld(args[6]); - - if (inputWorld != null) - { - world = inputWorld; - } - else - { - sender.sendMessage(I.t("{ce}The world {0} doesn't exists.", args[6])); - return; - } - } - } - } - } - } - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}This is not a number!")); - return; - } - - - if (spawnsCount <= 0) - { - sender.sendMessage(I.t("{ci}You asked for a void generation. Thus, the generation is empty.")); - return; - } - - -// try -// { -// p.getSpawnsManager().generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); -// } -// catch (UnknownGeneratorException e) -// { -// sender.sendMessage(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod)); -// return; -// -// } -// catch (CannotGenerateSpawnPointsException e) -// { -// sender.sendMessage(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); -// return; -// } - - sender.sendMessage(I.t("{cs}Successfully generated the asked spawn points.")); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - // Generation methods - /uh spawns generate <?> - if (args.length == 1) - return CommandUtils.getAutocompleteSuggestions( - args[0], - Arrays.stream(Generator.values()) - .map(generator -> generator.name().toLowerCase()) - .collect(Collectors.toList()) - ); - - // Worlds - /uh spawns generate - - - - - - <?> - else if (args.length == 7) - return CommandUtils.getAutocompleteSuggestions(args[6], p.getServer().getWorlds().stream().map(World::getName).collect(Collectors.toList())); - - else return null; - } - - /** - * Returns the help of this command. - * <p/> - * <p> - * The first line should describe briefly the command, as this line is displayed as - * a line of the help of the parent command. - * </p> - * <p> - * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException} - * is caught by the command executor. - * </p> - * - * @param sender The sender. - * - * @return The help. One line per entry in the list. - */ - @Override - public List<String> help(CommandSender sender) - { - return Arrays.asList( - I.t("{aqua}Command"), - I.t("{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]"), - I.t("{aqua}Shapes"), - I.t(" - {cc}random{ci}: generates random spawn points on the map, with a minimal distance between them."), - I.t(" - {cc}grid{ci}: generates the spawn points on concentric squares, with a constant distance between two generated points."), - I.t(" - {cc}circular{ci}: generates the spawn points on concentric circles, with a minimal distance between two generated points. In each circle, the angle (and the distance) between two spawn points is constant."), - I.t("{aqua}Arguments"), - I.t(" - {cc}size{ci}: the size of the region where the spawn points will be generated. Squared or circular, following the shape of the map. Default: map' size."), - I.t(" - {cc}distanceMin{ci}: the minimal distance between two spawn points. Default: 250 blocks."), - I.t(" - {cc}count{ci}: the number of spawn points to generate. Default: the number of players or teams."), - I.t(" - {cc}xCenter{ci}, {cc}zCenter{ci}: the center of the region where the points are generated. Default: world' spawn point."), - I.t(" - {cc}world{ci}: the world where the spawn points will be generated.") - ); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh spawns generate for details.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java deleted file mode 100644 index eecf361..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsListCommand.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - - -@Command (name = "list") -public class UHSpawnsListCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsListCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - List<Location> spawnPoints = new ArrayList<>(); // p.getSpawnsManager().getSpawnPoints(); - - if (spawnPoints.size() == 0) - { - sender.sendMessage(I.t("{ce}There isn't any registered spawn point.")); - } - else - { - sender.sendMessage(I.t("{ci}There are {0} registered spawn points.", String.valueOf(spawnPoints.size()))); - - // We want one list per world - Map<World, List<Location>> spanwsInWorlds = new HashMap<World, List<Location>>(); - for (World world : p.getServer().getWorlds()) - { - spanwsInWorlds.put(world, new LinkedList<Location>()); - } - - for (Location spawn : spawnPoints) - { - spanwsInWorlds.get(spawn.getWorld()).add(spawn); - } - - for (Map.Entry<World, List<Location>> spanwsInWorld : spanwsInWorlds.entrySet()) - { - if (spanwsInWorld.getValue().size() == 0) - { - continue; - } - - sender.sendMessage(I.t("{lightpurple}World {0}", spanwsInWorld.getKey().getName())); - - - // Displaying this number of spawn points per line - final int spawnsPerLine = 5; - - for (int j = 0; j < Math.ceil((double) spanwsInWorld.getValue().size() / spawnsPerLine); j++) - { - StringBuilder line = new StringBuilder(); - - for (int k = 0; k < spawnsPerLine; k++) - { - if (spawnPoints.size() > j * spawnsPerLine + k) - { - line.append( - getSpawnItem( - spanwsInWorld.getValue().get(j * spawnsPerLine + k).getBlockX(), - spanwsInWorld.getValue().get(j * spawnsPerLine + k).getBlockZ(), - spanwsInWorld.getKey().getEnvironment() - ) - ).append(" "); - } - } - - sender.sendMessage(line.toString()); - } - } - } - } - - private String getSpawnItem(int x, int z, World.Environment environment) - { - switch (environment) - { - case NORMAL: - /// A spawn point in the /uh spawns list command (in the overworld) - return I.t("{green}{0}{darkgreen};{green}{1}", x, z); - - case NETHER: - /// A spawn point in the /uh spawns list command (in the Nether) - return I.t("{red}{0}{darkred};{red}{1}", x, z); - - case THE_END: - /// A spawn point in the /uh spawns list command (in the End) - return I.t("{yellow}{0}{gold};{yellow}{1}", x, z); - - default: - /// A spawn point in the /uh spawns list command (in a custom world) - return I.t("{gray}{0}{darkgray};{gray}{1}", x, z); - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - /** - * Returns the help of this command. - * <p/> - * <p> - * The first line should describe briefly the command, as this line is displayed as - * a line of the help of the parent command. - * </p> - * <p> - * The other lines will only be displayed if the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException} - * is caught by the command executor. - * </p> - * - * @param sender The sender. - * - * @return The help. One line per entry in the list. - */ - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns list {ci}: lists the registered spawn points.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java deleted file mode 100644 index b0f3917..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "remove") -public class UHSpawnsRemoveCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsRemoveCommand(UHCReloaded plugin) - { - p = plugin; - } - - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { // /uh spawns remove - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - else - { - Player pl = (Player) sender; // Just a way to avoid casts everywhere. - // p.getSpawnsManager().removeSpawnPoint(pl.getLocation(), false); - sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", pl.getWorld().getName(), String.valueOf(pl.getLocation().getBlockX()), String.valueOf(pl.getLocation().getBlockZ()))); - } - } - else if (args.length == 1) - { // /uh spawns add <x>: Two coordinates needed! - sender.sendMessage(I.t("{ce}You need to specify two coordinates.")); - } - else - { // /uh spawns remove <x> <z> - try - { - World world; - if (sender instanceof Player) - { - world = ((Player) sender).getWorld(); - } - else - { - world = p.getServer().getWorlds().get(0); - } - - // p.getSpawnsManager().removeSpawnPoint(new Location(world, Double.parseDouble(args[2]), 0, Double.parseDouble(args[3])), true); - sender.sendMessage(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", p.getServer().getWorlds().get(0).getName(), args[2], args[3])); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}This is not a number!")); - } - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the specified coordinates, or at the current location if the sender without coordinates.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java deleted file mode 100644 index f06e09a..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/spawns/UHSpawnsResetCommand.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - - -@Command (name = "reset") -public class UHSpawnsResetCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpawnsResetCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // p.getSpawnsManager().reset(); - sender.sendMessage(I.t("{cs}All the spawn points were removed.")); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spawns reset {ci}: removes all registered spawn points.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java index 3b6486c..759d16a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java @@ -31,7 +31,6 @@ */ package eu.carrade.amaury.UHCReloaded.utils; -import fr.zcraft.zlib.tools.PluginLogger; import org.apache.commons.lang.StringUtils; import java.util.Arrays; @@ -58,8 +57,6 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S if (name.contains(".")) { final String[] lastClassPathParts = name.split("\\."); - PluginLogger.info(Arrays.toString(lastClassPathParts)); - alternateName = lastClassPathParts[lastClassPathParts.length - 1]; } else From 1e3698700de4f4f1f41cd29b0f83a02be51d5c23 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 22 Nov 2018 17:42:43 +0100 Subject: [PATCH 05/91] About module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - NEW: Added “about” module. - NEW: Added /uh about command. - NEW: Added version & stability info into the sidebar during the waiting phase (for advertisement if used on videos + stability warning). --- .../modules/other/about/AboutCommand.java | 76 ++++++ .../modules/other/about/AboutModule.java | 244 ++++++++++++++++++ src/main/resources/config.yml | 1 + 3 files changed, 321 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java new file mode 100644 index 0000000..ed53b19 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java @@ -0,0 +1,76 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.about; + +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.i18n.I18n; + + +@CommandInfo (name = "about") +public class AboutCommand extends Command +{ + @Override + protected void run() + { + final AboutModule about = UR.module(AboutModule.class); + + CommandUtils.displaySeparator(sender); + + info(I.t("{yellow}{0} - version {1}", about.getPluginName(), about.getVersion()) + " - " + about.getStability().toString().toLowerCase()); + info(I.t("Plugin made with love by {0}.", about.getFormattedAuthors())); + + if (about.getGitVersion() != null) + { + info(I.t("Build number: {0}.", about.getGitVersion())); + } + else + { + info(I.t("Build number not available.")); + } + + // Translation + + info(I.t("{aqua}------ Translations ------")); + info(I.t("Current language: {0} (translated by {1}).", I18n.getPrimaryLocale(), I18n.getTranslationTeam(I18n.getPrimaryLocale()))); + info(I.t("Fallback language: {0} (translated by {1}).", I18n.getFallbackLocale(), I18n.getTranslationTeam(I18n.getFallbackLocale()))); + info(I.t("{aqua}------ License ------")); + info(I.t("Published under the CeCILL-B License.")); + + CommandUtils.displaySeparator(sender); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java new file mode 100644 index 0000000..d80e7f6 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java @@ -0,0 +1,244 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.about; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.io.IOException; +import java.net.URL; +import java.util.Collections; +import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + + +@ModuleInfo ( + name = "About", + description = "Provides information about this plugin." +) +public class AboutModule extends UHModule +{ + private String shortName = "UHC Reloaded"; + private String version = null; + private Stability stability = null; + private String gitVersion = null; + private String authors = null; + + @Override + protected void onEnable() + { + computeVersion(); + computeGitVersion(); + computeFormattedAuthors(); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(AboutCommand.class); + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + if (UR.module(GameModule.class).getPhase() == GamePhase.WAIT) + { + injector.injectLines( + SidebarInjector.SidebarPriority.VERY_BOTTOM, + true, false, + ChatColor.GRAY + shortName + " " + version + ); + + if (getVersion() != null) + { + injector.injectLines( + SidebarInjector.SidebarPriority.VERY_BOTTOM, + false, + ChatColor.GRAY + gitVersion.substring(0, 8) + ); + } + + if (stability != Stability.STABLE) + { + switch (stability) + { + case BETA: + injector.injectLines( + SidebarInjector.SidebarPriority.VERY_BOTTOM, + true, + I.t("{yellow}Beta version") + ); + break; + + case ALPHA: + injector.injectLines( + SidebarInjector.SidebarPriority.VERY_BOTTOM, + true, + I.t("{red}Development version") + ); + break; + } + } + } + } + + public String getPluginName() + { + return UR.get().getDescription().getDescription(); + } + + public String getShortPluginName() + { + return shortName; + } + + public String getVersion() + { + return version; + } + + public Stability getStability() + { + return stability; + } + + public String getGitVersion() + { + return gitVersion; + } + + public List<String> getAuthors() + { + return UR.get().getDescription().getAuthors(); + } + + public String getFormattedAuthors() + { + return authors; + } + + private void computeGitVersion() + { + try + { + final Class<? extends UHCReloaded> clazz = UR.get().getClass(); + final String className = clazz.getSimpleName() + ".class"; + final String classPath = clazz.getResource(className).toString(); + + if (classPath.startsWith("jar")) // Class from JAR + { + final String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + + "/META-INF/MANIFEST.MF"; + final Manifest manifest = new Manifest(new URL(manifestPath).openStream()); + final Attributes attr = manifest.getMainAttributes(); + + gitVersion = attr.getValue("Git-Commit"); + } + } + catch (IOException e) + { + // Build not available. + } + } + + private void computeFormattedAuthors() + { + final StringBuilder authors = new StringBuilder(); + final List<String> listAuthors = getAuthors(); + + for (final String author : listAuthors) + { + if (!author.equals(listAuthors.get(0))) + { + if (author.equals(listAuthors.get(listAuthors.size() - 1))) + { + /// The "and" in the authors list (like "Amaury Carrade, azenet and João Roda") + authors.append(" ").append(I.tc("authors_list", "and")).append(" "); + } + else + { + authors.append(", "); + } + } + + authors.append(author); + } + + this.authors = authors.toString(); + } + + private void computeVersion() + { + final String[] versionParts = UR.get().getDescription().getVersion().split("-", 2); + + version = versionParts[0]; + + if (versionParts.length >= 2) + { + switch (versionParts[1].trim().toLowerCase()) + { + case "dev": + case "alpha": + stability = Stability.ALPHA; + break; + + case "beta": + case "bêta": + case "pre": + case "prerelease": + case "pre-release": + stability = Stability.BETA; + break; + + default: + stability = Stability.STABLE; + } + } + } + + public enum Stability + { + STABLE, BETA, ALPHA + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 86e94d4..b0254f7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,6 +23,7 @@ modules: "border-walls": true "border-warning": true "border-check": true + "other-about": true # The worlds to use as main worlds. # If not found, fallbacks on the first world found with the right type. From 1ec560e3a30159caa74917fbfc818edc3079bdfc Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 23 Nov 2018 13:31:43 +0100 Subject: [PATCH 06/91] Added players loader module. - NEW: Added module for players loader command. --- .../amaury/UHCReloaded/UHCReloaded.java | 1 + .../UHCReloaded/game/UHGameManager.java | 2 +- .../playersLoader/LoadPlayersCommand.java | 83 ++++++++ .../playersLoader/PlayersLoaderModule.java | 55 ++++++ .../old/commands/commands/UHRootCommand.java | 2 - .../commands/commands/uh/UHAboutCommand.java | 179 ------------------ .../commands/uh/UHLoadPlayersCommand.java | 104 ---------- .../commands/uh/UHSpectatorsCommand.java | 2 +- .../builder/TeamBuilderStepPlayersGUI.java | 2 +- .../old/teams/editor/TeamEditMembersGUI.java | 2 +- .../scoreboard/SidebarPlayerCache.java | 2 +- .../misc => utils}/OfflinePlayersLoader.java | 2 +- src/main/resources/config.yml | 1 + 13 files changed, 146 insertions(+), 291 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/misc => utils}/OfflinePlayersLoader.java (99%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 11a4b50..c838130 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -45,6 +45,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index f26d263..bda7080 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -38,7 +38,7 @@ import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.old.task.FireworksOnWinnersTask; import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java new file mode 100644 index 0000000..64ef8d1 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java @@ -0,0 +1,83 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.playersLoader; + +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +import java.util.Arrays; + +@CommandInfo ( + name = "load-players", + usageParameters = "<player1> [player2] [player3] […]", + aliases = {"loadplayers", "load-player", "loadplayer"} +) +public class LoadPlayersCommand extends Command +{ + @Override + protected void run() + { + if (!Bukkit.getOnlineMode()) + { + sender.sendMessage(I.t("{ce}You cannot load unknown players in offline mode, sorry.")); + return; + } + + if (args.length == 0) + { + /// Error returned if one calls /uh loadplayers without arguments. + sender.sendMessage(I.t("{ce}You need to provide at least one player name.")); + return; + } + + /// Message displayed when the /uh loadplayers command is used, as the execution may take some time. + info(I.t("{cst}Loading players...")); + + final CommandSender fSender = sender; + + OfflinePlayersLoader.loadPlayers( + Arrays.asList(args), + addedPlayers -> fSender.sendMessage(I.tn("{cs}Loaded {0} player successfully.", "{cs}Loaded {0} players successfully.", addedPlayers.size())), + notFound -> { + /// Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). + fSender.sendMessage(I.tn("{ce}{0} player is missing: {1}.", "{ce}{0} players are missing: {1}.", notFound.size(), notFound.size(), StringUtils.join(notFound, ", "))); + } + ); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java new file mode 100644 index 0000000..8196416 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java @@ -0,0 +1,55 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.playersLoader; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.commands.Command; + +import java.util.Collections; +import java.util.List; + +@ModuleInfo ( + name = "Players Loader", + description = "Loads player into the server even if they never came before, so you can add them to teams and such. " + + "An interface to the built-in players loader." +) +public class PlayersLoaderModule extends UHModule +{ + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(LoadPlayersCommand.class); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 905558f..8a8be53 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -71,8 +71,6 @@ public UHRootCommand(UHCReloaded plugin) registerSubCommand(new UHTPCommand(p)); registerSubCommand(new UHInfosCommand(p)); registerSubCommand(new UHRulesCommand(p)); - registerSubCommand(new UHLoadPlayersCommand()); - registerSubCommand(new UHAboutCommand(p)); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java deleted file mode 100644 index eb50f53..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHAboutCommand.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.i18n.I18n; -import org.bukkit.command.CommandSender; - -import java.io.IOException; -import java.net.URL; -import java.util.Collections; -import java.util.List; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - - -/** - * This command prints some informations about the plugin and the translation. - * - * Usage: /uh about - */ -@Command (name = "about") -public class UHAboutCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHAboutCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - CommandUtils.displaySeparator(sender); - sender.sendMessage(I.t("{yellow}{0} - version {1}", p.getDescription().getDescription(), p.getDescription().getVersion())); - - // Authors - - final StringBuilder authors = new StringBuilder(); - final List<String> listAuthors = p.getDescription().getAuthors(); - - for (final String author : listAuthors) - { - if (!author.equals(listAuthors.get(0))) - { - if (author.equals(listAuthors.get(listAuthors.size() - 1))) - { - /// The "and" in the authors list (like "Amaury Carrade, azenet and João Roda") - authors.append(" ").append(I.tc("authors_list", "and")).append(" "); - } - else - { - authors.append(", "); - } - } - - authors.append(author); - } - sender.sendMessage(I.t("Plugin made with love by {0}.", authors.toString())); - - // Build number - - String build = null; - try - { - Class<? extends UHCReloaded> clazz = p.getClass(); - String className = clazz.getSimpleName() + ".class"; - String classPath = clazz.getResource(className).toString(); - if (classPath.startsWith("jar")) // Class from JAR - { - String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + - "/META-INF/MANIFEST.MF"; - Manifest manifest = new Manifest(new URL(manifestPath).openStream()); - Attributes attr = manifest.getMainAttributes(); - - build = attr.getValue("Git-Commit"); - } - } - catch (IOException e) - { - // Build not available. - } - - if (build != null) - { - sender.sendMessage(I.t("Build number: {0}.", build)); - } - else - { - sender.sendMessage(I.t("Build number not available.")); - } - - // Translation - - sender.sendMessage(I.t("{aqua}------ Translations ------")); - sender.sendMessage(I.t("Current language: {0} (translated by {1}).", I18n.getPrimaryLocale(), I18n.getTranslationTeam(I18n.getPrimaryLocale()))); - sender.sendMessage(I.t("Fallback language: {0} (translated by {1}).", I18n.getFallbackLocale(), I18n.getTranslationTeam(I18n.getFallbackLocale()))); - sender.sendMessage(I.t("{aqua}------ License ------")); - sender.sendMessage(I.t("Published under the CeCILL-B License.")); - - CommandUtils.displaySeparator(sender); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh about {ci}: informations about the plugin and the translation.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java deleted file mode 100644 index e11ca37..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHLoadPlayersCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; -import fr.zcraft.zlib.components.i18n.I; -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -@Command(name = "loadplayers") -public class UHLoadPlayersCommand extends AbstractCommand -{ - @Override - public void run(final CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!Bukkit.getOnlineMode()) - { - sender.sendMessage(I.t("{ce}You cannot load unknown players in offline mode, sorry.")); - return; - } - - if (args.length == 0) - { - /// Error returned if one calls /uh loadplayers without arguments. - sender.sendMessage(I.t("{ce}You need to provide at least one player name.")); - return; - } - - /// Message displayed when the /uh loadplayers command is used, as the execution may take some time. - sender.sendMessage(I.t("{cst}Loading players...")); - - OfflinePlayersLoader.loadPlayers( - Arrays.asList(args), - addedPlayers -> sender.sendMessage(I.tn("{cs}Loaded {0} player successfully.", "{cs}Loaded {0} players successfully.", addedPlayers.size())), - notFound -> { - /// Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). - sender.sendMessage(I.tn("{ce}{0} player is missing: {1}.", "{ce}{0} players are missing: {1}.", notFound.size(), notFound.size(), StringUtils.join(notFound, ", "))); - } - ); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh loadplayers <pseudo> [pseudo] ... {ci}: loads the given players in the server so they can be added to teams even if they never logged in.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java index f0b2f86..b012e15 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java @@ -37,7 +37,7 @@ import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java index ffb4a20..ac58e2b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java @@ -33,7 +33,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java index b4f516e..c2478ac 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.teams.editor; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; import fr.zcraft.zlib.components.gui.ExplorerGui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java index e8055f2..ea54e30 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java @@ -31,7 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.scoreboard; -import eu.carrade.amaury.UHCReloaded.old.misc.OfflinePlayersLoader; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java index 3e2d437..9730d3d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/OfflinePlayersLoader.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.misc; +package eu.carrade.amaury.UHCReloaded.utils; import fr.zcraft.zlib.components.worker.Worker; import fr.zcraft.zlib.components.worker.WorkerCallback; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b0254f7..2424cd1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,6 +23,7 @@ modules: "border-walls": true "border-warning": true "border-check": true + "other-playersLoader": true "other-about": true # The worlds to use as main worlds. From 300d66ab2b4a0297ee69cb96dcf87953fd65c6b6 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 5 Dec 2018 02:47:33 +0100 Subject: [PATCH 07/91] Game start, cages, auto-spawns-generation. * NEW: Finished game startup proccess. * NEW: Added back cages in their own module. * NEW: The spawn points are automatically generated if some are missing when the game starts. --- .../amaury/UHCReloaded/UHCReloaded.java | 21 +- .../carrade/amaury/UHCReloaded/UHConfig.java | 12 +- .../amaury/UHCReloaded/core/ModuleInfo.java | 12 +- .../amaury/UHCReloaded/core/ModuleLogger.java | 26 + .../UHCReloaded/game/UHGameManager.java | 393 +++++++------ .../beginning/cages}/Cage.java | 55 +- .../modules/beginning/cages/CagesModule.java | 105 ++++ .../modules/beginning/cages/Config.java | 58 ++ .../UHCReloaded/modules/core/game/Config.java | 31 +- .../modules/core/game/GameBeginning.java | 224 ++++++++ .../modules/core/game/GameModule.java | 518 +++++++++++++++++- .../core/game/commands/StartCommand.java | 52 +- .../{ => game}/GamePhaseChangedEvent.java | 2 +- .../start/AfterTeleportationPhaseEvent.java | 55 ++ .../start/BeforeTeleportationPhaseEvent.java | 56 ++ ...rAboutToBeTeleportedToSpawnPointEvent.java | 80 +++ .../start/PlayerSpawnPointSelectedEvent.java | 81 +++ .../PlayerTeleportedToSpawnPointEvent.java | 80 +++ .../game/teleporter/TeleportationMode.java | 47 ++ .../teleporter}/TeleportationRunnable.java | 2 +- .../core/game/teleporter}/Teleporter.java | 110 +--- .../modules/core/spawns/SpawnsModule.java | 95 +++- .../core/spawns/commands/SpawnsCommand.java | 10 +- .../RandomSpawnPointsGenerator.java | 2 +- .../core/spectators/SpectatorsModule.java | 64 +++ .../managers}/SPlusSpectatorsManager.java | 4 +- .../managers}/SpectatorsManager.java | 5 +- .../managers}/VanillaSpectatorsManager.java | 6 +- .../old/listeners/BeforeGameListener.java | 12 +- .../old/listeners/CraftingListener.java | 84 ++- .../old/listeners/GameListener.java | 222 ++++---- .../old/listeners/GameplayListener.java | 10 +- .../old/listeners/SpawnsListener.java | 135 +---- .../UHCReloaded/scoreboard/GameSidebar.java | 201 ++++--- .../UHCReloaded/utils/EntitiesUtils.java | 76 +++ .../amaury/UHCReloaded/utils/UHSound.java | 97 ++++ src/main/resources/config.yml | 1 + 37 files changed, 2217 insertions(+), 827 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{game => modules/beginning/cages}/Cage.java (86%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/{ => game}/GamePhaseChangedEvent.java (97%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{game => modules/core/game/teleporter}/TeleportationRunnable.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{game => modules/core/game/teleporter}/Teleporter.java (70%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/spectators => modules/core/spectators/managers}/SPlusSpectatorsManager.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/spectators => modules/core/spectators/managers}/SpectatorsManager.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/spectators => modules/core/spectators/managers}/VanillaSpectatorsManager.java (91%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index c838130..04265fa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -39,24 +39,25 @@ import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesManagerModule; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; import eu.carrade.amaury.UHCReloaded.old.misc.*; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import eu.carrade.amaury.UHCReloaded.old.spectators.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager; import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; @@ -168,7 +169,9 @@ public void onEnable() SpawnsModule.class, // Manages the spawn points and teleportation. // Must be loaded before the game-related modules. - GameModule.class // Manages the game progression. + GameModule.class, // Manages the game progression. + + SpectatorsModule.class // Manages the spectators. ); @@ -450,13 +453,15 @@ public final void onWorldsLoaded(final WorldLoadEvent e) if (!worldsLoaded) onEnableWhenWorldsAvailable(); } - @EventHandler + @EventHandler (priority = EventPriority.LOWEST) public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { - PluginLogger.info("Game phase changed to {0}.", ev.getNewPhase()); - switch (ev.getNewPhase()) { + case STARTING: + loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_STARTING); + break; + case IN_GAME: loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_START); break; @@ -583,8 +588,6 @@ private World setDefaultWorld(final World.Environment environment, final String - - /** * Returns the team manager. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index ffa93a0..e8f1479 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -1,15 +1,9 @@ package eu.carrade.amaury.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.game.Cage; +import eu.carrade.amaury.UHCReloaded.modules.beginning.cages.Cage; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.configuration.Configuration; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationList; -import fr.zcraft.zlib.components.configuration.ConfigurationMap; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; +import fr.zcraft.zlib.components.configuration.*; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.inventory.meta.BannerMeta; @@ -604,7 +598,7 @@ static public class SoundSection extends ConfigurationSection static { - ConfigurationValueHandlers.registerHandlers(TeamManager.class); +// ConfigurationValueHandlers.registerHandlers(TeamManager.class); ConfigurationValueHandlers.registerHandlers(UHSound.class); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index 4797487..35fd78c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -106,19 +106,19 @@ enum ModuleLoadTime */ POST_WORLD, + /** + * Loads the module when the game phase is set to STARTING, i.e. when the /uh start command + * is used. + */ + ON_GAME_STARTING, + /** * Loads the module when the game starts. - * - * Modules loaded this late cannot register new commands. You must use a load time before - * {@link #POST_WORLD} (included) to do so. */ ON_GAME_START, /** * Loads the module when the game ends. - * - * Modules loaded this late cannot register new commands. You must use a load time before - * {@link #POST_WORLD} (included) to do so. */ ON_GAME_END } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index 7d5c3c6..e0182b9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -33,7 +33,11 @@ */ package eu.carrade.amaury.UHCReloaded.core; +import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.text.RawMessage; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -105,4 +109,26 @@ public void error(String message, Object... args) { log(Level.SEVERE, message, args); } + + public void broadcastAdministrative(String message) + { + // TODO use permissions + Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> { + player.sendMessage(""); + player.sendMessage(message); + }); + + info(message); + } + + public void broadcastAdministrative(RawText message) + { + // TODO use permissions + Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> { + player.sendMessage(""); + RawMessage.send(player, message); + }); + + info(message.toPlainText()); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index bda7080..415a5fa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -33,17 +33,14 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.old.task.FireworksOnWinnersTask; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; @@ -52,30 +49,12 @@ import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.ActionBar; import fr.zcraft.zlib.tools.text.RawMessage; -import fr.zcraft.zlib.tools.text.Titles; -import org.bukkit.Achievement; -import org.bukkit.Bukkit; -import org.bukkit.Difficulty; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Queue; -import java.util.Random; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; @@ -93,7 +72,7 @@ public class UHGameManager private final UHSound DEATH_SOUND; private UHCReloaded p; - private TeamManager tm; +// private TeamManager tm; private Random random; private Boolean damagesEnabled = false; @@ -101,7 +80,7 @@ public class UHGameManager private Set<String> players = new HashSet<>(); // Will be converted to UUID when a built-in API for name->UUID conversion will be available private Set<UUID> alivePlayers = new HashSet<>(); - private Set<UHTeam> aliveTeams = new HashSet<>(); +// private Set<UHTeam> aliveTeams = new HashSet<>(); private Set<UUID> spectators = new HashSet<>(); private Map<UUID, Location> deathLocations = new HashMap<>(); @@ -131,7 +110,7 @@ public class UHGameManager public UHGameManager(UHCReloaded plugin) { this.p = plugin; - this.tm = p.getTeamManager(); +// this.tm = p.getTeamManager(); this.random = new Random(); @@ -247,63 +226,63 @@ public void start(final CommandSender sender, final Boolean slow, Boolean ignore /* ** Initialization of the teams ** */ alivePlayers.clear(); - aliveTeams.clear(); +// aliveTeams.clear(); alivePlayersCount = 0; aliveTeamsCount = 0; - // Stores the teams created on-the-fly, to unregister them if something bad happens. - final Set<UHTeam> onTheFlyTeams = new HashSet<>(); - - // If there isn't any team, we add all players (startup spectators excluded) to a new solo team. - if (tm.getTeams().isEmpty()) - { - gameWithTeams = false; - - Bukkit.getOnlinePlayers().stream().filter(player -> !spectators.contains(player.getUniqueId())).forEach(player -> - { - final UHTeam team = new UHTeam(player.getName(), RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); - team.addPlayer(player, true); - - tm.addTeam(team); - onTheFlyTeams.add(team); - }); - } - - // Else, every non-startup-spectator out of any team player is added to a solo team. - else - { - gameWithTeams = true; - - Bukkit.getOnlinePlayers().stream() - .filter(player -> !spectators.contains(player.getUniqueId())) - .filter(player -> tm.getTeamForPlayer(player) == null) - .forEach(player -> - { - // We need an unique name for the team. - String teamName = player.getName(); - while (tm.isTeamRegistered(teamName)) - { - teamName = player.getName() + " " + random.nextInt(1000000); - } - - final UHTeam team = new UHTeam(teamName, RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); - - team.addPlayer(player, true); - - tm.addTeam(team); - onTheFlyTeams.add(team); - }); - } - - - /* ** Initialization of the players ** */ - - tm.getTeams().forEach( - team -> team.getPlayers().stream() - .map(OfflinePlayer::getUniqueId) - .filter(player -> !spectators.contains(player)) - .forEach(player -> alivePlayers.add(player)) - ); +// // Stores the teams created on-the-fly, to unregister them if something bad happens. +// final Set<UHTeam> onTheFlyTeams = new HashSet<>(); +// +// // If there isn't any team, we add all players (startup spectators excluded) to a new solo team. +// if (tm.getTeams().isEmpty()) +// { +// gameWithTeams = false; +// +// Bukkit.getOnlinePlayers().stream().filter(player -> !spectators.contains(player.getUniqueId())).forEach(player -> +// { +// final UHTeam team = new UHTeam(player.getName(), RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); +// team.addPlayer(player, true); +// +// tm.addTeam(team); +// onTheFlyTeams.add(team); +// }); +// } +// +// // Else, every non-startup-spectator out of any team player is added to a solo team. +// else +// { +// gameWithTeams = true; +// +// Bukkit.getOnlinePlayers().stream() +// .filter(player -> !spectators.contains(player.getUniqueId())) +// .filter(player -> tm.getTeamForPlayer(player) == null) +// .forEach(player -> +// { +// // We need an unique name for the team. +// String teamName = player.getName(); +// while (tm.isTeamRegistered(teamName)) +// { +// teamName = player.getName() + " " + random.nextInt(1000000); +// } +// +// final UHTeam team = new UHTeam(teamName, RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); +// +// team.addPlayer(player, true); +// +// tm.addTeam(team); +// onTheFlyTeams.add(team); +// }); +// } +// +// +// /* ** Initialization of the players ** */ +// +// tm.getTeams().forEach( +// team -> team.getPlayers().stream() +// .map(OfflinePlayer::getUniqueId) +// .filter(player -> !spectators.contains(player)) +// .forEach(player -> alivePlayers.add(player)) +// ); updateAliveCache(); @@ -347,13 +326,13 @@ public void start(final CommandSender sender, final Boolean slow, Boolean ignore p.getMOTDManager().updateMOTDDuringStart(); - /* ** Removes the teams action bar (if any) ** */ - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - { - tm.getTeams().stream() - .flatMap(team -> team.getPlayers().stream()) - .forEach(player -> ActionBar.removeMessage(player.getUniqueId(), true)); - } +// /* ** Removes the teams action bar (if any) ** */ +// if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) +// { +// tm.getTeams().stream() +// .flatMap(team -> team.getPlayers().stream()) +// .forEach(player -> ActionBar.removeMessage(player.getUniqueId(), true)); +// } /* ** Initialization of the spectator mode ** */ @@ -370,37 +349,37 @@ public void start(final CommandSender sender, final Boolean slow, Boolean ignore List<Location> spawnPoints = new ArrayList<>(); // (p.getSpawnsManager().getSpawnPoints()); Collections.shuffle(spawnPoints); - Queue<Location> unusedTP = new ArrayDeque<>(spawnPoints); - - tm.getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> - { - if (!ignoreTeams && gameWithTeams) - { - final Location teamSpawn = unusedTP.poll(); - final Cage cage = Cage.createInstanceForTeamIfEnabled(team, teamSpawn); - - p.getDynmapIntegration().showSpawnLocation(team, teamSpawn); - - team.getPlayersUUID().forEach(player -> - { - teleporter.setSpawnForPlayer(player, teamSpawn); - if (cage != null) teleporter.setCageForPlayer(player, cage); - }); - } - else - { - team.getPlayersUUID().forEach(player -> - { - final Location playerSpawn = unusedTP.poll(); - final Cage cage = Cage.createInstanceForTeamIfEnabled(team, playerSpawn); - - teleporter.setSpawnForPlayer(player, playerSpawn); - if (cage != null) teleporter.setCageForPlayer(player, cage); - - p.getDynmapIntegration().showSpawnLocation(Bukkit.getOfflinePlayer(player), playerSpawn); - }); - } - }); +// Queue<Location> unusedTP = new ArrayDeque<>(spawnPoints); +// +// tm.getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> +// { +// if (!ignoreTeams && gameWithTeams) +// { +// final Location teamSpawn = unusedTP.poll(); +// final Cage cage = Cage.createInstanceForTeamIfEnabled(team, teamSpawn); +// +// p.getDynmapIntegration().showSpawnLocation(team, teamSpawn); +// +// team.getPlayersUUID().forEach(player -> +// { +// teleporter.setSpawnForPlayer(player, teamSpawn); +// if (cage != null) teleporter.setCageForPlayer(player, cage); +// }); +// } +// else +// { +// team.getPlayersUUID().forEach(player -> +// { +// final Location playerSpawn = unusedTP.poll(); +// final Cage cage = Cage.createInstanceForTeamIfEnabled(team, playerSpawn); +// +// teleporter.setSpawnForPlayer(player, playerSpawn); +// if (cage != null) teleporter.setCageForPlayer(player, cage); +// +// p.getDynmapIntegration().showSpawnLocation(Bukkit.getOfflinePlayer(player), playerSpawn); +// }); +// } +// }); if (slow) { @@ -655,7 +634,7 @@ private void finalizeStart() { p.getFreezer().setGlobalFreezeState(false); - teleporter.cleanup(); +// teleporter.cleanup(); gameStarted = true; gameFinished = false; @@ -706,22 +685,22 @@ public boolean isSlowStartInProgress() */ public void updateAliveCache() { - // Alive teams - aliveTeams.clear(); - for (UHTeam t : tm.getTeams()) - { - for (UUID pid : t.getPlayersUUID()) - { - if (!this.isPlayerDead(pid)) aliveTeams.add(t); - } - } - - // Counters - this.alivePlayersCount = alivePlayers.size(); - this.aliveTeamsCount = aliveTeams.size(); - - if (isGameRunning()) - p.getMOTDManager().updateMOTDDuringGame(); +// // Alive teams +// aliveTeams.clear(); +// for (UHTeam t : tm.getTeams()) +// { +// for (UUID pid : t.getPlayersUUID()) +// { +// if (!this.isPlayerDead(pid)) aliveTeams.add(t); +// } +// } +// +// // Counters +// this.alivePlayersCount = alivePlayers.size(); +// this.aliveTeamsCount = aliveTeams.size(); +// +// if (isGameRunning()) +// p.getMOTDManager().updateMOTDDuringGame(); } /** @@ -911,7 +890,7 @@ public boolean hasDeathLocation(Player player) public void addStartupSpectator(OfflinePlayer player) { spectators.add(player.getUniqueId()); - tm.removePlayerFromTeam(player); +// tm.removePlayerFromTeam(player); } /** @@ -1075,70 +1054,70 @@ public void finishGame() } // There's only one team. - UHTeam winnerTeam = p.getGameManager().getAliveTeams().iterator().next(); - Set<OfflinePlayer> listWinners = winnerTeam.getPlayers(); - - if (UHConfig.FINISH.MESSAGE.get()) - { - if (isGameWithTeams()) - { - StringBuilder winners = new StringBuilder(); - int j = 0; - - for (OfflinePlayer winner : listWinners) - { - if (j != 0) - { - if (j == listWinners.size() - 1) - { - /// The "and" in the winners players list (like "player1, player2 and player3"). - winners.append(" ").append(I.tc("winners_list", "and")).append(" "); - } - else - { - winners.append(", "); - } - } - - winners.append(winner.getName()); - j++; - } - - p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", winners.toString(), winnerTeam.getDisplayName())); - } - else - { - p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", winnerTeam.getName())); - } - } - - if (UHConfig.FINISH.TITLE.get()) - { - final String title; - final String subtitle; - - if (isGameWithTeams()) - { - /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). - title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); - /// The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). - subtitle = I.t("{green}This team wins the game!", winnerTeam.getDisplayName()); - } - else - { - /// The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). - title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); - /// The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). - subtitle = I.t("{green}wins the game!", winnerTeam.getDisplayName()); - } - - Titles.broadcastTitle(5, 142, 21, title, subtitle); - } - - if (UHConfig.FINISH.FIREWORKS.ENABLED.get()) - { - new FireworksOnWinnersTask(listWinners).runTaskTimer(p, 0L, 15L); - } +// UHTeam winnerTeam = p.getGameManager().getAliveTeams().iterator().next(); +// Set<OfflinePlayer> listWinners = winnerTeam.getPlayers(); +// +// if (UHConfig.FINISH.MESSAGE.get()) +// { +// if (isGameWithTeams()) +// { +// StringBuilder winners = new StringBuilder(); +// int j = 0; +// +// for (OfflinePlayer winner : listWinners) +// { +// if (j != 0) +// { +// if (j == listWinners.size() - 1) +// { +// /// The "and" in the winners players list (like "player1, player2 and player3"). +// winners.append(" ").append(I.tc("winners_list", "and")).append(" "); +// } +// else +// { +// winners.append(", "); +// } +// } +// +// winners.append(winner.getName()); +// j++; +// } +// +// p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", winners.toString(), winnerTeam.getDisplayName())); +// } +// else +// { +// p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", winnerTeam.getName())); +// } +// } +// +// if (UHConfig.FINISH.TITLE.get()) +// { +// final String title; +// final String subtitle; +// +// if (isGameWithTeams()) +// { +// /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). +// title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); +// /// The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). +// subtitle = I.t("{green}This team wins the game!", winnerTeam.getDisplayName()); +// } +// else +// { +// /// The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). +// title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); +// /// The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). +// subtitle = I.t("{green}wins the game!", winnerTeam.getDisplayName()); +// } +// +// Titles.broadcastTitle(5, 142, 21, title, subtitle); +// } +// +// if (UHConfig.FINISH.FIREWORKS.ENABLED.get()) +// { +// new FireworksOnWinnersTask(listWinners).runTaskTimer(p, 0L, 15L); +// } } /** @@ -1156,10 +1135,10 @@ public Set<String> getPlayers() * * @return The set. */ - public Set<UHTeam> getAliveTeams() - { - return aliveTeams; - } +// public Set<UHTeam> getAliveTeams() +// { +// return aliveTeams; +// } /** * Returns a list of the currently alive players. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java index 449044f..489ef0a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Cage.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.game; +package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; +import fr.zcraft.zteams.ZTeam; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -176,9 +176,9 @@ private void setBlock(final Location location, final Material material, final Ma /** * Builds the cage. */ - public void build() + public boolean build() { - if (built) return; + if (built) return false; final int externalRadius = radius + 1; final int xMin = baseLocation.getBlockX() - externalRadius; @@ -248,6 +248,8 @@ public void build() setBlock(new Location(world, x, baseLocation.getBlockY() + internalHeight, z), ceilingMaterial, ceilingMaterialData); built = true; + + return true; } /** @@ -255,7 +257,7 @@ public void build() */ public void destroy() { - for (Map.Entry<Location, SimpleBlock> entry : blocksBuilt.entrySet()) + for (final Map.Entry<Location, SimpleBlock> entry : blocksBuilt.entrySet()) { final Block block = entry.getKey().getBlock(); final SimpleBlock originalBlock = entry.getValue(); @@ -273,30 +275,30 @@ public void destroy() /** * Creates a Cage instance for the given team. * - * @param team The team - * @param location The spawn location + * @param team The team. Can be null (fallbacks to white if a color is needed). + * @param location Where the cage should be built. * * @return A Cage */ - static public Cage createInstanceForTeam(final UHTeam team, final Location location) + static public Cage createInstanceForTeam(final ZTeam team, final Location location) { final Material cageMaterial; final Byte cageData; - switch (UHConfig.START.SLOW.CAGES.TYPE.get()) + switch (Config.TYPE.get()) { case TEAM_COLOR_TRANSPARENT: cageMaterial = Material.STAINED_GLASS; - cageData = ColorsUtils.chat2Dye(team.getColorOrWhite().toChatColor()).getWoolData(); + cageData = ColorsUtils.chat2Dye(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE).getWoolData(); break; case TEAM_COLOR_SOLID: cageMaterial = Material.STAINED_CLAY; - cageData = ColorsUtils.chat2Dye(team.getColorOrWhite().toChatColor()).getWoolData(); + cageData = ColorsUtils.chat2Dye(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE).getWoolData(); break; case CUSTOM: - cageMaterial = UHConfig.START.SLOW.CAGES.CUSTOM_BLOCK.get(); + cageMaterial = Config.CUSTOM_BLOCK.get(); cageData = null; break; @@ -306,39 +308,18 @@ static public Cage createInstanceForTeam(final UHTeam team, final Location locat cageData = null; } - final Cage cage = new Cage( - location, - UHConfig.START.SLOW.CAGES.BUILD_CEILING.get(), - UHConfig.START.SLOW.CAGES.VISIBLE_WALLS.get() - ); + final Cage cage = new Cage(location, Config.BUILD_CEILING.get(), Config.VISIBLE_WALLS.get()); if (cageMaterial != null) // Should always be true { cage.setCustomMaterial(cageMaterial, cageData != null ? cageData : 0); - cage.setInternalHeight(UHConfig.START.SLOW.CAGES.HEIGHT.get()); - cage.setRadius(UHConfig.START.SLOW.CAGES.RADIUS.get()); + cage.setInternalHeight(Config.HEIGHT.get()); + cage.setRadius(Config.RADIUS.get()); } return cage; } - /** - * Creates a Cage instance for the given team if cages are enabled. - * - * @param team The team. - * @param location The spawn location. - * - * @return A Cage, or null if cages are disabled. - */ - static public Cage createInstanceForTeamIfEnabled(final UHTeam team, final Location location) - { - if (UHConfig.START.SLOW.CAGES.ENABLED.get()) - { - return createInstanceForTeam(team, location); - } - else return null; - } - /** * Cage type, enum used for the configuration diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java new file mode 100644 index 0000000..d99de30 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java @@ -0,0 +1,105 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerAboutToBeTeleportedToSpawnPointEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.HashMap; +import java.util.Map; + + +@ModuleInfo ( + name = "Cages", + description = "Puts players in cages instead of floating in the air, during the startup process", + when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, + settings = Config.class +) +public class CagesModule extends UHModule +{ + private Map<Location, Cage> cages = new HashMap<>(); + + + @EventHandler (priority = EventPriority.MONITOR) + public void onPlayerSpawnSelected(PlayerSpawnPointSelectedEvent ev) + { + final Location spawn = cloneAndNormalize(ev.getSpawnPoint()); + cages.putIfAbsent(spawn, Cage.createInstanceForTeam(ZTeams.get().getTeamForPlayer(ev.getPlayer()), spawn)); + } + + @EventHandler + public void onPlayerAboutToBeTeleportedToSpawn(PlayerAboutToBeTeleportedToSpawnPointEvent ev) + { + final Cage cage = cages.get(cloneAndNormalize(ev.getSpawnPoint())); + + if (cage != null) cage.build(); + } + + @EventHandler + public void onPlayerTeleportedToSpawn(PlayerTeleportedToSpawnPointEvent ev) + { + final Location normalizedLocation = cloneAndNormalize(ev.getSpawnPoint()); + + // We only remove the fly if there is a cage for that player. + if (cages.containsKey(normalizedLocation)) + { + ev.getPlayer().setFlying(false); + ev.getPlayer().setAllowFlight(false); + + // We slightly fix the player location so he is at the center of the platform. + ev.getPlayer().teleport(normalizedLocation.add(.5, .5, .5)); + } + } + + @EventHandler + public void onGameStarts(GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + cages.forEach((location, nicolas) -> nicolas.destroy()); // Not even sorry. + } + + private Location cloneAndNormalize(final Location location) + { + return new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), 0, 0); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java new file mode 100644 index 0000000..bbadab2 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java @@ -0,0 +1,58 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import org.bukkit.Material; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Cage.CageType> TYPE = item("type", Cage.CageType.TEAM_COLOR_TRANSPARENT); + public static final ConfigurationItem<Material> CUSTOM_BLOCK = item("customBlock", Material.BARRIER); + public static final ConfigurationItem<Boolean> BUILD_CEILING = item("buildCeiling", false); + public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visibleWalls", false); + public static final ConfigurationItem<Integer> RADIUS = item("radius", 2); + public static final ConfigurationItem<Integer> HEIGHT = item("height", 3); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index 3e643c3..fe81003 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -31,11 +31,16 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.game; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; import java.io.File; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + public class Config extends ConfigurationInstance { @@ -44,5 +49,29 @@ public Config(File file) super(file); } - public final static ConfigurationItem<Integer> TOAST = ConfigurationItem.item("toast", 21); + public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 12); // Recommended: 7 or 12 + public static final ConfigurationItem<Boolean> STARTUP_TITLE = item("startup-title", true); + + public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = item("random-color-in-solo-games", true); + + public static final ConfigurationItem<Boolean> BROADCAST_PROGRESS = item("broadcastP-progress", true); + + public static final SlowSection SLOW = section("slow", SlowSection.class); + + public static final class SlowSection extends ConfigurationSection + { + public final ConfigurationItem<Long> DELAY_BETWEEN_TP = item("delay-between-teleportations", 3L); + } + + public static final BeginningSection BEGINNING = section("beginning", BeginningSection.class); + + public static final class BeginningSection extends ConfigurationSection + { + public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); + public final ConfigurationItem<Boolean> DISPLAY_GRACE_PERIOD = item("display-grace-period", true); + public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); + + public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0)); + public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 15, 0)); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java new file mode 100644 index 0000000..befecac --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java @@ -0,0 +1,224 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.core.ZLibComponent; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.ActionBar; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDamageEvent; + +public class GameBeginning extends ZLibComponent implements Listener +{ + /** + * A flag used to disable damages at the beginning of the game to avoid fall damages and early ones. + */ + private boolean inGracePeriod = false; + + /** + * A flag used to disable hostile mobs spawn on the surface a few minutes after the beginning of the game. + */ + private boolean inMobsFreePeriod = false; + + + @EventHandler(priority = EventPriority.LOWEST) + public void onGameStarts(GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + + + /* *** Grace period (damages disabled) *** */ + + TimeDelta grace = Config.BEGINNING.GRACE_PERIOD.get(); + + if (grace.getSeconds() < 15) + { + grace = new TimeDelta(15); + } + + if (Config.BEGINNING.DISPLAY_GRACE_PERIOD.get()) + { + UR.module(GameModule.class).getAliveConnectedPlayers().forEach(player -> + ActionBar.sendPermanentMessage(player, I.t("{green}Grace period {gray}-{green} All damages are disabled"))); + } + + inGracePeriod = true; + + RunTask.later(() -> { + inGracePeriod = false; + UR.module(GameModule.class).getAliveConnectedPlayers().forEach(ActionBar::removeMessage); + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); + }, Config.BEGINNING.GRACE_PERIOD.get().getSeconds() * 20L); + + + /* *** Peace period (PVP disabled) *** */ + + if (Config.BEGINNING.PEACE_PERIOD.get().getSeconds() > 0) + { + setPVP(false); + + RunTask.later(() -> { + setPVP(true); + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); + }, Config.BEGINNING.PEACE_PERIOD.get().getSeconds() * 20L); + } + + else setPVP(true); + + + /* *** Mobs-free period (mobs disabled on surface) *** */ + + if (Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() > 0) + { + inMobsFreePeriod = true; + RunTask.later(() -> inMobsFreePeriod = false, Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() * 20L); + } + } + + + /** + * Used to disable all damages if the game is not started. + */ + @EventHandler + public void onEntityDamage(final EntityDamageEvent ev) + { + if (ev.getEntity() instanceof Player && inGracePeriod) + { + ev.setCancelled(true); + } + } + + /** + * Used to cancel the spawn of hostile entities on the surface only, at the beginning of the game. + */ + @EventHandler + public void onSurfaceCreatureSpawn(CreatureSpawnEvent ev) + { + if (inMobsFreePeriod && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) && EntitiesUtils.isHostile(ev.getEntityType())) + { + // We check the blocs above the entity to see if we only find surface blocks. + final Location spawnLocation = ev.getLocation(); + final World world = spawnLocation.getWorld(); + final int highestBlockY = world.getHighestBlockYAt(spawnLocation); + + final int x = spawnLocation.getBlockX(); + final int z = spawnLocation.getBlockZ(); + + boolean surface = true; + + for (int y = spawnLocation.getBlockY(); y <= highestBlockY; y++) + { + switch (world.getBlockAt(x, y, z).getType()) + { + // Air + case AIR: + + // Trees + case LOG: + case LOG_2: + case LEAVES: + case LEAVES_2: + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + + // Vegetation + case DEAD_BUSH: + case CROPS: + case GRASS: + case LONG_GRASS: + case DOUBLE_PLANT: + case YELLOW_FLOWER: + case VINE: + case SUGAR_CANE_BLOCK: + case BROWN_MUSHROOM: + case RED_MUSHROOM: + + // Nature + case SNOW: + + // Igloos + case SNOW_BLOCK: + + // Villages + case WOOD: + case WOOD_STAIRS: + case SANDSTONE_STAIRS: + case BOOKSHELF: + + // Redstone + case REDSTONE_WIRE: + case REDSTONE_COMPARATOR: + case REDSTONE_COMPARATOR_OFF: + case REDSTONE_COMPARATOR_ON: + case REDSTONE_TORCH_OFF: + case REDSTONE_TORCH_ON: + + // Other blocs frequently used on surface on custom maps + case TORCH: + case RAILS: + case ACTIVATOR_RAIL: + case DETECTOR_RAIL: + case POWERED_RAIL: + break; + + default: + surface = false; + } + + if (!surface) break; + } + + if (surface) ev.setCancelled(true); + } + } + + private void setPVP(final boolean pvp) + { + UR.get().getWorld(World.Environment.NORMAL).setPVP(pvp); + UR.get().getWorld(World.Environment.NETHER).setPVP(pvp); + UR.get().getWorld(World.Environment.THE_END).setPVP(pvp); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 9835b86..36dd0b8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -34,19 +34,36 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.StartCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.*; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.ActionBar; +import fr.zcraft.zlib.tools.text.Titles; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.colors.TeamColor; +import org.bukkit.*; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.scheduler.BukkitRunnable; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; @ModuleInfo ( @@ -58,15 +75,74 @@ ) public class GameModule extends UHModule implements Listener { + /** + * The current game phase (initialized to {@link GamePhase#WAIT} in the + * {@link #onEnable()} method). + */ private GamePhase phase = null; - private final Set<UUID> players = new HashSet<>(); - private final Set<UUID> spectators = new HashSet<>(); + /** + * A list containing the currently alive players. + */ + private final Set<UUID> alivePlayers = new HashSet<>(); + + /** + * A list containing the currently (cached) alive teams. + * Refreshed using the {@link #updateAliveTeams()} method. + */ + private final Set<ZTeam> aliveTeams = new HashSet<>(); + + /** + * List of players connected when the game starts but who will not + * play at all, only spectate. + */ + private final Set<UUID> initialSpectators = new HashSet<>(); + + /** + * {@code true} if there is teams in this game. + */ + private boolean teamsGame = false; + + /** + * {@code true} if the starting process should be slow (for small servers). + */ + private boolean slowMode = false; + + /** + * The teleportation process, to teleport teams as a group or apart. + */ + private TeleportationMode teleportationMode = TeleportationMode.NORMAL; + + /** + * The teleporter used, storing effective spawn points for each player, used + * if we need them after the startup process. + */ + private Teleporter teleporter = null; + + /** + * An internal lock to avoid someone starting the game if the teleportation process + * is still running. + */ + private boolean teleportationProcessLock = false; + + /** + * An internal lock used to avoid multiple starting countdowns at the same time. + */ + private boolean startingCountdownLock = false; + + /** + * An internal counter for the displayed teleportation progress in the action bar (x/y). + */ + private int teleportationProgress = 0; + @Override protected void onEnable() { setPhase(GamePhase.WAIT); + Bukkit.getOnlinePlayers().forEach(this::updatePlayerFlightOptions); + + ZLib.loadComponent(GameBeginning.class); } @Override @@ -82,6 +158,44 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) SidebarInjector.SidebarPriority.VERY_TOP, true, I.tn("{white}{0}{gray} player", "{white}{0}{gray} players", Bukkit.getOnlinePlayers().size(), Bukkit.getOnlinePlayers().size()) ); + + switch (phase) + { + case WAIT: + injector.injectLines( + SidebarInjector.SidebarPriority.TOP, true, + I.t("{gray}Waiting for players...") + ); + break; + + case STARTING: + injector.injectLines( + SidebarInjector.SidebarPriority.TOP, true, + I.t("{gray}The game is starting..."), + I.t("{gray}Please wait.") + ); + break; + } + } + + public Set<UUID> getAlivePlayersUUIDs() + { + return Collections.unmodifiableSet(alivePlayers); + } + + public Set<OfflinePlayer> getAlivePlayers() + { + return alivePlayers.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toSet()); + } + + public Set<Player> getAliveConnectedPlayers() + { + return alivePlayers.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).filter(Player::isOnline).collect(Collectors.toSet()); + } + + public Set<ZTeam> getAliveTeams() + { + return Collections.unmodifiableSet(aliveTeams); } /** @@ -104,7 +218,391 @@ public void setPhase(GamePhase phase) final GamePhase oldPhase = this.phase; this.phase = phase; - Bukkit.getServer().getPluginManager().callEvent(new GamePhaseChangedEvent(oldPhase, phase)); + + log().info("Game phase changed to {0}.", phase); + + RunTask.nextTick(() -> Bukkit.getServer().getPluginManager().callEvent(new GamePhaseChangedEvent(oldPhase, phase))); + } + } + + public void setSlowMode(boolean slowMode) + { + this.slowMode = slowMode; + } + + public boolean isSlowMode() + { + return slowMode; + } + + public void setTeleportationMode(TeleportationMode teleportationMode) + { + this.teleportationMode = teleportationMode; + } + + public TeleportationMode getTeleportationMode() + { + return teleportationMode; + } + + public Teleporter getTeleporter() + { + return teleporter; + } + + /** + * Sets the phase to {@link GamePhase#IN_GAME} after a countdown. + */ + public void start() + { + if (startingCountdownLock) return; + if (phase != GamePhase.STARTING) throw new IllegalStateException("Cannot start the game if not in “starting” phase."); + if (teleportationProcessLock) throw new IllegalStateException("Cannot start the game: the teleportation phase is still running."); + + startingCountdownLock = true; + + final AtomicInteger countdown = new AtomicInteger(Config.COUNTDOWN.get() + 1); + final float[] countdownNotes = new float[] { .75f, .86f, .66f, 1, .5f, .5f, .5f }; + final AtomicInteger countdownIndex = new AtomicInteger(-1); + + RunTask.timer(new BukkitRunnable() + { + @Override + public void run() + { + countdown.getAndDecrement(); + + if (countdown.get() != 0 || !Config.STARTUP_TITLE.get()) + { + Titles.broadcastTitle( + countdown.get() == 10 ? 8 : 0, + countdown.get() == 0 ? 40 : 20, + countdown.get() == 0 ? 20 : 0, + (countdown.get() > 5 ? ChatColor.GREEN : (countdown.get() > 3 ? ChatColor.YELLOW : ChatColor.RED)) + countdown.toString(), + "" + ); + } + else + { + Titles.broadcastTitle( + 0, 84, 8, + /// Title of title displayed when the game starts. + I.t("{darkgreen}Let's go!"), + /// Subtitle of title displayed when the game starts. + I.t("{green}Good luck, and have fun") + ); + } + + if (countdown.get() != 0) + { + if (countdownIndex.incrementAndGet() == countdownNotes.length) + { + countdownIndex.set(0); + } + + new UHSound(1f, countdownNotes[countdownIndex.get()], "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT").broadcast(); + } + else + { + new UHSound("WITHER_DEATH").broadcast(); + } + + if (countdown.get() == 0) + { + setPhase(GamePhase.IN_GAME); + cancel(); + } + } + }, 5L, 20L); + } + + + @EventHandler (priority = EventPriority.LOW) + public void onGameStarting(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.STARTING) return; + + teleportationProcessLock = true; + + // We allow modules to prepare themselves for the teleportation phase + // (e.g. the spawns modules can generate missing spawn points on the fly). + Bukkit.getPluginManager().callEvent(new BeforeTeleportationPhaseEvent()); + + // We determine if the game is or not with teams by counting the teams. + teamsGame = ZTeams.get().countTeams() > 0; + + alivePlayers.clear(); + aliveTeams.clear(); + + // The Team is the base unit of the game. In a solo game, there is one team per player, with one player inside. + // In case of a teams game, we create a “wrapping” team for each alone player. Else, a team for each player. + // These teams created on the fly are saved in case of startup fail. + + final Set<ZTeam> onTheFlyTeams = new HashSet<>(); + final Random random = new Random(); + + Bukkit.getOnlinePlayers().stream() + .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) + .forEach(player -> + { + // We need an unique name for the team. + String teamName = player.getName(); + while (ZTeams.get().isTeamRegistered(teamName)) + { + teamName = player.getName() + " " + random.nextInt(1000000); + } + + final ZTeam team = ZTeams.get().createTeam( + teamName, + Config.RANDOM_COLORS_IN_SOLO_GAMES.get() ? TeamColor.RANDOM : TeamColor.WHITE, + player + ); + + onTheFlyTeams.add(team); + }); + + + // Loading alive players from teams, now that they are constructed and complete. + + ZTeams.get().getTeams().stream() + .flatMap(team -> team.getPlayers().stream()) + .map(OfflinePlayer::getUniqueId) + .filter(player -> !initialSpectators.contains(player)) + .forEach(alivePlayers::add); + + updateAliveTeams(); + + + // Enabling spectator mode for those who will not play. + + Bukkit.getOnlinePlayers() + .forEach(player -> UR.module(SpectatorsModule.class) + .getManager().setSpectating(player, initialSpectators.contains(player.getUniqueId()))); + + + // We have to check if there is enough spawn points. + + int spawnsNeeded = teleportationMode == TeleportationMode.IGNORE_TEAMS ? alivePlayers.size() : aliveTeams.size(); + + if (UR.module(SpawnsModule.class).getSpawnPoints().size() < spawnsNeeded) + { + log().broadcastAdministrative(I.t("{ce}Unable to start the game: not enough teleportation spots.")); + log().broadcastAdministrative(I.t("{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to generate the missing spawns automatically.")); + + /// In the sentence: "Or click here to generate the spawns randomly." + log().broadcastAdministrative(new RawText(I.t("Or")) + .then(" ") + /// In the sentence: "Or click here to generate the spawns randomly." + .then(I.t("click here")) + .color(ChatColor.GREEN).style(ChatColor.BOLD) + .command("/uh spawns generate random") + .hover(new RawText("/uh spawns generate random")) + .then(" ") + /// In the sentence: "Or click here to generate the spawns randomly." + .then(I.t("to generate the spawns randomly.")).color(ChatColor.WHITE) + .build() + ); + + // We clears the teams created on-the-fly + onTheFlyTeams.forEach(ZTeam::deleteTeam); + + return; + } + + + // Preparation of the spawn points. + + final List<Location> spawnPoints = UR.module(SpawnsModule.class).getSpawnPoints(); + Collections.shuffle(spawnPoints); + + final Queue<Location> unusedSpawnPoints = new ArrayDeque<>(spawnPoints); + + teleporter = new Teleporter(); + + ZTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> + { + if (teleportationMode == TeleportationMode.NORMAL && teamsGame) + { + // TODO re-add cages + dynmap integration in dedicated module using events. + + final Location teamSpawn = unusedSpawnPoints.poll(); + + // Should never happen + if (teamSpawn == null) + { + log().error( + "A fatal error occurred while starting the game: cannot set spawn point for team {0}: not enough spawn points", + team.getName() + ); + + return; + } + + team.getPlayersUUID().forEach(player -> + { + final PlayerSpawnPointSelectedEvent event = new PlayerSpawnPointSelectedEvent( + Bukkit.getOfflinePlayer(player), teamSpawn.clone()); + + Bukkit.getPluginManager().callEvent(event); + + teleporter.setSpawnForPlayer(player, event.getSpawnPoint()); + }); + } + else + { + team.getPlayersUUID().forEach(player -> + { + // TODO re-add cages + dynmap integration in dedicated module using events. + + final Location playerSpawn = unusedSpawnPoints.poll(); + final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player); + + // Should never happen + if (playerSpawn == null) + { + log().error( + "A fatal error occurred while starting the game: cannot set spawn point for player {0}: not enough spawn points", + offlinePlayer.getName() + ); + + return; + } + + final PlayerSpawnPointSelectedEvent event = new PlayerSpawnPointSelectedEvent( + offlinePlayer, playerSpawn); + + Bukkit.getPluginManager().callEvent(event); + + teleporter.setSpawnForPlayer(player, event.getSpawnPoint()); + }); + } + }); + + + // Effective teleportation. + + teleporter + .whenTeleportationOccurs(uuid -> Bukkit.getPluginManager().callEvent( + new PlayerAboutToBeTeleportedToSpawnPointEvent(Bukkit.getPlayer(uuid), teleporter.getSpawnForPlayer(uuid)))) + + .whenTeleportationSuccesses(uuid -> { + final Player player = Bukkit.getPlayer(uuid); + + log().info("Player {0} - {1} teleported to its spawn point.", uuid, player.getName()); + + Bukkit.getPluginManager().callEvent( + new PlayerTeleportedToSpawnPointEvent(player, teleporter.getSpawnForPlayer(uuid))); + }) + + .whenTeleportationFails(uuid -> log().error("Unable to teleport player {0} - {1}", uuid, Bukkit.getPlayer(uuid).getName())) + + .whenTeleportationEnds(uuids -> { + teleportationProcessLock = false; + Bukkit.getPluginManager().callEvent(new AfterTeleportationPhaseEvent()); + }) + + .startTeleportationProcess(slowMode); + } + + @EventHandler (priority = EventPriority.LOWEST) + public void onPlayerTeleportedToSpawnPoint(PlayerTeleportedToSpawnPointEvent ev) + { + Player player = Bukkit.getPlayer(ev.getPlayer().getUniqueId()); + + if (player != null) + { + player.setGameMode(GameMode.ADVENTURE); + player.setAllowFlight(true); + player.setFlying(true); + player.setFlySpeed(0f); + } + + if (Config.BROADCAST_PROGRESS.get()) + { + teleportationProgress++; + + /// Displayed in the action bar while the slow teleportation occurs. + final String message = I.t("{lightpurple}Teleporting... {gray}({0}/{1})", teleportationProgress, alivePlayers.size()); + Bukkit.getOnlinePlayers().forEach(onlinePlayer -> ActionBar.sendPermanentMessage(onlinePlayer, message)); + } + } + + @EventHandler (priority = EventPriority.LOWEST) + public void onTeleportationProcessComplete(AfterTeleportationPhaseEvent ev) + { + log().broadcastAdministrative(I.t("{cs}All teams are teleported.")); + log().broadcastAdministrative(new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) + .hover(new RawText(I.t("Click here to start the game"))) + .command(StartCommand.class) + ); + + if (Config.BROADCAST_PROGRESS.get()) + { + /// Displayed in the action bar when the slow teleportation is finished but the game not started. + String message = I.t("{lightpurple}Teleportation complete. {gray}The game will start soon..."); + Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, message)); + } + } + + @EventHandler (priority = EventPriority.LOWEST) + public void onGameStarts(GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + + Bukkit.getOnlinePlayers().forEach(ActionBar::removeMessage); + + getAliveConnectedPlayers().forEach(player -> { + updatePlayerFlightOptions(player); + player.setFlying(false); + player.setAllowFlight(false); + player.setGameMode(GameMode.SURVIVAL); + player.setHealth(player.getMaxHealth()); + }); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent ev) + { + updatePlayerFlightOptions(ev.getPlayer()); + } + + + /** + * Sets the flight options for the player according to the current game phase. + * @param player The player. + */ + private void updatePlayerFlightOptions(final Player player) + { + switch (phase) + { + case WAIT: + player.setFlySpeed(.1f); + break; + + case STARTING: + if (alivePlayers.contains(player.getUniqueId())) + { + player.setAllowFlight(true); + player.setFlySpeed(0f); + } + else + { + player.setFlySpeed(.1f); + } + + break; + + case IN_GAME: + case END: + player.setFlySpeed(.1f); } } + + private void updateAliveTeams() + { + aliveTeams.clear(); + + ZTeams.get().getTeams() + .forEach(t -> t.getPlayersUUID().stream().filter(alivePlayers::contains).map(pid -> t).forEach(aliveTeams::add)); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java index d645889..737b4b6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java @@ -31,22 +31,66 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.commands.WithFlags; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; +import java.util.List; -@CommandInfo (name = "start", usageParameters = "[--slow]") -@WithFlags ({"slow"}) + +@CommandInfo (name = "start", usageParameters = "[--slow] [--ignore-teams]") +@WithFlags ({"slow", "ignore-teams"}) public class StartCommand extends Command { @Override protected void run() throws CommandException { - UHCReloaded.getModule(GameModule.class).setPhase(GamePhase.STARTING); + final GameModule game = UR.module(GameModule.class); + + switch (game.getPhase()) + { + case WAIT: + game.setSlowMode(hasFlag("slow")); + game.setTeleportationMode(hasFlag("ignore-teams") ? TeleportationMode.IGNORE_TEAMS : TeleportationMode.NORMAL); + + if (hasFlag("slow")) + { + if (sender instanceof Player) info(""); + info(I.t("{green}{bold}The game is now starting.")); + info(I.t("{green}Wait for the teleportation to finish; you'll then be prompted to start the game.")); + } + + game.setPhase(GamePhase.STARTING); + + break; + + case STARTING: + try + { + game.start(); + } + catch (final IllegalStateException e) + { + error(I.t("The starting process is not finished yet. Please be patient.")); + } + + break; + + default: + error(I.t("{ce}The game is already started! Reload or restart the server to restart the game.")); + } + } + + @Override + protected List<String> complete() + { + return getMatchingSubset(args[args.length - 1], "--slow", "--ignore-teams"); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java index f30ea0d..e9cbabe 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events; +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.game; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java new file mode 100644 index 0000000..632b5bd --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired while starting the game, when the teleportation phase is finished. + */ +public class AfterTeleportationPhaseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java new file mode 100644 index 0000000..cadc083 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java @@ -0,0 +1,56 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired while starting the game, when the teleportation phase is about + * to start. + */ +public class BeforeTeleportationPhaseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java new file mode 100644 index 0000000..45ed3c7 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java @@ -0,0 +1,80 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired just before a player's teleportation to its spawn point. + * + * The spawn point cannot be modified here. + * + * @see PlayerSpawnPointSelectedEvent + */ +public class PlayerAboutToBeTeleportedToSpawnPointEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final Player player; + private final Location spawnPoint; + + public PlayerAboutToBeTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) + { + this.player = player; + this.spawnPoint = spawnPoint; + } + + public Player getPlayer() + { + return player; + } + + public Location getSpawnPoint() + { + return spawnPoint; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java new file mode 100644 index 0000000..d8c0858 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java @@ -0,0 +1,81 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; + +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired when a spawn point is selected for a given player. + */ +public class PlayerSpawnPointSelectedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final OfflinePlayer player; + private Location spawnPoint; + + public PlayerSpawnPointSelectedEvent(final OfflinePlayer player, final Location spawnPoint) + { + this.player = player; + this.spawnPoint = spawnPoint; + } + + public OfflinePlayer getPlayer() + { + return player; + } + + public Location getSpawnPoint() + { + return spawnPoint; + } + + public void setSpawnPoint(Location spawnPoint) + { + this.spawnPoint = spawnPoint; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java new file mode 100644 index 0000000..eb4d106 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java @@ -0,0 +1,80 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired when a player is teleported to its spawn point. + * + * The spawn point cannot be modified here. + * + * @see PlayerSpawnPointSelectedEvent + */ +public class PlayerTeleportedToSpawnPointEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final Player player; + private final Location spawnPoint; + + public PlayerTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) + { + this.player = player; + this.spawnPoint = spawnPoint; + } + + public Player getPlayer() + { + return player; + } + + public Location getSpawnPoint() + { + return spawnPoint; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java new file mode 100644 index 0000000..347d1c8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java @@ -0,0 +1,47 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; + +public enum TeleportationMode +{ + /** + * Teams are teleported together. + */ + NORMAL, + + /** + * Players are all teleported alone, even if they are in teams. + */ + IGNORE_TEAMS +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/TeleportationRunnable.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/game/TeleportationRunnable.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java index 91059b3..d0a7446 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/TeleportationRunnable.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.game; +package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.tools.Callback; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Teleporter.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java similarity index 70% rename from src/main/java/eu/carrade/amaury/UHCReloaded/game/Teleporter.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java index 8b8b906..9d9d83b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/Teleporter.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java @@ -29,10 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.game; +package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import eu.carrade.amaury.UHCReloaded.modules.core.game.Config; import fr.zcraft.zlib.tools.Callback; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; @@ -40,7 +39,6 @@ import org.bukkit.entity.Player; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -56,11 +54,6 @@ public class Teleporter */ private final Map<UUID, Location> spawnPoints = new HashMap<>(); - /** - * The cages generated for each team - */ - private final Map<UUID, Cage> cages = new HashMap<>(); - /** * Called when a player is teleported, during the teleportation process. @@ -120,37 +113,6 @@ public Location getSpawnForPlayer(final UUID playerUUID) } - /** - * Registers a cage for a player. - * - * @param player The player - * @param cage The cage - */ - public void setCageForPlayer(final UUID player, final Cage cage) - { - cages.put(player, cage); - } - - /** - * Checks if a cage is registered for the given player. - * @param player The player. - * @return {@code true} if a cage is registered. - */ - public boolean hasCageForPlayer(final UUID player) - { - return cages.containsKey(player); - } - - /** - * @param player A player - * @return The registered {@link Cage} for this player, or {@code null} if no one is registered. - */ - public Cage getCageForPlayer(final UUID player) - { - return cages.get(player); - } - - /** * Teleports the given player to the spawn point. * @@ -175,19 +137,13 @@ public boolean teleportPlayer(UUID playerUUID, Boolean teleportOnGround) else if (teleportOnGround) spawn = spawn.getWorld().getHighestBlockAt(spawn).getLocation().add(0, 2, 0); - if (!teleportOnGround) - { - final Cage cage = cages.get(playerUUID); - if (cage != null) cage.build(); - } - player.teleport(spawn); return true; } /** - * Registers a callback called while trying to teleport a player. + * Registers a callback called just before trying to teleport a player. * * @param callback The callback. Argument: the teleported player's UUID. * @@ -251,53 +207,17 @@ public Teleporter whenTeleportationEnds(Callback<Set<UUID>> callback) */ public void startTeleportationProcess(Boolean slowMode) { - // Fast mode: we loop on the spawn points and teleport everyone. Bim. - if (!slowMode) - { - Set<UUID> fails = new HashSet<>(); - - for (UUID playerUUID : spawnPoints.keySet()) - { - UHUtils.callIfDefined(onTeleportation, playerUUID); - - if (teleportPlayer(playerUUID, false)) - { - UHUtils.callIfDefined(onTeleportationSuccessful, playerUUID); - } - else - { - UHUtils.callIfDefined(onTeleportationFailed, playerUUID); - fails.add(playerUUID); - } - } - - UHUtils.callIfDefined(onTeleportationProcessFinished, fails); - } - - // Slow mode - else - { - RunTask.timer( - new TeleportationRunnable( - this, - spawnPoints.keySet(), - onTeleportation, - onTeleportationSuccessful, - onTeleportationFailed, - onTeleportationProcessFinished - ), - 1L, - UHConfig.START.SLOW.DELAY_BETWEEN_TP.get() * 20L - ); - } - } - - /** - * Cleanups the cages left by the teleportation process, to be executed when the game really starts. - */ - public void cleanup() - { - for (final Cage nicolas : cages.values()) // sorry - nicolas.destroy(); + RunTask.timer( + new TeleportationRunnable( + this, + spawnPoints.keySet(), + onTeleportation, + onTeleportationSuccessful, + onTeleportationFailed, + onTeleportationProcessFinished + ), + 1L, + slowMode ? 1L : Config.SLOW.DELAY_BETWEEN_TP.get() * 20L + ); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java index fe5a5af..8275cf0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java @@ -32,10 +32,11 @@ package eu.carrade.amaury.UHCReloaded.modules.core.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.commands.SpawnsCommand; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; @@ -43,8 +44,11 @@ import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import java.util.Collections; @@ -197,24 +201,6 @@ public void reset() } - /** - * Imports spawn points from the configuration. - * - * @return The number of spawn points imported. - */ - public int importSpawnPointsFromConfig() - { - int spawnCount = 0; - - for (Vector position : UHConfig.SPAWN_POINTS) - { - addSpawnPoint(position); - ++spawnCount; - } - - return spawnCount; - } - /** * Generates spawn points with the given generator. @@ -297,4 +283,75 @@ public void generateSpawnPoints(final SpawnPointsGenerator generator, final Worl xCenter, zCenter, Config.AVOID_WATER.get() ).forEach(this::addSpawnPoint); } + + + /** + * Generates on the fly missing spawn points when the game starts. + */ + @EventHandler + public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) + { + final GameModule game = UR.module(GameModule.class); + + final World normalWorld = UR.get().getWorld(World.Environment.NORMAL); + + final int regionDiameter = UR.module(BorderModule.class).getCurrentBorderDiameter(); + final int playersWithoutTeam = (int) Bukkit.getOnlinePlayers().stream() + .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) + .count(); + + int spawnsNeeded = 0; + + switch (game.getTeleportationMode()) + { + case NORMAL: + spawnsNeeded = ZTeams.get().countTeams() + playersWithoutTeam; + break; + + case IGNORE_TEAMS: + spawnsNeeded = ZTeams.get().getTeams().stream().mapToInt(team -> team.getPlayers().size()).sum() + + playersWithoutTeam; + break; + } + + spawnsNeeded -= spawnPoints.size(); // We don't need what we already have. + + if (spawnsNeeded <= 0) return; + + Exception error = null; + + for (int i = 0; i < 6; i++) + { + try + { + generateSpawnPoints( + Generator.RANDOM, + normalWorld, + spawnsNeeded, + regionDiameter - 25, + (int) Math.floor(regionDiameter / Math.max(spawnsNeeded * 1.4, 10)), + normalWorld.getSpawnLocation().getX(), + normalWorld.getSpawnLocation().getZ() + ); + + error = null; + } + catch (final CannotGenerateSpawnPointsException e) + { + error = e; + continue; + } + + break; + } + + if (error == null) + { + log().info("Randomly generated {0} missing spawn points on the fly. See /uh spawn for details.", spawnsNeeded); + } + else + { + log().error("There where {0} missing spawn points but we weren''t able to generate them automatically, even after 6 tries. Try to generate them yourself using /uh spawns generate, or to add them manually with /uh spawns add.", error, spawnsNeeded); + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java index e09325a..53a4142 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java @@ -42,6 +42,7 @@ import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -373,11 +374,10 @@ protected void generate() throws CommandException double zCenter = world.getSpawnLocation().getZ(); int spawnsCount = 0; -// TODO Default to either teams (if any) or players count. -// for (final ZTeam team : ZTeams.get().getTeams()) -// { -// if (!team.isEmpty()) spawnsCount++; -// } + for (final ZTeam team : ZTeams.get().getTeams()) + { + if (!team.isEmpty()) spawnsCount++; + } if (args.length < 8) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index de303a2..c298739 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -105,7 +105,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // So we uses this as a limit. if (packingDensity >= 0.9069) { - throw new CannotGenerateSpawnPointsException("Unable to generate spawn points randomly: packing density too high"); + throw new CannotGenerateSpawnPointsException("Unable to generate spawn points randomly: packing density of " + packingDensity + " too high"); } /* *** Generation *** */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java new file mode 100644 index 0000000..a350793 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -0,0 +1,64 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.spectators; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; + + +@ModuleInfo ( + name = "Spectators manager", + description = "Handles non-playing players", + when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, + can_be_disabled = false +) +public class SpectatorsModule extends UHModule +{ + private SpectatorsManager manager; + + @Override + protected void onEnable() + { + manager = SpectatorsManager.getInstance(); + } + + /** + * @return The manager instance to use to handle spectators. + */ + public SpectatorsManager getManager() + { + return manager; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java index 3dbd97d..bce76f4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SPlusSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.spectators; +package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import org.bukkit.entity.Player; @@ -37,6 +37,8 @@ /** * Spectators managed through the SpectatorsPlus Bukkit plugin by PGMann and AmauryPi. + * + * TODO fix integration */ public class SPlusSpectatorsManager extends SpectatorsManager { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java index 0e5911a..79824db 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.spectators; +package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import org.bukkit.Bukkit; @@ -90,7 +90,8 @@ public boolean isSpectating(final UUID playerID) */ public static SpectatorsManager getInstance() { - if (UHCReloaded.get().getSpectatorPlusIntegration().isSPIntegrationEnabled()) + // TODO re-add SP integration + if (false && UHCReloaded.get().getSpectatorPlusIntegration().isSPIntegrationEnabled()) return new SPlusSpectatorsManager(); else return new VanillaSpectatorsManager(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java index f78904d..4df455c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/spectators/VanillaSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.spectators; +package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; import org.bukkit.Bukkit; @@ -68,9 +68,7 @@ public void setSpectating(final Player player, final boolean spectating) } else { - GameMode previousMode = oldGameModes.get(player.getUniqueId()); - player.setGameMode(previousMode != null ? previousMode : Bukkit.getDefaultGameMode()); - + player.setGameMode(oldGameModes.getOrDefault(player.getUniqueId(), Bukkit.getDefaultGameMode())); oldGameModes.remove(player.getUniqueId()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java index 6bf392b..6dbea9c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java @@ -34,8 +34,6 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; -import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; @@ -48,11 +46,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permissible; @@ -84,7 +78,7 @@ private void openTeamsGUI(Player player, ItemStack item) && item != null && item.getType() == UHConfig.BEFORE_START.TEAM_SELECTOR.ITEM.get()) { - Gui.open(player, new TeamsSelectorGUI()); +// Gui.open(player, new TeamsSelectorGUI()); } } @@ -120,7 +114,7 @@ public void onPlayerJoin(PlayerJoinEvent ev) if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) { - UHCReloaded.get().getTeamManager().displayTeamInActionBar(ev.getPlayer()); +// UHCReloaded.get().getTeamManager().displayTeamInActionBar(ev.getPlayer()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java index 9fe235c..e7fe13c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java @@ -33,15 +33,12 @@ package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.block.Banner; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; @@ -50,14 +47,7 @@ import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.inventory.AnvilInventory; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.*; import org.bukkit.inventory.meta.ItemMeta; import java.util.HashSet; @@ -335,41 +325,41 @@ public void onInventoryDrag(final InventoryDragEvent ev) @EventHandler (ignoreCancelled = true) public void onShieldPreCraft(PrepareItemCraftEvent ev) { - if (!UHConfig.TEAMS_OPTIONS.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; - - final Player player = (Player) ev.getViewers().get(0); - final UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); - - if (team == null || team.getBanner() == null) return; - - final ItemStack result = ev.getRecipe().getResult(); - - final Material MATERIAL_SHIELD = Material.getMaterial("SHIELD"); - if (MATERIAL_SHIELD == null) return; // MC 1.8 - - if (result != null && result.getType() == MATERIAL_SHIELD) - { - try - { - final BannerMeta banner = (BannerMeta) team.getBanner().getItemMeta(); - - final BlockStateMeta bsMeta = (BlockStateMeta) result.getItemMeta(); - final Banner shieldBanner = (Banner) bsMeta.getBlockState(); - - shieldBanner.setBaseColor(banner.getBaseColor()); - shieldBanner.setPatterns(banner.getPatterns()); - - shieldBanner.update(); - - bsMeta.setBlockState(shieldBanner); - result.setItemMeta(bsMeta); - - ev.getInventory().setResult(result); - } - catch (ClassCastException | NullPointerException ignored) - { - // Bad Minecraft version (1.8) - } - } +// if (!UHConfig.TEAMS_OPTIONS.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; +// +// final Player player = (Player) ev.getViewers().get(0); +// final UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); +// +// if (team == null || team.getBanner() == null) return; +// +// final ItemStack result = ev.getRecipe().getResult(); +// +// final Material MATERIAL_SHIELD = Material.getMaterial("SHIELD"); +// if (MATERIAL_SHIELD == null) return; // MC 1.8 +// +// if (result != null && result.getType() == MATERIAL_SHIELD) +// { +// try +// { +// final BannerMeta banner = (BannerMeta) team.getBanner().getItemMeta(); +// +// final BlockStateMeta bsMeta = (BlockStateMeta) result.getItemMeta(); +// final Banner shieldBanner = (Banner) bsMeta.getBlockState(); +// +// shieldBanner.setBaseColor(banner.getBaseColor()); +// shieldBanner.setPatterns(banner.getPatterns()); +// +// shieldBanner.update(); +// +// bsMeta.setBlockState(shieldBanner); +// result.setItemMeta(bsMeta); +// +// ev.getInventory().setResult(result); +// } +// catch (ClassCastException | NullPointerException ignored) +// { +// // Bad Minecraft version (1.8) +// } +// } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 84280ed..dddf069 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -34,32 +34,18 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameEndsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHTeamDeathEvent; +import eu.carrade.amaury.UHCReloaded.old.events.*; import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.RawMessage; import fr.zcraft.zlib.tools.text.Titles; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.SkullType; -import org.bukkit.block.Banner; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; +import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -69,16 +55,10 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerAchievementAwardedEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerStatisticIncrementEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.SkullMeta; import java.net.URISyntaxException; @@ -185,7 +165,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) Player killer = ev.getEntity().getKiller(); if (killer != null) { - boolean inSameTeam = p.getTeamManager().inSameTeam(ev.getEntity(), killer); + boolean inSameTeam = true; // TODO p.getTeamManager().inSameTeam(ev.getEntity(), killer); boolean onlyOtherTeam = UHConfig.DEATH.GIVE_XP_TO_KILLER.ONLY_OTHER_TEAM.get(); if (!onlyOtherTeam || !inSameTeam) @@ -196,34 +176,34 @@ public void onPlayerDeath(final PlayerDeathEvent ev) } // Sends a team-death message & event if needed. - final UHTeam team = p.getTeamManager().getTeamForPlayer(ev.getEntity()); - if (team != null) - { - boolean isAliveTeam = false; - - for (UUID playerID : team.getPlayersUUID()) - { - if (!p.getGameManager().isPlayerDead(playerID)) - { - isAliveTeam = true; - break; - } - } - - if (!isAliveTeam) - { - p.getServer().getPluginManager().callEvent(new UHTeamDeathEvent(team)); - - if (UHConfig.DEATH.MESSAGES.NOTIFY_IF_TEAM_HAS_FALLEN.get()) - { - // Used to display this message after the death message. - RunTask.later(() -> { - String format = ChatColor.translateAlternateColorCodes('&', UHConfig.DEATH.MESSAGES.TEAM_DEATH_MESSAGES_FORMAT.get()); - p.getServer().broadcastMessage(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)); - }, 1L); - } - } - } +// final UHTeam team = p.getTeamManager().getTeamForPlayer(ev.getEntity()); +// if (team != null) +// { +// boolean isAliveTeam = false; +// +// for (UUID playerID : team.getPlayersUUID()) +// { +// if (!p.getGameManager().isPlayerDead(playerID)) +// { +// isAliveTeam = true; +// break; +// } +// } +// +// if (!isAliveTeam) +// { +// p.getServer().getPluginManager().callEvent(new UHTeamDeathEvent(team)); +// +// if (UHConfig.DEATH.MESSAGES.NOTIFY_IF_TEAM_HAS_FALLEN.get()) +// { +// // Used to display this message after the death message. +// RunTask.later(() -> { +// String format = ChatColor.translateAlternateColorCodes('&', UHConfig.DEATH.MESSAGES.TEAM_DEATH_MESSAGES_FORMAT.get()); +// p.getServer().broadcastMessage(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)); +// }, 1L); +// } +// } +// } // Highlights the death message in the console p.getServer().getConsoleSender().sendMessage(ChatColor.GOLD + "-- Death of " + ev.getEntity().getDisplayName() + ChatColor.GOLD + " (" + ev.getDeathMessage() + ") --"); @@ -250,7 +230,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) p.getGameManager().setGameFinished(true); // There's only one team alive, so the winner team is the first one. - p.getServer().getPluginManager().callEvent(new UHGameEndsEvent(p.getGameManager().getAliveTeams().iterator().next())); +// p.getServer().getPluginManager().callEvent(new UHGameEndsEvent(p.getGameManager().getAliveTeams().iterator().next())); } // Notifies the player about the possibility of respawn if hardcore hearts are enabled @@ -263,13 +243,13 @@ public void onPlayerDeath(final PlayerDeathEvent ev) } // Disables the team-chat-lock if needed - if (UHConfig.TEAMS_OPTIONS.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) - { - if (p.getTeamChatManager().isTeamChatEnabled(ev.getEntity())) - { - p.getTeamChatManager().toggleChatForPlayer(ev.getEntity()); - } - } +// if (UHConfig.TEAMS_OPTIONS.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) +// { +// if (p.getTeamChatManager().isTeamChatEnabled(ev.getEntity())) +// { +// p.getTeamChatManager().toggleChatForPlayer(ev.getEntity()); +// } +// } // Updates the list headers & footers. p.getPlayerListHeaderFooterManager().updateHeadersFooters(); @@ -380,15 +360,15 @@ public void onPlayerJoin(final PlayerJoinEvent ev) p.getGameManager().initPlayer(ev.getPlayer()); // Teams selector. - if (UHConfig.TEAMS_OPTIONS.GUI.AUTO_DISPLAY.get() && p.getTeamManager().getTeams().size() != 0) - { - RunTask.later(() -> { - if (p.getTeamManager().getTeamForPlayer(ev.getPlayer()) == null) - { - p.getTeamManager().displayTeamChooserChatGUI(ev.getPlayer()); - } - }, 20L * UHConfig.TEAMS_OPTIONS.GUI.DELAY.get()); - } +// if (UHConfig.TEAMS_OPTIONS.GUI.AUTO_DISPLAY.get() && p.getTeamManager().getTeams().size() != 0) +// { +// RunTask.later(() -> { +// if (p.getTeamManager().getTeamForPlayer(ev.getPlayer()) == null) +// { +// p.getTeamManager().displayTeamChooserChatGUI(ev.getPlayer()); +// } +// }, 20L * UHConfig.TEAMS_OPTIONS.GUI.DELAY.get()); +// } // Rules if (p.getRulesManager().displayOnJoin()) @@ -411,7 +391,7 @@ public void onPlayerJoin(final PlayerJoinEvent ev) p.getPlayerListHeaderFooterManager().sendTo(ev.getPlayer()); // The display name is reset when the player logs off. - p.getTeamManager().colorizePlayer(ev.getPlayer()); +// p.getTeamManager().colorizePlayer(ev.getPlayer()); if (!p.getGameManager().isGameStarted() && ev.getPlayer().hasPermission("uh.*")) { @@ -538,16 +518,16 @@ public void onAsyncPlayerChat(final AsyncPlayerChatEvent ev) // the event is ignored. if (ev.isAsynchronous()) { - if (p.getTeamChatManager().isTeamChatEnabled(ev.getPlayer())) - { - ev.setCancelled(true); - p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage()); - } - else if (p.getTeamChatManager().isOtherTeamChatEnabled(ev.getPlayer())) - { - ev.setCancelled(true); - p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage(), p.getTeamChatManager().getOtherTeamEnabled(ev.getPlayer())); - } +// if (p.getTeamChatManager().isTeamChatEnabled(ev.getPlayer())) +// { +// ev.setCancelled(true); +// p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage()); +// } +// else if (p.getTeamChatManager().isOtherTeamChatEnabled(ev.getPlayer())) +// { +// ev.setCancelled(true); +// p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage(), p.getTeamChatManager().getOtherTeamEnabled(ev.getPlayer())); +// } } } @@ -682,47 +662,47 @@ public void onGameStarts(final UHGameStartsEvent ev) // Banners if (p.getGameManager().START_GIVE_BANNER || p.getGameManager().START_PLACE_BANNER_HEAD || p.getGameManager().START_PLACE_BANNER_SPAWN) { - RunTask.later(() -> - { - for (UHTeam team : p.getTeamManager().getTeams()) - { - if (!team.isEmpty()) - { - final ItemStack banner = team.getBanner(); - for (Player player : team.getOnlinePlayers()) - { - if (p.getGameManager().START_GIVE_BANNER) - player.getInventory().setItem(8, banner); - - if (p.getGameManager().START_PLACE_BANNER_HEAD) - player.getInventory().setHelmet(banner); - - if (p.getGameManager().START_PLACE_BANNER_SPAWN) - { - final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); - final Block under = place.getRelative(BlockFace.DOWN); - - // We don't want a stack of banners - if (under.getType() != Material.STANDING_BANNER) - { - if (!under.getType().isSolid()) - under.setType(Material.WOOD); - - place.setType(Material.STANDING_BANNER); - - Banner bannerBlock = (Banner) place.getState(); - BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); - - bannerBlock.setBaseColor(bannerMeta.getBaseColor()); - bannerBlock.setPatterns(bannerMeta.getPatterns()); - - bannerBlock.update(); - } - } - } - } - } - }, 5L); +// RunTask.later(() -> +// { +// for (UHTeam team : p.getTeamManager().getTeams()) +// { +// if (!team.isEmpty()) +// { +// final ItemStack banner = team.getBanner(); +// for (Player player : team.getOnlinePlayers()) +// { +// if (p.getGameManager().START_GIVE_BANNER) +// player.getInventory().setItem(8, banner); +// +// if (p.getGameManager().START_PLACE_BANNER_HEAD) +// player.getInventory().setHelmet(banner); +// +// if (p.getGameManager().START_PLACE_BANNER_SPAWN) +// { +// final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); +// final Block under = place.getRelative(BlockFace.DOWN); +// +// // We don't want a stack of banners +// if (under.getType() != Material.STANDING_BANNER) +// { +// if (!under.getType().isSolid()) +// under.setType(Material.WOOD); +// +// place.setType(Material.STANDING_BANNER); +// +// Banner bannerBlock = (Banner) place.getState(); +// BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); +// +// bannerBlock.setBaseColor(bannerMeta.getBaseColor()); +// bannerBlock.setPatterns(bannerMeta.getPatterns()); +// +// bannerBlock.update(); +// } +// } +// } +// } +// } +// }, 5L); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index 128f883..28fac67 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -323,11 +323,11 @@ public void onPlayerInteract(PlayerInteractEvent ev) if (calc > 1 && calc < distance) { - distance = calc; - if (!player2.getUniqueId().equals(player1.getUniqueId()) && !p.getTeamManager().inSameTeam(player1, player2)) - { - nearest = player2.getPlayer(); - } +// distance = calc; +// if (!player2.getUniqueId().equals(player1.getUniqueId()) && !p.getTeamManager().inSameTeam(player1, player2)) +// { +// nearest = player2.getPlayer(); +// } } } catch (Exception ignored) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java index ccb85f0..2562d95 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java @@ -33,14 +33,9 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Entity; +import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Monster; import org.bukkit.entity.Rabbit; -import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -98,134 +93,10 @@ public void onRabbitSpawn(CreatureSpawnEvent ev) public void onCreatureSpawn(CreatureSpawnEvent ev) { if (!UHCReloaded.get().getGameManager().isGameStarted() - && isNaturalSpawn(ev.getSpawnReason()) - && isHostile(ev.getEntityType())) + && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) + && EntitiesUtils.isHostile(ev.getEntityType())) { ev.setCancelled(true); } } - - /** - * Used to cancel the spawn of hostile entities on the surface only, at the beginning of the game. - */ - @EventHandler - public void onSurfaceCreatureSpawn(CreatureSpawnEvent ev) - { - if (UHCReloaded.get().getGameManager().isGameStarted() - && !UHCReloaded.get().getGameManager().isSurfaceSpawnEnabled() - && isNaturalSpawn(ev.getSpawnReason()) - && isHostile(ev.getEntityType())) - { - // We check the blocs above the entity to see if we only find surface blocks. - final Location spawnLocation = ev.getLocation(); - final World world = spawnLocation.getWorld(); - final int highestBlockY = world.getHighestBlockYAt(spawnLocation); - - final int x = spawnLocation.getBlockX(); - final int z = spawnLocation.getBlockZ(); - - boolean surface = true; - - for (int y = spawnLocation.getBlockY(); y <= highestBlockY; y++) - { - switch (world.getBlockAt(x, y, z).getType()) - { - // Air - case AIR: - - // Trees - case LOG: - case LOG_2: - case LEAVES: - case LEAVES_2: - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: - - // Vegetation - case DEAD_BUSH: - case CROPS: - case GRASS: - case LONG_GRASS: - case DOUBLE_PLANT: - case YELLOW_FLOWER: - case VINE: - case SUGAR_CANE_BLOCK: - case BROWN_MUSHROOM: - case RED_MUSHROOM: - - // Nature - case SNOW: - - // Igloos - case SNOW_BLOCK: - - // Villages - case WOOD: - case WOOD_STAIRS: - case SANDSTONE_STAIRS: - case BOOKSHELF: - - // Redstone - case REDSTONE_WIRE: - case REDSTONE_COMPARATOR: - case REDSTONE_COMPARATOR_OFF: - case REDSTONE_COMPARATOR_ON: - case REDSTONE_TORCH_OFF: - case REDSTONE_TORCH_ON: - - // Other blocs frequently used on surface on custom maps - case TORCH: - case RAILS: - case ACTIVATOR_RAIL: - case DETECTOR_RAIL: - case POWERED_RAIL: - break; - - default: - surface = false; - } - - if (!surface) break; - } - - if (surface) ev.setCancelled(true); - } - } - - - /** - * Checks if a spawn is natural. - * - * @param reason The spawn reason. - * @return {@code true} if it's a natural spawn (not from a player or an interaction - * with another entity, as example). - */ - private boolean isNaturalSpawn(CreatureSpawnEvent.SpawnReason reason) - { - switch (reason) - { - case NATURAL: - case NETHER_PORTAL: - case LIGHTNING: - case SPAWNER: - return true; - - default: - return false; - } - } - - /** - * Checks if the given mod is hostile. - * @param entity The entity. - * @return {@code true} if hostile. - */ - private boolean isHostile(EntityType entity) - { - Class<? extends Entity> entityClass = entity.getEntityClass(); - - return Monster.class.isAssignableFrom(entityClass) - || Slime.class.isAssignableFrom(entityClass) - || Ghast.class.isAssignableFrom(entityClass); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java index dcdcf3d..00e8f92 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java @@ -33,12 +33,11 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; @@ -50,7 +49,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; public class GameSidebar extends Sidebar @@ -191,103 +189,104 @@ public void preRender() public List<String> getContent(Player player) { - List<String> sidebar = new ArrayList<>(sidebarTop); - sidebar.add(""); - - if (OWN_TEAM_IN_SIDEBAR && gameManager.isGameStarted() && gameManager.isGameWithTeams()) - { - UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); - - if (team != null) - { - sidebar.add( - (OWN_TEAM_TITLE_COLOR.isEmpty() ? team.getColorOrWhite().toChatColor() : OWN_TEAM_TITLE_COLOR) - /// Title of the team section in the sidebar - + (OWN_TEAM_TITLE_IS_NAME ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) - ); - - Location playerLocation = player.getLocation(); - - for (UUID teamMember : team.getPlayersUUID()) - { - SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(teamMember); - - // If enabled, we check if the player was already met or is close to this player. - // Only if the damages are on (= 30 seconds after the game start) to avoid false close while - // teleporting. - if(OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY) - { - if(!(teamMember.equals(player.getUniqueId()) || cache.getTeammatesDisplayed().contains(teamMember))) - { - if (gameManager.isGameStarted() && gameManager.isTakingDamage()) - { - if (gameManager.isPlayerDead(teamMember)) - continue; // dead (spectators don't have to be displayed in the sidebar). - - Player teammate = Sidebar.getPlayerAsync(teamMember); - if (teammate == null) - continue; // offline - - - Location teammateLocation = teammate.getLocation(); - - // Check if the players are close - if (teammateLocation.getWorld().equals(playerLocation.getWorld())) - { - final double distanceSquared = teammateLocation.distanceSquared(playerLocation); - if (distanceSquared <= OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED) - cache.getTeammatesDisplayed().add(teamMember); - else - continue; // Too far, skipped - } - else - { - continue; // Too far, skipped - } - } - else - { - continue; - } - } - } - - final String strike = OWN_TEAM_STRIKE_DEAD_PLAYERS && !cache.isAlive() ? ChatColor.STRIKETHROUGH.toString() : ""; - final ChatColor aliveColor = cache.isAlive() ? ChatColor.WHITE : ChatColor.GRAY; - - final String heart = OWN_TEAM_DISPLAY_HEARTS ? cache.getHealthColor() + strike + HEART + " " : ""; - final String name = (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) - + strike - + (OWN_TEAM_DISPLAY_LOGIN_STATE_ITALIC && !cache.isOnline() ? ChatColor.ITALIC : "") - + cache.getPlayerName() - + (!cache.isOnline() ? ChatColor.RESET + "" + (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) + " " + OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX : ""); - - sidebar.add(heart + name); - } - - sidebar.add(""); - } - } - - sidebar.addAll(sidebarBorder); - - if (KILLS_IN_SIDEBAR && gameManager.isGameStarted()) - { - SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); - - /// Kills count in the sidebar - sidebar.add(I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", cache.getPlayersKilled().size(), cache.getPlayersKilled().size())); - sidebar.add(""); - } - - sidebar.addAll(sidebarTimers); - - if (FREEZE_STATUS_IN_SIDEBAR) - { - insertFreezeStatus(sidebar, player); - } - - return sidebar; +// List<String> sidebar = new ArrayList<>(sidebarTop); +// sidebar.add(""); +// +// if (OWN_TEAM_IN_SIDEBAR && gameManager.isGameStarted() && gameManager.isGameWithTeams()) +// { +// UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); +// +// if (team != null) +// { +// sidebar.add( +// (OWN_TEAM_TITLE_COLOR.isEmpty() ? team.getColorOrWhite().toChatColor() : OWN_TEAM_TITLE_COLOR) +// /// Title of the team section in the sidebar +// + (OWN_TEAM_TITLE_IS_NAME ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) +// ); +// +// Location playerLocation = player.getLocation(); +// +// for (UUID teamMember : team.getPlayersUUID()) +// { +// SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(teamMember); +// +// // If enabled, we check if the player was already met or is close to this player. +// // Only if the damages are on (= 30 seconds after the game start) to avoid false close while +// // teleporting. +// if(OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY) +// { +// if(!(teamMember.equals(player.getUniqueId()) || cache.getTeammatesDisplayed().contains(teamMember))) +// { +// if (gameManager.isGameStarted() && gameManager.isTakingDamage()) +// { +// if (gameManager.isPlayerDead(teamMember)) +// continue; // dead (spectators don't have to be displayed in the sidebar). +// +// Player teammate = Sidebar.getPlayerAsync(teamMember); +// if (teammate == null) +// continue; // offline +// +// +// Location teammateLocation = teammate.getLocation(); +// +// // Check if the players are close +// if (teammateLocation.getWorld().equals(playerLocation.getWorld())) +// { +// final double distanceSquared = teammateLocation.distanceSquared(playerLocation); +// if (distanceSquared <= OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED) +// cache.getTeammatesDisplayed().add(teamMember); +// else +// continue; // Too far, skipped +// } +// else +// { +// continue; // Too far, skipped +// } +// } +// else +// { +// continue; +// } +// } +// } +// +// final String strike = OWN_TEAM_STRIKE_DEAD_PLAYERS && !cache.isAlive() ? ChatColor.STRIKETHROUGH.toString() : ""; +// final ChatColor aliveColor = cache.isAlive() ? ChatColor.WHITE : ChatColor.GRAY; +// +// final String heart = OWN_TEAM_DISPLAY_HEARTS ? cache.getHealthColor() + strike + HEART + " " : ""; +// final String name = (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) +// + strike +// + (OWN_TEAM_DISPLAY_LOGIN_STATE_ITALIC && !cache.isOnline() ? ChatColor.ITALIC : "") +// + cache.getPlayerName() +// + (!cache.isOnline() ? ChatColor.RESET + "" + (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) + " " + OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX : ""); +// +// sidebar.add(heart + name); +// } +// +// sidebar.add(""); +// } +// } +// +// sidebar.addAll(sidebarBorder); +// +// if (KILLS_IN_SIDEBAR && gameManager.isGameStarted()) +// { +// SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); +// +// /// Kills count in the sidebar +// sidebar.add(I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", cache.getPlayersKilled().size(), cache.getPlayersKilled().size())); +// sidebar.add(""); +// } +// +// sidebar.addAll(sidebarTimers); +// +// if (FREEZE_STATUS_IN_SIDEBAR) +// { +// insertFreezeStatus(sidebar, player); +// } +// +// return sidebar; + return null; } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java new file mode 100644 index 0000000..066ce7e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java @@ -0,0 +1,76 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.utils; + +import org.bukkit.entity.*; +import org.bukkit.event.entity.CreatureSpawnEvent; + +public class EntitiesUtils +{ + /** + * Checks if a spawn is natural. + * + * @param reason The spawn reason. + * @return {@code true} if it's a natural spawn (not from a player or an interaction + * with another entity, as example). + */ + public static boolean isNaturalSpawn(final CreatureSpawnEvent.SpawnReason reason) + { + switch (reason) + { + case NATURAL: + case NETHER_PORTAL: + case LIGHTNING: + case SPAWNER: + return true; + + default: + return false; + } + } + + /** + * Checks if the given mod is hostile. + * @param entity The entity. + * @return {@code true} if hostile. + */ + public static boolean isHostile(final EntityType entity) + { + final Class<? extends Entity> entityClass = entity.getEntityClass(); + + return Monster.class.isAssignableFrom(entityClass) + || Slime.class.isAssignableFrom(entityClass) + || Ghast.class.isAssignableFrom(entityClass); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java index ce123d8..1e57c03 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java @@ -34,12 +34,15 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; +import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import java.util.Arrays; + /** * Represents a sound, with volume and pitch. @@ -59,16 +62,107 @@ public class UHSound */ public UHSound(final Sound sound) { + Validate.notNull(sound, "The sound cannot be null."); this.sound = sound; } public UHSound(final Sound sound, final Float volume, final Float pitch) { + Validate.notNull(sound, "The sound cannot be null."); + this.sound = sound; this.volume = volume; this.pitch = pitch; } + /** + * Constructs a sound from a string name with volume = 1f and pitch = 1f. + * + * This allows to support automatically all Minecraft versions as sounds names changed in enum + * after version 1.10. + * + * @param sound The sound name to be looked up. + */ + public UHSound(final String sound) + { + final Sound bukkitSound = string2Sound(sound); + + if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching " + sound); + + this.sound = bukkitSound; + } + + /** + * Constructs a sound from a string name. + * + * This allows to support automatically all Minecraft versions as sounds names changed in enum + * after version 1.10. + * + * @param sound The sound name to be looked up. + * @param volume The sound volume. + * @param pitch The sound pitch. + */ + public UHSound(final String sound, final Float volume, final Float pitch) + { + final Sound bukkitSound = string2Sound(sound); + + if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching " + sound); + + this.sound = bukkitSound; + this.volume = volume; + this.pitch = pitch; + } + + /** + * Constructs a sound from string names with volume = 1f and pitch = 1f. + * + * This allows to support automatically all Minecraft versions as sounds names changed in enum + * after version 1.10. + * + * @param sound A list of sounds to be looked up. The first one found will be used. + */ + public UHSound(final String... sound) + { + Sound bukkitSound = null; + + for (String soundCandidate : sound) + { + bukkitSound = string2Sound(soundCandidate); + if (bukkitSound != null) break; + } + + if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + + this.sound = bukkitSound; + } + + /** + * Constructs a sound from a string name. + * + * This allows to support automatically all Minecraft versions as sounds names changed in enum + * after version 1.10. + * + * @param volume The sound volume. + * @param pitch The sound pitch. + * @param sound A list of sounds to be looked up. The first one found will be used. + */ + public UHSound(final Float volume, final Float pitch, final String... sound) + { + Sound bukkitSound = null; + + for (String soundCandidate : sound) + { + bukkitSound = string2Sound(soundCandidate); + if (bukkitSound != null) break; + } + + if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + + this.sound = bukkitSound; + this.volume = volume; + this.pitch = pitch; + } + /** * Constructs a sound from a configuration section. * <p> @@ -230,6 +324,9 @@ else if (!pitch.equals(other.pitch)) * "<code>ANVIL_LAND</code>", "<code>Anvil Land</code>" and "<code>ANVIL Land</code>" are recognized as * <code>Sound.ANVIL_LAND</code>, as example. * + * <p> + * If no sound match, common prefixes in the sounds name are tested. + * * @param soundName The text to be converted. * @return The corresponding Sound, or null if there isn't any match. */ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2424cd1..f46b318 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,6 +20,7 @@ lang: # You can put internal modules or refer to modules classes from other plugins. In all # cases, replace all dots in class paths by dashes. modules: + "beginning-cages": true "border-walls": true "border-warning": true "border-check": true From 92849d9ea591e6de4e9f2700d73cee8685f94988 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 5 Dec 2018 03:12:27 +0100 Subject: [PATCH 08/91] Fixed game start always slow and scoreboard incorrectly set at reload. * BUG: The game startup process was always slow, even without --slow. * BUG: When the game was reloaded, the scoreboard was incorrectly set. * OPT: Removed the old teams component and updated/commented references. --- .../amaury/UHCReloaded/UHCReloaded.java | 25 +- .../modules/core/game/GameModule.java | 20 +- .../commands/GlobalMessageCommand.java | 2 +- .../commands/commands/TeamMessageCommand.java | 2 +- .../commands/commands/ToggleChatCommand.java | 72 +- .../commands/commands/uh/UHInfosCommand.java | 5 +- .../old/commands/commands/uh/UHTPCommand.java | 11 +- .../old/events/UHGameEndsEvent.java | 8 +- .../old/events/UHTeamDeathEvent.java | 8 +- .../old/integration/UHDynmapIntegration.java | 11 +- .../UHCReloaded/old/misc/MOTDManager.java | 4 +- .../old/teams/TeamChatManager.java | 334 --------- .../UHCReloaded/old/teams/TeamColor.java | 143 ---- .../UHCReloaded/old/teams/TeamManager.java | 647 ------------------ .../old/teams/TeamsSelectorGUI.java | 254 ------- .../amaury/UHCReloaded/old/teams/UHTeam.java | 624 ----------------- .../old/teams/builder/TeamBuilderBaseGUI.java | 139 ---- .../builder/TeamBuilderStepColorGUI.java | 152 ---- .../teams/builder/TeamBuilderStepNameGUI.java | 88 --- .../builder/TeamBuilderStepPlayersGUI.java | 194 ------ .../old/teams/editor/TeamActionGUI.java | 79 --- .../old/teams/editor/TeamEditColorGUI.java | 65 -- .../old/teams/editor/TeamEditDeleteGUI.java | 103 --- .../old/teams/editor/TeamEditGUI.java | 177 ----- .../old/teams/editor/TeamEditMembersGUI.java | 123 ---- 25 files changed, 80 insertions(+), 3210 deletions(-) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 04265fa..ea84d0a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -53,8 +53,6 @@ import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; import eu.carrade.amaury.UHCReloaded.old.misc.*; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamChatManager; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamManager; import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; @@ -104,7 +102,6 @@ public class UHCReloaded extends ZPlugin implements Listener private boolean worldsLoaded = false; - private TeamManager teamManager = null; private UHGameManager gameManager = null; private SpectatorsManager spectatorsManager = null; private ScoreboardManager scoreboardManager = null; @@ -112,7 +109,6 @@ public class UHCReloaded extends ZPlugin implements Listener private RulesManager rulesManager = null; private PlayerListHeaderFooterManager playerListHeaderFooterManager = null; private RecipesManager recipesManager = null; - private TeamChatManager teamChatManager = null; private RuntimeCommandsExecutor runtimeCommandsExecutor = null; @@ -193,6 +189,11 @@ public void onEnable() } + /* *** Sets scoreboard for already-logged-in players (server reloaded) *** */ + + RunTask.nextTick(() -> Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard))); + + /* *** Ready *** */ PluginLogger.info(I.t("Ultra Hardcore plugin loaded.")); @@ -588,14 +589,6 @@ private World setDefaultWorld(final World.Environment environment, final String - /** - * Returns the team manager. - */ - public TeamManager getTeamManager() - { - return teamManager; - } - /** * Returns the game manager. */ @@ -652,14 +645,6 @@ public RecipesManager getRecipesManager() return recipesManager; } - /** - * Returns the team-chat manager. - */ - public TeamChatManager getTeamChatManager() - { - return teamChatManager; - } - /** * Returns the manager used to manage the commands executed after the start/the end of the * game (or any other moment using the generic API). diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 36dd0b8..b11c15e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -423,7 +423,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) { if (teleportationMode == TeleportationMode.NORMAL && teamsGame) { - // TODO re-add cages + dynmap integration in dedicated module using events. + // TODO re-add dynmap integration in dedicated module using events. final Location teamSpawn = unusedSpawnPoints.poll(); @@ -452,7 +452,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) { team.getPlayersUUID().forEach(player -> { - // TODO re-add cages + dynmap integration in dedicated module using events. + // TODO re-add dynmap integration in dedicated module using events. final Location playerSpawn = unusedSpawnPoints.poll(); final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player); @@ -531,10 +531,18 @@ public void onPlayerTeleportedToSpawnPoint(PlayerTeleportedToSpawnPointEvent ev) public void onTeleportationProcessComplete(AfterTeleportationPhaseEvent ev) { log().broadcastAdministrative(I.t("{cs}All teams are teleported.")); - log().broadcastAdministrative(new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) - .hover(new RawText(I.t("Click here to start the game"))) - .command(StartCommand.class) - ); + + if (slowMode) + { + log().broadcastAdministrative(new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) + .hover(new RawText(I.t("Click here to start the game"))) + .command(StartCommand.class) + ); + } + else + { + start(); + } if (Config.BROADCAST_PROGRESS.get()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java index b8ed15a..179d584 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java @@ -85,7 +85,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand message.append(arg).append(" "); } - p.getTeamChatManager().sendGlobalMessage((Player) sender, message.toString()); +// p.getTeamChatManager().sendGlobalMessage((Player) sender, message.toString()); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java index 70c9da7..87a66a2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java @@ -84,7 +84,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand message.append(arg).append(" "); } - p.getTeamChatManager().sendTeamMessage((Player) sender, message.toString()); +// p.getTeamChatManager().sendTeamMessage((Player) sender, message.toString()); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java index 9d452f9..9bec7c7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java @@ -37,9 +37,7 @@ import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -69,37 +67,37 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); } - // /togglechat - if (args.length == 0) - { - if (p.getTeamChatManager().toggleChatForPlayer((Player) sender)) - { - sender.sendMessage(I.t("{cs}You are now chatting with your team only.")); - } - else - { - sender.sendMessage(I.t("{cs}You are now chatting with everyone.")); - } - } - - // /togglechat <another team> - else - { - String teamName = UHUtils.getStringFromCommandArguments(args, 0); - UHTeam team = p.getTeamManager().getTeam(teamName); - - if (team != null) - { - if (p.getTeamChatManager().toggleChatForPlayer((Player) sender, team)) - { - sender.sendMessage(I.t("{cs}You are now chatting with the team {0}{cs}.", team.getDisplayName())); - } - } - else - { - sender.sendMessage(I.t("{ce}This team does not exists.")); - } - } +// // /togglechat +// if (args.length == 0) +// { +// if (p.getTeamChatManager().toggleChatForPlayer((Player) sender)) +// { +// sender.sendMessage(I.t("{cs}You are now chatting with your team only.")); +// } +// else +// { +// sender.sendMessage(I.t("{cs}You are now chatting with everyone.")); +// } +// } +// +// // /togglechat <another team> +// else +// { +// String teamName = UHUtils.getStringFromCommandArguments(args, 0); +// UHTeam team = p.getTeamManager().getTeam(teamName); +// +// if (team != null) +// { +// if (p.getTeamChatManager().toggleChatForPlayer((Player) sender, team)) +// { +// sender.sendMessage(I.t("{cs}You are now chatting with the team {0}{cs}.", team.getDisplayName())); +// } +// } +// else +// { +// sender.sendMessage(I.t("{ce}This team does not exists.")); +// } +// } } @Override @@ -109,10 +107,10 @@ public List<String> tabComplete(CommandSender sender, String[] args) { ArrayList<String> teamNames = new ArrayList<>(); - for (UHTeam team : p.getTeamManager().getTeams()) - { - teamNames.add(team.getName()); - } +// for (UHTeam team : p.getTeamManager().getTeams()) +// { +// teamNames.add(team.getName()); +// } return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java index fff2afb..775bab9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java @@ -37,9 +37,10 @@ import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -73,7 +74,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand sender.sendMessage(I.t("{ci}The game is not started.")); } - for (UHTeam team : p.getTeamManager().getTeams()) + for (ZTeam team : ZTeams.get().getTeams()) { for (OfflinePlayer player : team.getPlayers()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java index 37b0a21..d8d62ae 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java @@ -38,9 +38,10 @@ import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; @@ -105,8 +106,7 @@ else if (sender instanceof BlockCommandSender) // possibly /uh tp team <x> <y> <z> <team ...> if (args.length >= 6) { - String teamName = UHUtils.getStringFromCommandArguments(args, 4); - UHTeam team = p.getTeamManager().getTeam(teamName); + final ZTeam team = ZTeams.get().getTeamByName(UHUtils.getStringFromCommandArguments(args, 4)); // ok, the team exists. if (team != null) @@ -134,8 +134,7 @@ else if (sender instanceof BlockCommandSender) // /uh tp team <target> <team ...> if (args.length >= 3) { - String teamName = UHUtils.getStringFromCommandArguments(args, 2); - UHTeam team = p.getTeamManager().getTeam(teamName); + final ZTeam team = ZTeams.get().getTeamByName(UHUtils.getStringFromCommandArguments(args, 2)); if (team == null) { @@ -228,7 +227,7 @@ public List<String> tabComplete(CommandSender sender, String[] args) else if (args.length > 1 && args[0].equalsIgnoreCase("team")) { ArrayList<String> teamNames = new ArrayList<>(); - for (UHTeam team : this.p.getTeamManager().getTeams()) + for (ZTeam team : ZTeams.get().getTeams()) { teamNames.add(team.getName()); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java index 83482ea..eac5a97 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.events; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; +import fr.zcraft.zteams.ZTeam; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -40,10 +40,10 @@ public class UHGameEndsEvent extends Event implements Cancellable { - private UHTeam winner; + private ZTeam winner; private boolean cancelled = false; - public UHGameEndsEvent(UHTeam winner) + public UHGameEndsEvent(ZTeam winner) { this.winner = winner; } @@ -53,7 +53,7 @@ public UHGameEndsEvent(UHTeam winner) * * @return The team. */ - public UHTeam getWinnerTeam() + public ZTeam getWinnerTeam() { return winner; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java index e1e549d..65a06b7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.events; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; +import fr.zcraft.zteams.ZTeam; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -42,9 +42,9 @@ */ public class UHTeamDeathEvent extends Event { - private UHTeam team; + private ZTeam team; - public UHTeamDeathEvent(UHTeam team) + public UHTeamDeathEvent(ZTeam team) { this.team = team; } @@ -54,7 +54,7 @@ public UHTeamDeathEvent(UHTeam team) * * @return The team. */ - public UHTeam getTeam() + public ZTeam getTeam() { return team; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java index 95a0c90..47a8d14 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java @@ -34,10 +34,11 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.colors.TeamColor; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; @@ -201,7 +202,7 @@ private String getDeathMarkerName(Player player) * @param team The team. * @param spawnPoint The location of the spawn point. */ - public void showSpawnLocation(UHTeam team, Location spawnPoint) + public void showSpawnLocation(ZTeam team, Location spawnPoint) { if (!isDynmapIntegrationEnabled()) { @@ -251,7 +252,7 @@ public void showSpawnLocation(OfflinePlayer player, Location spawnPoint) { if (player == null) return; - UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); + ZTeam team = ZTeams.get().getTeamForPlayer(player); showSpawnLocation(player, team != null && team.getColor() != null ? team.getColor() : null, spawnPoint); } @@ -384,7 +385,7 @@ private void showSpawnLocation(Location spawnPoint, TeamColor color, String labe * @param team The team. * @return The ID. */ - private String getSpawnMarkerName(UHTeam team) + private String getSpawnMarkerName(ZTeam team) { return "uhplugin.spawn." + team.getName(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java index 364d8af..f072314 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java @@ -34,8 +34,8 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; import org.bukkit.ChatColor; @@ -128,7 +128,7 @@ public void updateMOTDDuringGame() * * @param winner The winner. */ - public void updateMOTDAfterGame(UHTeam winner) + public void updateMOTDAfterGame(ZTeam winner) { if (enabled) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java deleted file mode 100644 index 6c06ba9..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamChatManager.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.MessageSender; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - - -public class TeamChatManager -{ - private final UHCReloaded p; - - private final Set<UUID> teamChatLocked = new HashSet<>(); - private final Map<UUID, UHTeam> otherTeamChatLocked = new HashMap<>(); - private final Set<UUID> globalSpies = new HashSet<>(); - - public TeamChatManager(UHCReloaded p) - { - this.p = p; - } - - /** - * Sends a team-message from the given sender. - * - * @param sender The sender. - * @param message The message to send. - */ - public void sendTeamMessage(Player sender, String message) - { - sendTeamMessage(sender, message, null); - } - - /** - * Sends a team-message from the given sender. - * - * @param sender The sender. - * @param message The message to send. - * @param team If not null, this message will be considered as an external message from another player to this team. - */ - public void sendTeamMessage(Player sender, String message, UHTeam team) - { - // Permission check - if (team == null && !sender.hasPermission("uh.teamchat.self")) - { - sender.sendMessage(I.t("{ce}You are not allowed to send a private message to your team.")); - return; - } - if (team != null && !sender.hasPermission("uh.teamchat.others")) - { - sender.sendMessage(I.t("{ce}You are not allowed to enter in the private chat of another team.")); - return; - } - - final String rawMessage; - final UHTeam recipient; - - if (team == null) - { - /// Format of a private team message from a team member. {0} = sender display name, {1} = message. - rawMessage = I.t("{gold}[{0}{gold} -> his team] {reset}{1}", sender.getDisplayName(), message); - recipient = p.getTeamManager().getTeamForPlayer(sender); - - if (recipient == null) - { - /// Error message if someone try to send a team private message out of any team - sender.sendMessage(I.t("{ce}You are not in a team!")); - return; - } - } - else - { - /// Format of a private team message from a non-team-member. {0} = sender display name, {1} = team display name, {2} = message. - rawMessage = I.t("{gold}[{0}{gold} -> team {1}{gold}] {reset}{2}", sender.getDisplayName(), team.getDisplayName(), message); - recipient = team; - } - - sendRawTeamMessage(sender, rawMessage, recipient); - } - - /** - * Sends a raw team-message from the given player. - * - * @param sender The sender of this message. - * @param rawMessage The raw message to be sent. - * @param team The recipient of this message. - */ - private void sendRawTeamMessage(final Player sender, String rawMessage, UHTeam team) - { - // The message is sent to the players of the team... - team.getOnlinePlayers().forEach(player -> MessageSender.sendChatMessage(player, rawMessage)); - - // ... to the spies ... - if (otherTeamChatLocked.containsValue(team)) - { - // The message is only sent to the spies not in the team, to avoid double messages - otherTeamChatLocked.keySet().stream() - .filter(playerId -> otherTeamChatLocked.get(playerId).equals(team)) - .filter(playerId -> !team.containsPlayer(playerId)) - .forEach(playerId -> MessageSender.sendChatMessage(p.getServer().getPlayer(playerId), rawMessage)); - } - - // ... to the global spies ... - globalSpies.stream() - .filter(playerId -> !team.containsPlayer(playerId)) - .forEach(playerId -> p.getServer().getPlayer(playerId).sendMessage(rawMessage)); - - // ... and to the console. - if (UHConfig.TEAMS_OPTIONS.TEAM_CHAT.LOG.get()) - { - p.getServer().getConsoleSender().sendMessage(rawMessage); - } - - RunTask.later(() -> ProTips.LOCK_CHAT.sendTo(sender), 30L); - } - - /** - * Sends a global message from the given player. - * - * @param sender The sender of this message. - * @param message The message to be sent. - */ - public void sendGlobalMessage(Player sender, String message) - { - // This message will be sent synchronously. - // The players' messages are sent asynchronously. - // That's how we differentiates the messages sent through /g and the messages sent using - // the normal chat. - sender.chat(message); - } - - - /** - * Toggles the chat between the global chat and the team chat. - * - * @param player The chat of this player will be toggled. - * @return {@code true} if the chat is now the team chat; false else. - */ - public boolean toggleChatForPlayer(Player player) - { - return toggleChatForPlayer(player, null); - } - - /** - * Toggles the chat between the global chat and the team chat. - * - * @param player The chat of this player will be toggled. - * @param team The team to chat with. If null, the player's team will be used. - * @return {@code true} if the chat is now the team chat; false else. - */ - public boolean toggleChatForPlayer(final Player player, UHTeam team) - { - // Permission check - if (team == null && !player.hasPermission("uh.teamchat.self")) - { - player.sendMessage(I.t("{ce}You are not allowed to send a private message to your team.")); - return false; - } - if (team != null && !player.hasPermission("uh.teamchat.others")) - { - player.sendMessage(I.t("{ce}You are not allowed to enter in the private chat of another team.")); - return false; - } - - - // If the team is not null, we will always go to the team chat - // Else, normal toggle - - if (team != null) - { - // if the player was in another team chat before, we removes it. - teamChatLocked.remove(player.getUniqueId()); - otherTeamChatLocked.put(player.getUniqueId(), team); - - return true; - } - - else - { - if (isAnyTeamChatEnabled(player)) - { - teamChatLocked.remove(player.getUniqueId()); - otherTeamChatLocked.remove(player.getUniqueId()); - - return false; - } - else - { - teamChatLocked.add(player.getUniqueId()); - RunTask.later(() -> ProTips.USE_G_COMMAND.sendTo(player), 10L); - - return true; - } - } - } - - /** - * Returns true if the team chat is enabled for the given player. - * - * @param player The player. - * @param team If non-null, this will check if the given player is spying the current team. - * @return {@code true} if the team chat is enabled for the given player. - */ - public boolean isTeamChatEnabled(Player player, UHTeam team) - { - if (team == null) - { - return teamChatLocked.contains(player.getUniqueId()); - } - else - { - final UHTeam lockedTeam = this.otherTeamChatLocked.get(player.getUniqueId()); - final UHTeam playerTeam = p.getTeamManager().getTeamForPlayer(player); - - return (lockedTeam != null && lockedTeam.equals(team)) || (playerTeam != null && playerTeam.equals(team)); - } - } - - /** - * Returns true if the team chat is enabled for the given player. - * - * @param player The player. - * @return {@code true} if the team chat is enabled for the given player. - */ - public boolean isTeamChatEnabled(Player player) - { - return this.isTeamChatEnabled(player, null); - } - - /** - * Returns true if the given player is in the team chat of another team. - * - * @param player The player. - * @return {@code true} if the given player is in the team chat of another team. - */ - public boolean isOtherTeamChatEnabled(Player player) - { - return otherTeamChatLocked.containsKey(player.getUniqueId()); - } - - /** - * Returns true if a team chat is enabled for the given player. - * - * @param player The player. - * @return {@code true} if a team chat is enabled for the given player. - */ - public boolean isAnyTeamChatEnabled(Player player) - { - return (teamChatLocked.contains(player.getUniqueId()) || otherTeamChatLocked.containsKey(player.getUniqueId())); - } - - /** - * Returns the other team viewed by the given player, or null if the player is not in - * the chat of another team. - * - * @param player The player. - * @return The other team viewed by the given player. - */ - public UHTeam getOtherTeamEnabled(Player player) - { - return otherTeamChatLocked.get(player.getUniqueId()); - } - - - /** - * Registers a player receiving ALL the teams chats. - * - * @param id The spy's UUID. - */ - public void addGlobalSpy(UUID id) - { - globalSpies.add(id); - } - - /** - * Stops a player from receiving ALL the teams chats. - * - * @param id The spy's UUID. - */ - public void removeGlobalSpy(UUID id) - { - globalSpies.remove(id); - } - - /** - * Checks if the given player receives all the teams chats. - * - * @param id The spy's UUID. - * @return {@code true} if spying. - */ - public boolean isGlobalSpy(UUID id) - { - return globalSpies.contains(id); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java deleted file mode 100644 index a30a525..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamColor.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams; - -import org.bukkit.ChatColor; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - - -/** - * Represents a team color. - * - * Also used to convert a string to a ChatColor object. - */ -public enum TeamColor -{ - AQUA("Aqua", ChatColor.AQUA), - BLACK("Black", ChatColor.BLACK), - BLUE("Blue", ChatColor.BLUE), - DARK_AQUA("Darkaqua", ChatColor.DARK_AQUA), - DARK_BLUE("Darkblue", ChatColor.DARK_BLUE), - DARK_GRAY("Darkgray", ChatColor.DARK_GRAY), - DARK_GREEN("Darkgreen", ChatColor.DARK_GREEN), - DARK_PURPLE("Darkpurple", ChatColor.DARK_PURPLE), - DARK_RED("Darkred", ChatColor.DARK_RED), - GOLD("Gold", ChatColor.GOLD), - GRAY("Gray", ChatColor.GRAY), - GREEN("Green", ChatColor.GREEN), - LIGHT_PURPLE("Lightpurple", ChatColor.LIGHT_PURPLE), - RED("Red", ChatColor.RED), - WHITE("White", ChatColor.WHITE), - YELLOW("Yellow", ChatColor.YELLOW), - - RANDOM("?", null); // Must be the last one. - - - private static Map<ChatColor, TeamColor> BY_CHAT_COLOR = new HashMap<>(); - - static - { - Arrays.stream(values()) - .filter(color -> color.toChatColor() != null) - .forEach(color -> BY_CHAT_COLOR.put(color.toChatColor(), color)); - } - - - private String name; - private ChatColor color; - - TeamColor(String name, ChatColor color) - { - this.name = name; - this.color = color; - } - - public ChatColor toChatColor() - { - return this.color; - } - - /** - * Returns a ChatColor object from a string. - * - * @param name The name of the color. - * @return The ChatColor object (null if RANDOM or not found). - */ - public static ChatColor getChatColorByName(String name) - { - return Arrays.stream(values()) - .filter(color -> color.name.equalsIgnoreCase(name)) - .findFirst() - .map(color -> color.color) - .orElse(null); - } - - /** - * Case&trim-insensitive version of {@link #valueOf(String)}. - * - * @param name The name to get. - * @return A TeamColor value, or null if no value found. - */ - public static TeamColor fromString(String name) - { - if (name.equals("?")) - { - return RANDOM; - } - - try - { - return valueOf(name.trim().toUpperCase()); - } - catch (IllegalArgumentException e) - { - // Maybe a color without underscore - return Arrays.stream(values()) - .filter(color -> color.name.equalsIgnoreCase(name)) - .findFirst().orElse(null); - } - } - - /** - * Returns the TeamColor enum member associated to the given ChatColor. - * - * @param color The ChatColor. - * @return The corresponding TeamColor. - */ - public static TeamColor fromChatColor(ChatColor color) - { - return BY_CHAT_COLOR.get(color); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java deleted file mode 100644 index cd43f38..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamManager.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditDeleteGUI; -import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditGUI; -import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditMembersGUI; -import fr.zcraft.zlib.components.configuration.ConfigurationParseException; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.text.ActionBar; -import fr.zcraft.zlib.tools.text.RawMessage; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.BannerMeta; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; -import java.util.Set; - - -public class TeamManager -{ - private final int MAX_PLAYERS_PER_TEAM; - - private final UHCReloaded p; - private final HashSet<UHTeam> teams = new HashSet<>(); - - - public TeamManager() - { - p = UHCReloaded.get(); - - MAX_PLAYERS_PER_TEAM = UHConfig.TEAMS_OPTIONS.MAX_PLAYERS_PER_TEAM.get(); - } - - /** - * Is the given team registered? - * - * @param team The team. - * @return {@code true} if the team is registered. - */ - public boolean isTeamRegistered(UHTeam team) - { - return teams.contains(team); - } - - /** - * Is the given team registered? - * - * @param name The name of the team. - * @return {@code true} if the team is registered. - */ - public boolean isTeamRegistered(String name) - { - return getTeam(name) != null; - } - - - /** - * Adds a team. - * - * @param color The color. - * @param name The name of the team. - * - * @return The new team. - * - * @throws IllegalArgumentException if a team with the same name already exists. - */ - public UHTeam addTeam(TeamColor color, String name) - { - if (isTeamRegistered(name)) - { - throw new IllegalArgumentException("There is already a team named " + name + " registered!"); - } - - final UHTeam team = new UHTeam(name, generateColor(color)); - teams.add(team); - - updateGUIs(); - - return team; - } - - /** - * Adds a team. A name is generated based on the color. - * - * @param color The color. - * - * @return The new team. - * - * @throws IllegalArgumentException if a team with the same name already exists. - */ - public UHTeam addTeam(TeamColor color) - { - color = generateColor(color); - String teamName = color.toString().toLowerCase(); - - if (isTeamRegistered(teamName)) // Taken! - { - Random rand = new Random(); - do - { - teamName = color.toString().toLowerCase() + rand.nextInt(1000); - } while (isTeamRegistered(teamName)); - } - - final UHTeam team = new UHTeam(teamName, color); - teams.add(team); - - updateGUIs(); - - return team; - } - - /** - * Adds a team from an UHTeam object. - * - * @param team The team. - * @return The new team. - * - * @throws IllegalArgumentException if a team with the same name already exists. - */ - public UHTeam addTeam(final UHTeam team) - { - if (isTeamRegistered(team)) - { - throw new IllegalArgumentException("There is already a team named " + team.getName() + " registered!"); - } - - teams.add(team); - - updateGUIs(); - - return team; - } - - /** - * Deletes a team. - * - * @param team The team to delete. - * @param dontNotify If true, the player will not be notified about the leave. - * @return boolean True if a team was removed. - */ - public boolean removeTeam(UHTeam team, boolean dontNotify) - { - if (team != null) - { - if (dontNotify) - { - team.getPlayers().forEach(player -> this.removePlayerFromTeam(player, true)); - } - - team.deleteTeam(); - } - - final boolean removed = teams.remove(team); - - updateGUIs(); - - return removed; - } - - /** - * Deletes a team. - * - * @param team The team to delete. - * @return boolean True if a team was removed. - */ - public boolean removeTeam(UHTeam team) - { - return removeTeam(team, false); - } - - /** - * Deletes a team. - * - * @param name The name of the team to delete. - * @return boolean True if a team was removed. - */ - public boolean removeTeam(String name) - { - return removeTeam(getTeam(name), false); - } - - /** - * Deletes a team. - * - * @param name The name of the team to delete. - * @param dontNotify If true, the player will not be notified about the leave. - * @return boolean True if a team was removed. - */ - public boolean removeTeam(String name, boolean dontNotify) - { - return removeTeam(getTeam(name), dontNotify); - } - - /** - * Adds a player to a team. - * - * @param teamName The team in which we adds the player. - * @param player The player to add. - * @throws IllegalArgumentException if the team does not exists. - */ - public void addPlayerToTeam(String teamName, OfflinePlayer player) - { - UHTeam team = getTeam(teamName); - - if (team == null) - { - throw new IllegalArgumentException("There isn't any team named" + teamName + " registered!"); - } - - team.addPlayer(player); - } - - /** - * Removes a player from his team. - * - * @param player The player to remove. - * @param dontNotify If true, the player will not be notified about the leave. - */ - public void removePlayerFromTeam(OfflinePlayer player, boolean dontNotify) - { - UHTeam team = getTeamForPlayer(player); - if (team != null) - { - team.removePlayer(player, dontNotify); - } - } - - /** - * Removes a player from his team. - * - * @param player The player to remove. - */ - public void removePlayerFromTeam(OfflinePlayer player) - { - removePlayerFromTeam(player, false); - } - - - /** - * Removes all teams. - * - * @param dontNotify If true, the player will not be notified when they leave the destroyed team. - */ - public void reset(boolean dontNotify) - { - // 1: scoreboard reset - new HashSet<>(teams).forEach(team -> this.removeTeam(team, dontNotify)); - - // 2: internal list reset - teams.clear(); - - updateGUIs(); - } - - /** - * Removes all teams. - */ - public void reset() - { - reset(false); - } - - /** - * Sets the correct display name of a player, according to his team. - * - * @param offlinePlayer The player to colorize. - */ - public void colorizePlayer(OfflinePlayer offlinePlayer) - { - if (!UHConfig.COLORIZE_CHAT.get()) - { - return; - } - - if (!offlinePlayer.isOnline()) - { - return; - } - - Player player = (Player) offlinePlayer; - - UHTeam team = getTeamForPlayer(player); - - if (team == null) - { - player.setDisplayName(player.getName()); - } - else - { - player.setDisplayName(team.getColorOrWhite().toChatColor() + player.getName() + ChatColor.RESET); - } - } - - /** - * Returns all the teams. - * - * @return The teams. - */ - public Set<UHTeam> getTeams() - { - return teams; - } - - /** - * Returns the maximal number of players in each team. - * - * @return The max. - */ - public int getMaxPlayersPerTeam() - { - return MAX_PLAYERS_PER_TEAM; - } - - /** - * Returns the UHTeam object of the team with the given name. - * - * @param name The name of the team. - * @return The team, or null if the team does not exists. - */ - public UHTeam getTeam(String name) - { - return teams.stream().filter(t -> t.getName().equalsIgnoreCase(name)).findFirst().orElse(null); - } - - /** - * Gets a player's team. - * - * @param player The player. - * @return The team of this player. - */ - public UHTeam getTeamForPlayer(OfflinePlayer player) - { - return teams.stream().filter(t -> t.containsPlayer(player.getUniqueId())).findFirst().orElse(null); - } - - /** - * Checks if two players are in the same team. - * - * @param player1 The first player. - * @param player2 The second player - * @return True if the players are in the same team, false else. - */ - public boolean inSameTeam(Player player1, Player player2) - { - return (getTeamForPlayer(player1).equals(getTeamForPlayer(player2))); - } - - /** - * Generates a color from the given color. - * <p> - * If the color is neither {@link TeamColor#RANDOM} nor {@code null}, returns the given color.<br /> - * Else, generates a random unused (if possible) color. - * - * @param color The color to be generated. - * @return A non-random color. - */ - public TeamColor generateColor(TeamColor color) - { - if (color != null && color != TeamColor.RANDOM) - { - return color; - } - - // A list of the currently used colors. - final HashSet<TeamColor> availableColors = new HashSet<TeamColor>(Arrays.asList(TeamColor.values())); - availableColors.remove(TeamColor.RANDOM); - - getTeams().stream().map(UHTeam::getColorOrWhite).forEach(availableColors::remove); - - if (availableColors.size() != 0) - { - return (TeamColor) availableColors.toArray()[(new Random()).nextInt(availableColors.size())]; - } - else - { - // length-1 so the RANDOM option is never selected. - return TeamColor.values()[(new Random()).nextInt(TeamColor.values().length - 1)]; - } - } - - /** - * Imports the teams from the configuration. - * - * @return The number of teams imported. - */ - public int importTeamsFromConfig() - { - int teamsCount = 0; - for (String teamDescription : UHConfig.TEAMS) - { - try - { //TODO: Sanitize UHTeam to allow it being loaded directly by the configuration. - addTeam(handleTeamValue(teamDescription)); - } - catch (ConfigurationParseException ex) - { - PluginLogger.warning("Invalid team value : ''{0}''.", ex.getValue()); - PluginLogger.warning("\tReason : {0}", ex.getMessage()); - } - } - - for(Entry<String, BannerMeta> bannerEntry : UHConfig.TEAM_BANNERS) - { - UHTeam team = getTeam(bannerEntry.getKey()); - if(team == null) continue; - team.setBanner(bannerEntry.getValue()); - } - - return teamsCount; - } - - /** - * Displays a chat-based GUI (using tellraw formatting) to player to select a team. - * <p> - * Nothing is displayed if the player cannot use the /join command. - * - * @param player The receiver of the chat-GUI. - */ - public void displayTeamChooserChatGUI(Player player) - { - if (!player.hasPermission("uh.player.join.self")) return; - - if (p.getGameManager().isGameRunning()) - { - if (!p.getGameManager().isGameWithTeams()) - { - return; - } - } - - player.sendMessage(ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"); - - if (p.getTeamManager().getTeams().size() != 0) - { - /// Invite displayed in the chat team selector - player.sendMessage(I.t("{gold}Click on the names below to join a team")); - - boolean displayPlayers = UHConfig.TEAMS_OPTIONS.GUI.DISPLAY_PLAYERS_IN_TEAMS.get(); - - for (UHTeam team : p.getTeamManager().getTeams()) - { - StringBuilder players = new StringBuilder(); - if (displayPlayers) - { - String bullet = "\n - "; - for (OfflinePlayer opl : team.getPlayers()) - { - if (!p.getGameManager().isGameRunning()) - { - players.append(bullet).append(opl.getName()); - } - else - { - if (p.getGameManager().isPlayerDead(opl.getUniqueId())) - { - /// Displayed in team tooltip of the chat team selector for a dead player - players.append(bullet).append(I.t("{0} ({red}dead{reset})", opl.getName())); - } - else - { - /// Displayed in team tooltip of the chat team selector for an alive player - players.append(bullet).append(I.t("{0} ({green}alive{reset})", opl.getName())); - } - } - } - } - - RawMessage.send(player, new RawText("") - .then( - MAX_PLAYERS_PER_TEAM != 0 - /// Team count with max players (ex. [3/5]) followed in-game by the team name. {0} = current count, {1} = max. - ? I.t("{gray}[{white}{0}{gray}/{white}{1}{gray}]", String.valueOf(team.getSize()), String.valueOf(MAX_PLAYERS_PER_TEAM)) - /// Team count without max players (ex. [3]) followed in-game by the team name. {0} = current count. - : I.t("{gray}[{white}{0}{gray}]", String.valueOf(team.getSize())) - ) - .hover(new RawText(I.tn("{0} player in this team", "{0} players in this team", team.getPlayers().size(), team.getPlayers().size()) + players)) - - .then(" ") - - .then(team.getName()) - .color(team.getColorOrWhite().toChatColor()) - .command("/join " + team.getName()) - .style(team.containsPlayer(player) ? ChatColor.BOLD : null) - .hover(new RawText( - team.containsPlayer(player) - /// Tooltip on the chat team selector GUI when the player is in the team. {0} = team display name. - ? I.t("You are in the team {0}", team.getDisplayName()) - /// Tooltip on the chat team selector GUI when the player is not in the team. {0} = team display name. - : I.t("Click here to join the team {0}", team.getDisplayName()) - )) - - .build() - ); - } - - if (p.getTeamManager().getTeamForPlayer(player) != null && player.hasPermission("uh.player.leave.self")) - { - RawMessage.send(player, - new RawText(I.t("{darkred}[×] {red}Click here to leave your team")).command("/leave") - ); - } - else - { - player.sendMessage(I.t("{gray}Run /join to display this again")); - } - } - else - { - // No teams. - player.sendMessage(I.t("{ce}There isn't any team available.")); - } - - player.sendMessage(ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"); - } - - - /** - * Displays the team of the given player in his action bar. - * If the player is not in a team, or the game is started, does nothing. - * - * @param player The player. - */ - public void displayTeamInActionBar(Player player) - { - UHTeam team = getTeamForPlayer(player); - if (team == null) return; - - displayTeamInActionBar(player, team); - } - - /** - * Displays the team of the given player in his action bar. - * If the player is not in a team, or the game is started, does nothing. - * - * Internal use when an instance of the team is accessible (avoids lookup). - * - * @param player The player. - * @param team The team. - */ - void displayTeamInActionBar(Player player, UHTeam team) - { - if (!UHCReloaded.get().getGameManager().isGameStarted()) - ActionBar.sendPermanentMessage(player, I.t("{gold}Your team: {0}", team.getDisplayName())); - } - - /** - * Updates the teams GUIs. Called when a team is created, deleted, or updated, - * so the GUIs update in real time. - */ - void updateGUIs() - { - Gui.update(TeamsSelectorGUI.class); - Gui.update(TeamEditGUI.class); - Gui.update(TeamEditMembersGUI.class); - Gui.update(TeamEditDeleteGUI.class); - } - - - @ConfigurationValueHandler - static public TeamColor handleTeamColorValue(String value) throws ConfigurationParseException - { - TeamColor color = TeamColor.fromString(value); - if (color == null) - throw new ConfigurationParseException("Invalid team color name.", value); - - return color; - } - - @ConfigurationValueHandler - static public UHTeam handleTeamValue(String str) throws ConfigurationParseException - { - return handleTeamValue(Arrays.asList(str.split(","))); - } - - @ConfigurationValueHandler - static public UHTeam handleTeamValue(List list) throws ConfigurationParseException - { - if (list.size() < 1) - throw new ConfigurationParseException("Not enough values, at least 1 required.", list); - if (list.size() > 2) - throw new ConfigurationParseException("Too many values, at most 2 (color, name) can be used.", list); - - if (list.size() == 1) - { - return new UHTeam(list.get(0).toString().trim(), handleTeamColorValue(list.get(0).toString())); - } - else - { - return new UHTeam(list.get(1).toString().trim(), handleTeamColorValue(list.get(0).toString())); - } - } - - @ConfigurationValueHandler - static public UHTeam handleTeamValue(Map map) throws ConfigurationParseException - { - TeamColor color = map.containsKey("color") ? handleTeamColorValue(map.get("color").toString()) : TeamColor.RANDOM; - Object name = map.containsKey("name") ? map.get("name") : map.get("color"); - - if (name == null) - throw new ConfigurationParseException("Either color or name must be specified", map); - - return new UHTeam(name.toString(), color); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java deleted file mode 100644 index 8710b28..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/TeamsSelectorGUI.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.teams.builder.TeamBuilderStepColorGUI; -import eu.carrade.amaury.UHCReloaded.old.teams.editor.TeamEditGUI; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; -import fr.zcraft.zlib.components.gui.ExplorerGui; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.gui.PromptGui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - - -public class TeamsSelectorGUI extends ExplorerGui<UHTeam> -{ - private final String TEAM_ITEM_TYPE; - private final boolean GLOW_ON_CURRENT_TEAM; - - private final TeamManager tm = UHCReloaded.get().getTeamManager(); - - public TeamsSelectorGUI() - { - TEAM_ITEM_TYPE = UHConfig.TEAMS_OPTIONS.CHEST_GUI.DISPLAY.TEAM_ITEM.get().toLowerCase(); - GLOW_ON_CURRENT_TEAM = UHConfig.TEAMS_OPTIONS.CHEST_GUI.DISPLAY.GLOW_ON_SELECTED_TEAM.get(); - } - - @Override - protected void onUpdate() - { - /// The title of the teams selector GUI. {0} = teams count. - setTitle(I.t("{black}Select a team {reset}({0})", tm.getTeams().size())); - setData(tm.getTeams().toArray(new UHTeam[tm.getTeams().size()])); - - setMode(Mode.READONLY); - setKeepHorizontalScrollingSpace(true); - - if (getPlayer().hasPermission("uh.player.renameTeam")) - { - int renameSlot = getPlayer().hasPermission("uh.team") ? getSize() - 6 : getSize() - 5; - - action("rename", renameSlot, GuiUtils.makeItem( - /// The title of a button to rename our team, in the selector GUI. - Material.BOOK_AND_QUILL, I.t("{white}Rename your team"), - /// Warning displayed in the "Rename your team" button, if the player is not in a team - tm.getTeamForPlayer(getPlayer()) == null ? GuiUtils.generateLore(I.t("{gray}You have to be in a team")) : null - )); - } - - if (getPlayer().hasPermission("uh.team")) - { - int newTeamSlot = getPlayer().hasPermission("uh.player.renameTeam") ? getSize() - 4 : getSize() - 5; - - /// The title of a button to create a new team, in the selector GUI. - action("new", newTeamSlot, GuiUtils.makeItem(Material.EMERALD, I.t("{white}New team"))); - } - } - - @Override - protected ItemStack getViewItem(UHTeam team) - { - final boolean playerInTeam = team.getPlayersUUID().contains(getPlayer().getUniqueId()); - - - // Lore - final List<String> lore = new ArrayList<>(); - - lore.add(""); - - if (team.getSize() != 0) - { - /// The "Players" title in the selector GUI, on a team's tooltip - lore.add(I.t("{blue}Players")); - for (OfflinePlayer player : team.getPlayers()) - { - /// An item of the players list in the selector GUI, on a team's tooltip - lore.add(I.t("{darkgray}- {white}{0}", player.getName())); - } - - lore.add(""); - } - - if (getPlayer().hasPermission("uh.player.join.self") && !playerInTeam) - { - if (!team.isFull()) - { - lore.add(I.t("{darkgray}» {white}Click {gray}to join this team")); - } - else - { - lore.add(I.t("{darkgray}» {red}This team is full")); - } - } - else if (getPlayer().hasPermission("uh.player.leave.self") && playerInTeam) - { - lore.add(I.t("{darkgray}» {white}Click {gray}to leave this team")); - } - - if (getPlayer().hasPermission("uh.team")) // TODO adapt with new granular permissions - { - lore.add(I.t("{darkgray}» {white}Right-click {gray}to manage this team")); - } - - - // Item - final ItemStack item; - final DyeColor dye = ColorsUtils.chat2Dye(team.getColorOrWhite().toChatColor()); - - switch (TEAM_ITEM_TYPE) - { - case "banner": - item = team.getBanner(); - break; - - case "clay": - item = new ItemStack(Material.STAINED_CLAY, 1, dye.getWoolData()); - break; - - case "glass": - item = new ItemStack(Material.STAINED_GLASS_PANE, 1, dye.getWoolData()); - break; - - case "glass_pane": - item = new ItemStack(Material.STAINED_GLASS_PANE, 1, dye.getWoolData()); - break; - - case "dye": - item = new ItemStack(Material.INK_SACK, 1, dye.getDyeData()); - break; - - default: - item = new ItemStack(Material.WOOL, 1, dye.getWoolData()); - } - - - // Title - final String title = tm.getMaxPlayersPerTeam() != 0 - /// Title of the team item in the teams selector GUI (with max). {0}: team display name. {1}: players count. {2}: max count. - ? I.t("{white}Team {0} {gray}({1}/{2})", team.getDisplayName(), team.getSize(), tm.getMaxPlayersPerTeam()) - /// Title of the team item in the teams selector GUI (without max) {0}: team display name. {1}: players count. - : I.tn("{white}Team {0} {gray}({1} player)", "{white}Team {0} {gray}({1} players)", team.getSize(), team.getDisplayName(), team.getSize()); - - return new ItemStackBuilder(item) - .title(title) - .lore(lore) - .glow(GLOW_ON_CURRENT_TEAM && playerInTeam) - .hideAttributes() - .item(); - } - - @Override - protected ItemStack getEmptyViewItem() - { - return new ItemStackBuilder(Material.BARRIER) - .title(I.t("{red}No team created")) - .lore(getPlayer().hasPermission("uh.team") - /// Subtitle of the item displayed in the teams selector GUI if there isn't anything to display. - ? GuiUtils.generateLore(I.t("{gray}Click the emerald button below to create one.")) - /// Subtitle of the item displayed in the teams selector GUI if there isn't anything to display and the player cannot create a team. - : GuiUtils.generateLore(I.t("{gray}Wait for an administrator to create one."))) - .hideAttributes() - .item(); - } - - @Override - protected ItemStack getPickedUpItem(UHTeam team) - { - final boolean playerInTeam = team.getPlayersUUID().contains(getPlayer().getUniqueId()); - - if (getPlayer().hasPermission("uh.player.join.self") && !playerInTeam) - { - try - { - team.addPlayer(getPlayer()); - } - catch (RuntimeException ignored) {} // team full, does nothing - } - else if (getPlayer().hasPermission("uh.player.leave.self") && playerInTeam) - { - team.removePlayer(getPlayer()); - } - - update(); - return null; - } - - @Override - protected void onRightClick(UHTeam team) - { - if (getPlayer().hasPermission("uh.team")) // TODO adapt with new granular permissions - { - Gui.open(getPlayer(), new TeamEditGUI(team), this); - } - else - { - getPickedUpItem(team); - } - } - - @GuiAction ("rename") - public void rename() - { - final UHTeam team = tm.getTeamForPlayer(getPlayer()); - if (team == null) return; - - Gui.open(getPlayer(), new PromptGui(team::setName, team.getName()), this); - } - - @GuiAction ("new") - public void newTeam() - { - Gui.open(getPlayer(), new TeamBuilderStepColorGUI()); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java deleted file mode 100644 index 39fd851..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/UHTeam.java +++ /dev/null @@ -1,624 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.teams; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; -import eu.carrade.amaury.UHCReloaded.utils.TextUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.items.TextualBanners; -import fr.zcraft.zlib.tools.text.ActionBar; -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Objects; -import java.util.Random; -import java.util.Set; -import java.util.UUID; - - -public class UHTeam -{ - private static final boolean BANNER_SHAPE_WRITE_LETTER = UHConfig.TEAMS_OPTIONS.BANNER.SHAPE.WRITE_LETTER.get(); - private static final boolean BANNER_SHAPE_ADD_BORDER = UHConfig.TEAMS_OPTIONS.BANNER.SHAPE.ADD_BORDER.get(); - - private static final Random random = new Random(); - - private UHCReloaded plugin = UHCReloaded.get(); - - private String name = null; - private String internalName; - private String displayName = null; - private TeamColor color = null; - private ItemStack defaultBanner = null; - private ItemStack banner = null; - - private HashSet<UUID> players = new HashSet<>(); - - - public UHTeam(String name, TeamColor color) - { - Validate.notNull(name, "The name cannot be null."); - - // We use a random internal name because the name of a team, in Minecraft vanilla, is limited - // (16 characters max). - this.internalName = String.valueOf(random.nextInt(99999999)) + String.valueOf(random.nextInt(99999999)); - - final Scoreboard sb = this.plugin.getScoreboardManager().getScoreboard(); - final Team t = sb.registerNewTeam(this.internalName); - - t.setSuffix(ChatColor.RESET.toString()); - t.setCanSeeFriendlyInvisibles(UHConfig.TEAMS_OPTIONS.CAN_SEE_FRIENDLY_INVISIBLES.get()); - t.setAllowFriendlyFire(UHConfig.TEAMS_OPTIONS.ALLOW_FRIENDLY_FIRE.get()); - - setName(name, true); - setColor(color); - updateDefaultBanner(); - } - - /** - * @deprecated Use {@link #UHTeam(String, TeamColor)} instead. - */ - @Deprecated - public UHTeam(String name, TeamColor color, UHCReloaded plugin) - { - this(name, color); - } - - /** - * Returns the name of the team. - * - * Can include spaces. - * - * @return The name. - */ - public String getName() - { - return name; - } - - public void setName(String name) - { - setName(name, false); - } - - /** - * Changes the name of this team. - * - * @param name The new name. - * @param silent if {@code true}, the players will not be notified. - */ - public void setName(String name, boolean silent) - { - if (name == null || (this.name != null && this.name.equals(name))) - return; - - this.name = name; - - updateDisplayName(); - updateDefaultBanner(); - - plugin.getTeamManager().updateGUIs(); - - for (Player player : getOnlinePlayers()) - { - if (!silent) - player.sendMessage(I.t("{cs}Your team is now called {0}{cs}.", displayName)); - - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - plugin.getTeamManager().displayTeamInActionBar(player, this); - } - } - - /** - * Returns the display name of the team. - * - * This name is: - * - if the team is uncolored, the name of the team; - * - else, the name of the team with: - * - before, the color of the team; - * - after, the "reset" formatting mark (§r). - * - * @return The display name. - */ - public String getDisplayName() - { - return displayName; - } - - private void updateDisplayName() - { - displayName = (color != null) ? color.toChatColor() + name + ChatColor.RESET : name; - - final Team t = plugin.getScoreboardManager().getScoreboard().getTeam(internalName); - if (t != null) - t.setDisplayName(displayName.substring(0, Math.min(displayName.length(), 32))); - } - - /** - * Returns the players inside this team. - * - * @return The players. - */ - public Set<OfflinePlayer> getPlayers() - { - final Set<OfflinePlayer> playersList = new HashSet<>(); - - for (UUID id : players) - { - final Player player = plugin.getServer().getPlayer(id); - if (player != null) - { - playersList.add(player); - } - else - { - playersList.add(plugin.getServer().getOfflinePlayer(id)); - } - } - - return playersList; - } - - /** - * Returns the online players inside this team. - * - * @return The online players. - */ - public Set<Player> getOnlinePlayers() - { - HashSet<Player> playersList = new HashSet<>(); - - for (UUID id : players) - { - Player player = plugin.getServer().getPlayer(id); - if (player != null && player.isOnline()) - { - playersList.add(player); - } - } - - return playersList; - } - - /** - * Returns the UUIDs of the players inside this team. - * - * @return The UUIDs of the players. - */ - @SuppressWarnings ("unchecked") - public Set<UUID> getPlayersUUID() - { - return Collections.unmodifiableSet(players); - } - - /** - * Returns the UUIDs of the online players inside this team. - * - * @return The UUID of the online players. - */ - public Set<UUID> getOnlinePlayersUUID() - { - HashSet<UUID> playersList = new HashSet<>(); - - for (UUID id : players) - { - Player player = plugin.getServer().getPlayer(id); - if (player != null && player.isOnline()) - { - playersList.add(id); - } - } - - return playersList; - } - - /** - * Returns the size of this team. - * - * @return The size. - */ - public int getSize() - { - return players.size(); - } - - /** - * Returns true if the team is empty. - * - * @return The emptiness. - */ - public boolean isEmpty() - { - return getSize() == 0; - } - - /** - * Returns true if the team is full. - * - * @return The fullness. - */ - public boolean isFull() - { - return plugin.getTeamManager().getMaxPlayersPerTeam() != 0 && getSize() >= plugin.getTeamManager().getMaxPlayersPerTeam(); - } - - /** - * Adds a player inside this team. - * - * @param player The player to add. - */ - public void addPlayer(OfflinePlayer player) - { - addPlayer(player, false); - } - - /** - * Adds a player inside this team. - * - * @param player The player to add. - * @param silent If true, the player will not be notified about this. - */ - public void addPlayer(OfflinePlayer player, boolean silent) - { - Validate.notNull(player, "The player cannot be null."); - - if (plugin.getTeamManager().getMaxPlayersPerTeam() != 0 - && this.players.size() >= plugin.getTeamManager().getMaxPlayersPerTeam()) - { - throw new RuntimeException("The team " + getName() + " is full"); - } - - plugin.getTeamManager().removePlayerFromTeam(player, true); - - players.add(player.getUniqueId()); - plugin.getScoreboardManager().getScoreboard().getTeam(this.internalName).addPlayer(player); - - plugin.getTeamManager().colorizePlayer(player); - - plugin.getTeamManager().updateGUIs(); - - if (player.isOnline()) - { - if (!silent) - ((Player) player).sendMessage(I.t("{aqua}You are now in the {0}{aqua} team.", getDisplayName())); - - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - plugin.getTeamManager().displayTeamInActionBar((Player) player, this); - } - } - - /** - * Removes a player from this team. - * - * Nothing is done if the player wasn't in this team. - * - * @param player The player to remove. - */ - public void removePlayer(OfflinePlayer player) - { - removePlayer(player, false); - } - - /** - * Removes a player from this team. - * - * Nothing is done if the player wasn't in this team. - * - * @param player The player to remove. - * @param silent If true, the player will not be notified. - */ - public void removePlayer(OfflinePlayer player, boolean silent) - { - Validate.notNull(player, "The player cannot be null."); - - players.remove(player.getUniqueId()); - unregisterPlayer(player, silent); - - plugin.getTeamManager().updateGUIs(); - } - - /** - * Unregisters a player from the scoreboard and uncolorizes the pseudo. - * - * Internal use, avoids a ConcurrentModificationException in this.deleteTeam() - * (this.players is listed and emptied simultaneously, else). - */ - private void unregisterPlayer(OfflinePlayer player, boolean silent) - { - if (player == null) return; - - plugin.getScoreboardManager().getScoreboard().getTeam(this.internalName).removePlayer(player); - plugin.getTeamManager().colorizePlayer(player); - - if (player.isOnline()) - { - if (!silent) - ((Player) player).sendMessage(I.t("{darkaqua}You are no longer part of the {0}{darkaqua} team.", getDisplayName())); - - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - ActionBar.removeMessage((Player) player, true); - } - } - - /** - * Deletes this team. - * - * The players inside the team are left without any team. - */ - public void deleteTeam() - { - // We removes the players from the team (scoreboard team too) - players.forEach(id -> unregisterPlayer(plugin.getServer().getOfflinePlayer(id), false)); - - players.clear(); - - // Then the scoreboard team is deleted. - plugin.getScoreboardManager().getScoreboard().getTeam(this.internalName).unregister(); - } - - /** - * Returns true if the given player is in this team. - * - * @param player The player to check. - * @return true if the given player is in this team. - */ - public boolean containsPlayer(Player player) - { - Validate.notNull(player, "The player cannot be null."); - - return players.contains(player.getUniqueId()); - } - - /** - * Returns true if the player with the given UUID is in this team. - * - * @param id The UUID of the player to check. - * @return true if the given player is in this team. - */ - public boolean containsPlayer(UUID id) - { - Validate.notNull(id, "The player cannot be null."); - - return players.contains(id); - } - - /** - * Teleports the entire team to the given location. - * - * @param location The location. - */ - public void teleportTo(Location location) - { - Validate.notNull(location, "The location cannot be null."); - - players.stream() - .map(id -> plugin.getServer().getPlayer(id)) - .filter(Objects::nonNull) - .filter(Player::isOnline) - .forEach(player -> player.teleport(location, TeleportCause.PLUGIN)); - } - - /** - * @return the color of the team. - */ - public TeamColor getColor() - { - return color; - } - - /** - * @return the color of the team, or white if the color is set to null. Never returns {@code null}. - */ - public TeamColor getColorOrWhite() - { - return color != null ? color : TeamColor.WHITE; - } - - /** - * Updates the team color. - * - * @param color The new color. - */ - public void setColor(TeamColor color) - { - // We don't use generateColor directly because we want to keep the "null" color. - if (color == TeamColor.RANDOM) this.color = plugin.getTeamManager().generateColor(color); - else this.color = color; - - updateDisplayName(); - - // The team color needs to be updated - if (this.color != null) - { - Team t = plugin.getScoreboardManager().getScoreboard().getTeam(internalName); - if (t != null) - t.setPrefix(this.color.toChatColor().toString()); - } - - // The players names too - for (Player player : getOnlinePlayers()) - { - plugin.getTeamManager().colorizePlayer(player); - - // Also we update the action bar if needed - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - plugin.getTeamManager().displayTeamInActionBar(player, this); - } - - // The default banner too - updateDefaultBanner(); - - plugin.getTeamManager().updateGUIs(); - } - - - /** - * Generates and return the default banner for this team, following the - * banners options in the configuration file. - * - * @return the generated banner. - */ - public ItemStack getDefaultBanner() - { - final ItemStack banner; - final DyeColor dye = ColorsUtils.chat2Dye(getColorOrWhite().toChatColor()); - - if (BANNER_SHAPE_WRITE_LETTER) - { - banner = TextualBanners.getCharBanner(Character.toUpperCase(TextUtils.getInitialLetter(name)), dye, BANNER_SHAPE_ADD_BORDER); - } - else - { - banner = new ItemStack(Material.BANNER); - BannerMeta meta = (BannerMeta) banner.getItemMeta(); - meta.setBaseColor(dye); - banner.setItemMeta(meta); - } - - return banner; - } - - /** - * Regenerates the default banner. - */ - private void updateDefaultBanner() - { - // Avoid updating in the constructor before all the object is populated. - if (name != null) - defaultBanner = getDefaultBanner(); - else - defaultBanner = new ItemStack(Material.BANNER); - } - - /** - * Updates this team's banner. - * - * @param banner The new banner. {@code null} to use the default banner. - */ - public void setBanner(ItemStack banner) - { - if (banner == null) - { - this.banner = null; - return; - } - - if (banner.getType() != Material.BANNER) - throw new IllegalArgumentException("A banner is required"); - - this.banner = new ItemStackBuilder(banner.clone()) - .title(displayName) - .amount(1) - .hideAttributes() - .item(); - - if (banner.hasItemMeta()) - { - BannerMeta meta = (BannerMeta) this.banner.getItemMeta(); - meta.setBaseColor(((BannerMeta) banner.getItemMeta()).getBaseColor()); - this.banner.setItemMeta(meta); - } - - plugin.getTeamManager().updateGUIs(); - } - - /** - * Updates this team's banner. - * - * @param banner The new banner. {@code null} to use the default banner. - */ - public void setBanner(BannerMeta banner) - { - if (banner == null) - { - this.banner = null; - return; - } - - this.banner = new ItemStackBuilder(Material.BANNER) - .title(displayName) - .amount(1) - .hideAttributes() - .item(); - - this.banner.setItemMeta(banner.clone()); - - plugin.getTeamManager().updateGUIs(); - } - - /** - * Returns this team's banner. - * - * @return the banner. - */ - public ItemStack getBanner() - { - return banner == null ? defaultBanner : banner; - } - - - @Override - public int hashCode() - { - return ((name == null) ? 0 : name.hashCode()); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof UHTeam)) - return false; - - final UHTeam other = (UHTeam) obj; - return name == null ? other.name == null : name.equals(other.name); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java deleted file mode 100644 index 06ca947..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderBaseGUI.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.builder; - -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.utils.TextUtils; -import fr.zcraft.zlib.components.gui.ActionGui; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.Collections; - - -/** - * The base of the team creator GUIs: contains the breadcrumb generator. - */ -public abstract class TeamBuilderBaseGUI extends ActionGui -{ - protected void generateBreadcrumbs(BuildingStep step) - { - for (int i = 0; i < 9; i++) - { - if (i != 1 && i != 4 && i != 7) - { - action("", i, GuiUtils.makeItem(new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.WHITE.getWoolData()), ChatColor.RESET + " ", null)); - } - else - { - final BuildingStep slotStep; - final String achievedSubtitle; - - if (i == 1) - { - slotStep = BuildingStep.COLOR; - achievedSubtitle = getColor() != null ? (getColor() == TeamColor.RANDOM ? ChatColor.WHITE + "" + ChatColor.MAGIC + "Random color" : getColor().toChatColor() + TextUtils.friendlyEnumName(getColor())) : ""; - } - else if (i == 4) - { - slotStep = BuildingStep.NAME; - achievedSubtitle = getName() != null ? ChatColor.GRAY + getName() : ""; - } - else - { - slotStep = BuildingStep.PLAYERS; - achievedSubtitle = ""; // Never displayed as achieved: it's the last one. - } - - final boolean achieved = slotStep.isAchieved(step); - - action("", i, GuiUtils.makeItem( - new ItemStack(Material.STAINED_GLASS_PANE, 1, achieved ? DyeColor.LIME.getWoolData() : DyeColor.RED.getWoolData()), - slotStep.getName(), - achieved ? Collections.singletonList(achievedSubtitle) : null - )); - } - } - } - - /** - * @return the selected color. {@code null} if not selected yet. - */ - protected abstract TeamColor getColor(); - - /** - * @return the chosen name. {@code null} if not chosen yet. - */ - protected abstract String getName(); - - - /** - * The current step used by {@link #generateBreadcrumbs(BuildingStep)} - */ - protected enum BuildingStep - { - /// The title of the first step in the team creator GUIs - COLOR (I.t("{gray}1. {white}{bold}Team color")), - /// The title of the second step in the team creator GUIs - NAME (I.t("{gray}2. {white}{bold}Team name")), - /// The title of the third step in the team creator GUIs - PLAYERS (I.t("{gray}3. {white}{bold}Team members")); - - - private final String name; - - BuildingStep(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - - /** - * Checks if this step is achieved, at the given step. - * - * @param step The current step. - * @return {@code true} if achieved. - */ - public boolean isAchieved(BuildingStep step) - { - return step.ordinal() > this.ordinal(); - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java deleted file mode 100644 index 0a3361f..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepColorGUI.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.builder; - -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; -import eu.carrade.amaury.UHCReloaded.utils.TextUtils; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitTask; - -import java.util.Random; - - -public class TeamBuilderStepColorGUI extends TeamBuilderBaseGUI -{ - private final Random randomSource = new Random(); - - private BukkitTask randomUpdate = null; - - - @Override - protected void onUpdate() - { - /// The title of the color selector GUI, in the create team GUIs - setTitle(I.t("New team » {black}Color")); - setSize(6 * 9); - - generateBreadcrumbs(BuildingStep.COLOR); - - insertColors(3); - } - - protected void insertColors(final int firstLine) - { - final int offset = (firstLine - 1) * 9; - - /// The random color button in a colors selector GUI. - action("random", offset + 4, GuiUtils.makeItem(Material.WOOL, I.t("{lightpurple}Random color"))); - - insertColor(offset + 10, ChatColor.WHITE); - insertColor(offset + 11, ChatColor.AQUA); - insertColor(offset + 12, ChatColor.BLUE); - insertColor(offset + 13, ChatColor.GREEN); - insertColor(offset + 14, ChatColor.YELLOW); - insertColor(offset + 15, ChatColor.GOLD); - insertColor(offset + 16, ChatColor.LIGHT_PURPLE); - - insertColor(offset + 19, ChatColor.RED); - insertColor(offset + 20, ChatColor.DARK_RED); - insertColor(offset + 21, ChatColor.DARK_GREEN); - insertColor(offset + 22, ChatColor.DARK_PURPLE); - insertColor(offset + 23, ChatColor.DARK_BLUE); - insertColor(offset + 24, ChatColor.DARK_AQUA); - insertColor(offset + 25, ChatColor.BLACK); - - insertColor(offset + 29, ChatColor.GRAY); - insertColor(offset + 33, ChatColor.DARK_GRAY); - - randomUpdate = RunTask.timer(() -> - { - ItemStack random = getInventory().getItem(offset + 4); - if (random != null) - random.setDurability((short) randomSource.nextInt(16)); - }, 15L, 15L); - } - - private void insertColor(int slot, ChatColor color) - { - action( - "", - slot, - new ItemStackBuilder(Material.WOOL) - .data(ColorsUtils.chat2Dye(color).getWoolData()) - .title(color, TextUtils.friendlyEnumName(color)) - .item() - ); - } - - - @GuiAction ("random") - protected void random() - { - saveColor(TeamColor.RANDOM); - } - - @Override - protected void unknown_action(String name, int slot, ItemStack item) - { - if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) - saveColor(TeamColor.fromChatColor(ChatColor.getByChar(ChatColor.getLastColors(item.getItemMeta().getDisplayName()).substring(1)))); - } - - protected void saveColor(TeamColor color) - { - Gui.open(getPlayer(), new TeamBuilderStepNameGUI(color)); - } - - @Override - protected void onClose() - { - if (randomUpdate != null) - { - randomUpdate.cancel(); - randomUpdate = null; - } - - super.onClose(); - } - - @Override - protected TeamColor getColor() { return null; } - - @Override - protected String getName() { return null; } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java deleted file mode 100644 index fe6bb13..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepNameGUI.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.builder; - -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.gui.PromptGui; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Material; - - -public class TeamBuilderStepNameGUI extends TeamBuilderBaseGUI -{ - private final TeamColor color; - - public TeamBuilderStepNameGUI(TeamColor color) - { - this.color = color; - } - - @Override - protected void onUpdate() - { - /// The title of the name selector GUI, in the create team GUIs - setTitle(I.t("New team » {black}Name")); - setSize(6 * 9); - - generateBreadcrumbs(BuildingStep.NAME); - - action("name", 22, GuiUtils.makeItem( - Material.BOOK_AND_QUILL, - /// The title of the button opening the sign to write the team name (creator GUIs) - I.t("{white}Name the team"), - /// The legend of the button opening the sign to write the team name (creator GUIs) - GuiUtils.generateLore(I.t("{gray}When clicked, a sign will open; write the name of the team inside.")) - )); - } - - @GuiAction ("name") - protected void name() - { - Gui.open(getPlayer(), new PromptGui(name -> - { - if (name.trim().isEmpty()) - Gui.open(getPlayer(), new TeamBuilderStepNameGUI(getColor())); - else - Gui.open(getPlayer(), new TeamBuilderStepPlayersGUI(getColor(), name)); - })); - } - - - @Override - protected TeamColor getColor() { return color; } - - @Override - protected String getName() { return null; } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java deleted file mode 100644 index ac58e2b..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/builder/TeamBuilderStepPlayersGUI.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.builder; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; -import eu.carrade.amaury.UHCReloaded.utils.TextUtils; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.SkullType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; - - -public class TeamBuilderStepPlayersGUI extends TeamBuilderBaseGUI -{ - private final TeamColor color; - private final String name; - - private final Set<UUID> teamMembers = new HashSet<>(); - - - public TeamBuilderStepPlayersGUI(TeamColor color, String name) - { - this.color = color; - this.name = name; - } - - @Override - protected void onUpdate() - { - /// The title of the members selector GUI, in the create team GUIs - setTitle(I.t("New team » {black}Members")); - setSize(6 * 9); - - generateBreadcrumbs(BuildingStep.PLAYERS); - - - // Players - - final Set<OfflinePlayer> players = new TreeSet<>(new OfflinePlayersComparator()); - players.addAll(OfflinePlayersLoader.getOfflinePlayers()); - - int slot = 9; - for (OfflinePlayer player : players) - { - action(player.getUniqueId().toString(), slot, generatePlayerButton(player)); - - if (slot < 44) slot++; - else break; - } - - - // Done button - - final List<String> lore = new ArrayList<>(); - lore.add(""); - - /// The summary title in the final « create the team » button of the create team GUIs - lore.add(I.t("{blue}{bold}Summary")); - - /// The team name in the final « create the team » button of the create team GUIs - lore.add(I.t("{gray}Team name: {white}{0}", getName())); - - /// The team color in the final « create the team » button of the create team GUIs - lore.add(I.t("{gray}Color: {0}", getColor() == TeamColor.RANDOM ? ChatColor.MAGIC + "Random" : getColor().toChatColor() + TextUtils.friendlyEnumName(getColor()))); - - /// The team members count in the final « create the team » button of the create team GUIs - lore.add(I.t("{gray}Members: {white}{0}", teamMembers.size())); - lore.add(""); - - for (UUID teamMember : teamMembers) - { - OfflinePlayer player = Bukkit.getOfflinePlayer(teamMember); - /// A member bullet in the final « create the team » button of the create team GUIs - lore.add(I.t("{darkgray}- {white}{0}", player != null ? player.getName() : teamMember)); - } - - /// The title of the final « create the team » button of the create team GUIs - action("done", getSize() - 5, GuiUtils.makeItem(Material.EMERALD, I.t("{green}Create the team"), lore)); - } - - private ItemStack generatePlayerButton(OfflinePlayer player) - { - ItemStack button = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal()); - SkullMeta meta = (SkullMeta) button.getItemMeta(); - - String displayName = player instanceof Player ? ((Player) player).getDisplayName() : player.getName(); - UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); - - meta.setOwner(player.getName()); - /// The title of a button to select a player (a skull button). {0} = player's display name. - meta.setDisplayName(I.t("{reset}{0}", displayName)); - meta.setLore(Arrays.asList( - player.isOnline() ? I.t("{gray}Online") : I.t("{gray}Offline"), - team != null ? I.t("{gray}Current team: {0}", team.getDisplayName()) : I.t("{gray}Current team: none"), - "", - teamMembers.contains(player.getUniqueId()) ? I.t("{lightpurple}Selected!") : I.t("{darkgray}» {white}Click {gray}to add to the team") - )); - - button.setItemMeta(meta); - return button; - } - - - @Override - protected void unknown_action(String name, int slot, ItemStack item) - { - UUID playerUUID; - try { playerUUID = UUID.fromString(name); } catch(IllegalArgumentException e) { return; } - - if (teamMembers.contains(playerUUID)) - teamMembers.remove(playerUUID); - else - teamMembers.add(playerUUID); - - update(); - } - - @GuiAction ("done") - protected void done() - { - UHTeam team = new UHTeam(getName(), getColor()); - - try - { - UHCReloaded.get().getTeamManager().addTeam(team); - getPlayer().sendMessage(I.t("{cs}Team created.")); - - teamMembers.stream().map(OfflinePlayersLoader::getOfflinePlayer).forEach(team::addPlayer); - } - catch (IllegalArgumentException e) - { - getPlayer().sendMessage(I.t("{ce}This team already exists.")); - } - - Gui.open(getPlayer(), new TeamsSelectorGUI()); - } - - - @Override - protected TeamColor getColor() { return color; } - - @Override - protected String getName() { return name; } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java deleted file mode 100644 index bb8509d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamActionGUI.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.editor; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import fr.zcraft.zlib.components.gui.ActionGui; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - - -public abstract class TeamActionGUI extends ActionGui -{ - protected final UHTeam team; - - public TeamActionGUI(UHTeam team) - { - this.team = team; - } - - /** - * Checks if the team still exists. - * @return {@code true} if the team exists. - */ - protected boolean exists() - { - return UHCReloaded.get().getTeamManager().isTeamRegistered(team); - } - - /** - * Generates the item to display if the team was deleted while a player edited the team on a GUI. - * @return the item. - */ - protected ItemStack getDeletedItem() - { - return new ItemStackBuilder(Material.BARRIER) - /// Title of the item displayed if a team was deleted while someone edited it in a GUI. - .title(I.t("{red}Team deleted")) - /// Lore of the item displayed if a team was deleted while someone edited it in a GUI. - .lore(GuiUtils.generateLore(I.t("{gray}The team {0}{gray} was deleted by another player.", team.getDisplayName()))) - .lore("") - /// Lore of the item displayed if a team was deleted while someone edited it in a GUI. - .lore(GuiUtils.generateLore(I.t("{gray}Press {white}Escape{gray} to go back to the teams list."))) - .hideAttributes() - .item(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java deleted file mode 100644 index c77444a..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditColorGUI.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.editor; - -import eu.carrade.amaury.UHCReloaded.old.teams.builder.TeamBuilderStepColorGUI; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamColor; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.i18n.I; - - -public class TeamEditColorGUI extends TeamBuilderStepColorGUI -{ - private final UHTeam team; - - public TeamEditColorGUI(UHTeam team) - { - this.team = team; - } - - @Override - protected void onUpdate() - { - /// The title of the edit team color GUI. {0} = team name (raw). - setTitle(I.t("{0} » {black}Color", team.getName())); - setSize(6 * 9); - insertColors(2); - } - - @Override - protected void saveColor(TeamColor color) - { - team.setColor(color); - Gui.open(getPlayer(), new TeamEditGUI(team), getParent().getParent()); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java deleted file mode 100644 index d756078..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditDeleteGUI.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.editor; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.teams.TeamsSelectorGUI; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - - -public class TeamEditDeleteGUI extends TeamActionGUI -{ - public TeamEditDeleteGUI(UHTeam team) - { - super(team); - } - - - @Override - protected void onUpdate() - { - /// The title of the delete team GUI. {0} = team name (raw). - setTitle(I.t("{0} » {darkred}Delete", team.getName())); - setSize(9); - - if (!exists()) - { - action("", 4, getDeletedItem()); - return; - } - - for (int slot = 0; slot < 3; slot++) - { - action("keep", slot, GuiUtils.makeItem( - new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.LIME.getWoolData()), - /// The title of the "keep" button in the delete team GUI - I.t("{green}Keep this team alive"), - null - )); - } - - action("", 4, team.getBanner()); - - for (int slot = 6; slot < 9; slot++) - { - action("delete", slot, GuiUtils.makeItem( - new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.RED.getWoolData()), - /// The title of the "delete" button in the delete team GUI - I.t("{red}Delete this team {italic}forever"), - null - )); - } - } - - - @GuiAction ("keep") - protected void keep() - { - close(); - } - - @GuiAction ("delete") - protected void delete() - { - UHCReloaded.get().getTeamManager().removeTeam(team); - Gui.open(getPlayer(), new TeamsSelectorGUI()); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java deleted file mode 100644 index 394e4a4..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditGUI.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.editor; - -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; -import eu.carrade.amaury.UHCReloaded.utils.TextUtils; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.gui.PromptGui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - - -public class TeamEditGUI extends TeamActionGUI -{ - public TeamEditGUI(UHTeam team) - { - super(team); - } - - - @Override - protected void onUpdate() - { - /// The title of the edit team GUI. {0} = team display name. - setTitle(I.t("Teams » {black}{0}", team.getDisplayName())); - setSize(36); - - if (!exists()) - { - action("", 13, getDeletedItem()); - return; - } - - // Banner - action("banner", 9, new ItemStackBuilder(team.getBanner()) - .title(team.getDisplayName()) - /// Members count in the banner description, in the team edit GUI. - .lore(GuiUtils.generateLore(I.tn("{white}{0} {gray}member", "{white}{0} {gray}members", team.getSize(), team.getSize()))) - .lore(" ") - .lore(GuiUtils.generateLore(I.t("{white}Click with a banner {gray}to update this team's banner"))) - .hideAttributes() - ); - - // Color - action("color", 11, GuiUtils.makeItem( - new ItemStack(Material.WOOL, 1, ColorsUtils.chat2Dye(team.getColorOrWhite().toChatColor()).getWoolData()), - /// Update team color button in edit GUI. - I.t("{green}Update the color"), - /// Current team color in edit GUI. {0} = formatted color name. - GuiUtils.generateLore(I.tc("current_team_color", "{gray}Current: {white}{0}", team.getColorOrWhite().toChatColor() + TextUtils.friendlyEnumName(team.getColorOrWhite()))) - )); - - // Name - action("name", 13, GuiUtils.makeItem( - Material.BOOK_AND_QUILL, - /// Rename team button in edit GUI. - I.t("{green}Rename the team"), - /// Current team name in edit GUI. {0} = raw team name. - GuiUtils.generateLore(I.tc("current_team_name", "{gray}Current: {white}{0}", team.getName())) - )); - - // Members - List<String> lore = new ArrayList<>(); - for (OfflinePlayer player : team.getPlayers()) - if (player.isOnline()) - lore.add(I.t("{green} • ") + ChatColor.RESET + player.getName()); - else - lore.add(I.t("{red} • ") + ChatColor.RESET + player.getName()); - - action("members", 15, GuiUtils.makeItem( - new ItemStack(Material.SKULL_ITEM, 1, (short) 3), - /// Update team members button in edit GUI. - I.t("{green}Add or remove players"), - lore - )); - - // Delete - action("delete", 17, GuiUtils.makeItem( - Material.BARRIER, - /// Delete team button in edit GUI. - I.t("{red}Delete this team"), - /// Warning under the "delete team" button title. - GuiUtils.generateLore(I.t("{gray}Cannot be undone")) - )); - - // Exit - action("exit", getSize() - 5, GuiUtils.makeItem( - Material.EMERALD, - /// Go back button in GUIs. - I.t("{green}« Go back") - )); - } - - - @GuiAction ("banner") - protected void banner(InventoryClickEvent ev) - { - if (ev.getCursor() != null && ev.getCursor().getType() == Material.BANNER) - { - team.setBanner(ev.getCursor()); - update(); - } - } - - @GuiAction ("color") - protected void color() - { - Gui.open(getPlayer(), new TeamEditColorGUI(team), this); - } - - @GuiAction ("name") - protected void name() - { - Gui.open(getPlayer(), new PromptGui(name -> - { - if (!name.trim().isEmpty()) team.setName(name); - }, team.getName()), this); - } - - @GuiAction ("members") - protected void members() - { - Gui.open(getPlayer(), new TeamEditMembersGUI(team), this); - } - - @GuiAction ("delete") - protected void delete() - { - Gui.open(getPlayer(), new TeamEditDeleteGUI(team), this); - } - - @GuiAction ("exit") - protected void exit() - { - close(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java deleted file mode 100644 index c2478ac..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/teams/editor/TeamEditMembersGUI.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.teams.editor; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.old.teams.UHTeam; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersComparator; -import fr.zcraft.zlib.components.gui.ExplorerGui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.SkullType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.Set; -import java.util.TreeSet; - - -public class TeamEditMembersGUI extends ExplorerGui<OfflinePlayer> -{ - private final UHTeam team; - - public TeamEditMembersGUI(UHTeam team) - { - this.team = team; - } - - - @Override - protected void onUpdate() - { - /// The title of the edit team members GUI. {0} = team name (raw). - setTitle(I.t("{0} » {black}Members", team.getName())); - setKeepHorizontalScrollingSpace(true); - - final Set<OfflinePlayer> players = new TreeSet<>(new OfflinePlayersComparator()); - players.addAll(OfflinePlayersLoader.getOfflinePlayers()); - setData(players.toArray(new OfflinePlayer[0])); - - action("back", getSize() - 5, GuiUtils.makeItem( - Material.EMERALD, - I.t("{green}« Go back") - )); - } - - @Override - protected ItemStack getViewItem(OfflinePlayer player) - { - final String displayName = player instanceof Player ? ((Player) player).getDisplayName() : player.getName(); - final UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); - - final boolean inThisTeam = this.team.equals(team); - - final ItemStack button = new ItemStackBuilder(Material.SKULL_ITEM) - .data((short) SkullType.PLAYER.ordinal()) - .title(I.t("{reset}{0}", displayName)) - .lore(player.isOnline() ? I.t("{gray}Online") : I.t("{gray}Offline")) - .lore(team != null ? I.t("{gray}Current team: {0}", team.getDisplayName()) : I.t("{gray}Current team: none")) - .loreLine() - .lore(inThisTeam ? I.t("{darkgray}» {white}Click {gray}to remove this player") : I.t("{darkgray}» {white}Click {gray}to add this player")) - .item(); - - SkullMeta meta = (SkullMeta) button.getItemMeta(); - meta.setOwner(player.getName()); - button.setItemMeta(meta); - - return button; - } - - @Override - protected ItemStack getPickedUpItem(OfflinePlayer player) - { - if (team.containsPlayer(player.getUniqueId())) - team.removePlayer(player); - else - team.addPlayer(player); - - update(); - - return null; - } - - @GuiAction ("back") - protected void back() - { - close(); - } -} From 22c8fa19040530cfcc94996d825581d15c6633b1 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 6 Dec 2018 13:48:44 +0100 Subject: [PATCH 09/91] Wait periode + beginning fixes + small fixes --- .../amaury/UHCReloaded/core/ModuleLogger.java | 2 +- .../modules/beginning/wait/Config.java | 75 ++++ .../modules/beginning/wait/WaitModule.java | 367 ++++++++++++++++++ .../modules/core/game/GameBeginning.java | 4 +- .../modules/core/game/GameModule.java | 14 + .../old/listeners/BeforeGameListener.java | 189 --------- .../old/listeners/GameListener.java | 41 -- src/main/resources/config.yml | 1 + 8 files changed, 460 insertions(+), 233 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index e0182b9..cdee9bd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -54,7 +54,7 @@ public class ModuleLogger extends Logger setParent(ZLib.getPlugin().getLogger()); setLevel(Level.ALL); - loggerName = "[" + ZLib.getPlugin().getName() + "] [" + ModuleWrapper.computeModuleName(module) + " Module] "; + loggerName = "[" + ZLib.getPlugin().getName() + "] [" + ModuleWrapper.computeModuleName(module) + "] "; } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java new file mode 100644 index 0000000..8c9db1a --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java @@ -0,0 +1,75 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.beginning.wait; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import org.bukkit.Material; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> TELEPORT_TO_SPAWN_IF_NOT_STARTED = item("teleport-to-spawn-if-not-started", true); + + public static final InventorySection INVENTORY = section("inventory", InventorySection.class); + + static public class InventorySection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> CLEAR = item("clear", true); + public final ConfigurationItem<Boolean> PREVENT_USAGE = item("prevent-usage", true); + public final ConfigurationItem<Boolean> ALLOW_FOR_BUILDERS = item("allow-for-builders", true); + } + + public static final TeamSelectorSection TEAM_SELECTOR = section("teams-selector", TeamSelectorSection.class); + + static public class TeamSelectorSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Material> ITEM = item("item", Material.NETHER_STAR); + } + + public static final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("team-in-action-bar", true); + + public static final ConfigurationItem<Boolean> ENABLE_PVP = item("enable-pvp", false); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java new file mode 100644 index 0000000..d699cfb --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -0,0 +1,367 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.beginning.wait; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.gui.Gui; +import fr.zcraft.zlib.components.gui.GuiUtils; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.text.ActionBar; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.events.PlayerJoinedTeamEvent; +import fr.zcraft.zteams.events.PlayerLeftTeamEvent; +import fr.zcraft.zteams.events.TeamUnregisteredEvent; +import fr.zcraft.zteams.events.TeamUpdatedEvent; +import fr.zcraft.zteams.guis.TeamsSelectorGUI; +import org.bukkit.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.player.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.permissions.Permissible; + + +@ModuleInfo ( + name = "Waiting phase", + description = "Manages the waiting phase: inventory, effects, modes, teleportation, etc.", + settings = Config.class +) +public class WaitModule extends UHModule +{ + @Override + protected void onEnable() + { + Bukkit.getOnlinePlayers().forEach(this::handleNewPlayer); + } + + /** + * Opens the teams selector GUI, if needed (enabled, game not started, needed item). + * + * TODO improve selector item detection. + * + * @param player The player who right-clicked an item. + * @param item The right-clicked item. + */ + private void openTeamsGUI(Player player, ItemStack item) + { + if (isGameStarted()) return; + + if (Config.TEAM_SELECTOR.ENABLED.get() + && item != null + && item.getType() == Config.TEAM_SELECTOR.ITEM.get()) + { + Gui.open(player, new TeamsSelectorGUI()); + } + } + + /** + * Sets the state of a player joining the game while the waiting phase is in progress. + * + * @param player The player to setup. + */ + private void handleNewPlayer(final Player player) + { + final boolean builder = isBuilder(player); + + if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get()) + { + final Location worldSpawn = UR.get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); + if (!UHUtils.safeTP(player, worldSpawn)) + { + player.teleport(worldSpawn.add(0, 1, 0)); + } + + if (Config.ENABLE_PVP.get()) + { + player.setBedSpawnLocation(worldSpawn, true); + } + } + + player.setHealth(player.getMaxHealth()); + player.setFoodLevel(20); + player.setSaturation(20f); + + if (!builder && Config.INVENTORY.CLEAR.get()) + { + player.getInventory().clear(); + player.getInventory().setArmorContents(null); + } + + if (Config.TEAM_SELECTOR.ENABLED.get()) + { + Material itemType = Config.TEAM_SELECTOR.ITEM.get(); + + ItemStack item = new ItemStackBuilder(itemType) + /// The title of the item given before the game to select a team + .title(I.t("{green}{bold}Select a team {gray}(Right-Click)")) + /// The lore of the item given before the game to select a team + .lore(GuiUtils.generateLore(I.t("{gray}Right-click to select your team for this game"))) + .hideAttributes() + .item(); + + final ItemStack centralItem = player.getInventory().getItem(4); + if (!builder || centralItem == null || centralItem.getType() == org.bukkit.Material.AIR) + player.getInventory().setItem(4, item); + } + + displayTeamInActionBar(player); + } + + /** + * If the configuration option is enabled, displays its team in the player's + * action bar. If the player is not in a team, the action bar is cleared. + * + * @param player The player. + */ + private void displayTeamInActionBar(final OfflinePlayer player) + { + if (!Config.TEAM_IN_ACTION_BAR.get() || player == null) return; + + final Player onlinePlayer; + + if (player instanceof Player) onlinePlayer = (Player) player; + else onlinePlayer = Bukkit.getPlayer(player.getUniqueId()); + + if (onlinePlayer == null) return; + + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + + if (team != null) + ActionBar.sendPermanentMessage(onlinePlayer, I.t("{gold}Your team: {0}", team.getDisplayName())); + else + ActionBar.removeMessage(onlinePlayer, true); + } + + @EventHandler + public void onPlayerJoin(final PlayerJoinEvent ev) + { + if (isGameStarted()) return; + + handleNewPlayer(ev.getPlayer()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerInteract(PlayerInteractEvent ev) + { + if (ev.getAction() != Action.PHYSICAL) + openTeamsGUI(ev.getPlayer(), ev.getItem()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent ev) + { + openTeamsGUI(ev.getPlayer(), ev.getPlayer().getItemInHand()); + } + + @EventHandler + public void onPlayerClick(InventoryClickEvent ev) + { + if (Config.INVENTORY.PREVENT_USAGE.get()) + { + if (isGameStarted()) return; + if (isBuilder(ev.getWhoClicked())) return; + if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; + + ev.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDrag(InventoryDragEvent ev) + { + if (Config.INVENTORY.PREVENT_USAGE.get()) + { + if (isGameStarted()) return; + if (isBuilder(ev.getWhoClicked())) return; + if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; + + ev.setCancelled(true); + } + } + + @EventHandler + public void onPlayerDrop(PlayerDropItemEvent ev) + { + if (Config.INVENTORY.PREVENT_USAGE.get()) + { + if (isGameStarted()) return; + if (isBuilder(ev.getPlayer())) return; + + ev.setCancelled(true); + } + } + + @EventHandler + public void onPlayerPickup(PlayerPickupItemEvent ev) + { + if (isGameStarted()) return; + if (isBuilder(ev.getPlayer())) return; + + if (Config.INVENTORY.PREVENT_USAGE.get()) + { + ev.setCancelled(true); + } + } + + /** + * Used to disable all damages if the game is not started. + */ + @EventHandler + public void onEntityDamage(final EntityDamageEvent ev) + { + if (ev.getEntity() instanceof Player) + { + if (!isGameStarted() + || (UR.module(GameModule.class).getPhase() == GamePhase.WAIT && !Config.ENABLE_PVP.get())) + { + ev.setCancelled(true); + } + } + } + + /** + * Used to prevent the food level from dropping if the game has not started. + */ + @EventHandler + public void onFoodUpdate(final FoodLevelChangeEvent ev) + { + if (isGameStarted()) return; + + if (ev.getEntity() instanceof Player) + { + ((Player) ev.getEntity()).setFoodLevel(20); + ((Player) ev.getEntity()).setSaturation(20f); + } + + ev.setCancelled(true); + } + + + /** + * Used to display the team in the action bar (if needed). + */ + @EventHandler + public void onTeamJoin(final PlayerJoinedTeamEvent ev) + { + displayTeamInActionBar(ev.getPlayer()); + } + + /** + * Used to display the team in the action bar (if needed). + */ + @EventHandler + public void onTeamUpdated(final TeamUpdatedEvent ev) + { + ev.getTeam().getOnlinePlayers().forEach(this::displayTeamInActionBar); + } + + /** + * Used to display the team in the action bar (if needed). + */ + @EventHandler + public void onTeamDeleted(final TeamUnregisteredEvent ev) + { + ev.getTeam().getOnlinePlayers().forEach(this::displayTeamInActionBar); + } + + /** + * Used to display the team in the action bar (if needed). + */ + @EventHandler + public void onTeamLeft(final PlayerLeftTeamEvent ev) + { + displayTeamInActionBar(ev.getPlayer()); + } + + + /** + * The action bar messages are removed when the starting phase starts. + * This listener will self-disable when the game starts. + */ + @EventHandler + public void onGameStarts(final GamePhaseChangedEvent ev) + { + switch (ev.getNewPhase()) + { + case STARTING: + Bukkit.getOnlinePlayers().forEach(player -> { + ActionBar.removeMessage(player); + + player.getInventory().clear(); + player.getInventory().setArmorContents(null); + + player.closeInventory(); + }); + break; + + case IN_GAME: + ZLib.unregisterEvents(this); + break; + } + } + + + /** + * @param player A player + * @return True if an inventory action should not be done because he is a builder. + */ + private boolean isBuilder(final Permissible player) + { + return Config.INVENTORY.ALLOW_FOR_BUILDERS.get() && player.hasPermission("uh.build"); + } + + /** + * @return If we are in the right game phase (wait). + */ + private boolean isGameStarted() + { + final GamePhase phase = UR.module(GameModule.class).getPhase(); + return phase != GamePhase.WAIT && phase != GamePhase.STARTING; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java index befecac..793045a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java @@ -91,7 +91,7 @@ public void onGameStarts(GamePhaseChangedEvent ev) inGracePeriod = false; UR.module(GameModule.class).getAliveConnectedPlayers().forEach(ActionBar::removeMessage); Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); - }, Config.BEGINNING.GRACE_PERIOD.get().getSeconds() * 20L); + }, grace.getSeconds() * 20L); /* *** Peace period (PVP disabled) *** */ @@ -135,7 +135,7 @@ public void onEntityDamage(final EntityDamageEvent ev) * Used to cancel the spawn of hostile entities on the surface only, at the beginning of the game. */ @EventHandler - public void onSurfaceCreatureSpawn(CreatureSpawnEvent ev) + public void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) { if (inMobsFreePeriod && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) && EntitiesUtils.isHostile(ev.getEntityType())) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index b11c15e..5af3593 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -561,10 +561,24 @@ public void onGameStarts(GamePhaseChangedEvent ev) getAliveConnectedPlayers().forEach(player -> { updatePlayerFlightOptions(player); + player.setFlying(false); player.setAllowFlight(false); + player.setGameMode(GameMode.SURVIVAL); + player.setHealth(player.getMaxHealth()); + + player.setFoodLevel(20); + player.setSaturation(20); + + player.getInventory().clear(); + player.getInventory().setArmorContents(null); + + player.closeInventory(); + + player.setExp(0L); + player.setLevel(0); }); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java deleted file mode 100644 index 6dbea9c..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/BeforeGameListener.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.listeners; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.*; -import org.bukkit.inventory.ItemStack; -import org.bukkit.permissions.Permissible; - - -public class BeforeGameListener implements Listener -{ - /** - * @param player A player - * @return True if an inventory action should not be done because he is a builder. - */ - private boolean excludeBuilder(Permissible player) - { - return UHConfig.BEFORE_START.INVENTORY.ALLOW_FOR_BUILDERS.get() && player.hasPermission("uh.build"); - } - - /** - * Opens the teams selector GUI, if needed (enabled, game not started, needed item). - * - * TODO improve selector item detection. - * - * @param player The player who right-clicked an item. - * @param item The right-clicked item. - */ - private void openTeamsGUI(Player player, ItemStack item) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - - if (UHConfig.BEFORE_START.TEAM_SELECTOR.ENABLED.get() - && item != null - && item.getType() == UHConfig.BEFORE_START.TEAM_SELECTOR.ITEM.get()) - { -// Gui.open(player, new TeamsSelectorGUI()); - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent ev) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - - final boolean builder = excludeBuilder(ev.getPlayer()); - - if (!builder && UHConfig.BEFORE_START.INVENTORY.CLEAR.get()) - { - ev.getPlayer().getInventory().clear(); - ev.getPlayer().getInventory().setArmorContents(null); - } - - if (UHConfig.BEFORE_START.TEAM_SELECTOR.ENABLED.get()) - { - Material itemType = UHConfig.BEFORE_START.TEAM_SELECTOR.ITEM.get(); - - ItemStack item = new ItemStackBuilder(itemType) - /// The title of the item given before the game to select a team - .title(I.t("{green}{bold}Select a team {gray}(Right-Click)")) - /// The lore of the item given before the game to select a team - .lore(GuiUtils.generateLore(I.t("{gray}Right-click to select your team for this game"))) - .hideAttributes() - .item(); - - final ItemStack centralItem = ev.getPlayer().getInventory().getItem(4); - if (!builder || centralItem == null || centralItem.getType() == org.bukkit.Material.AIR) - ev.getPlayer().getInventory().setItem(4, item); - } - - if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) - { -// UHCReloaded.get().getTeamManager().displayTeamInActionBar(ev.getPlayer()); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerInteract(PlayerInteractEvent ev) - { - if (ev.getAction() != Action.PHYSICAL) - openTeamsGUI(ev.getPlayer(), ev.getItem()); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent ev) - { - openTeamsGUI(ev.getPlayer(), ev.getPlayer().getItemInHand()); - } - - @EventHandler - public void onPlayerClick(InventoryClickEvent ev) - { - if (UHConfig.BEFORE_START.INVENTORY.PREVENT_USAGE.get()) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - if (excludeBuilder(ev.getWhoClicked())) return; - if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; - - ev.setCancelled(true); - } - } - - @EventHandler - public void onPlayerDrag(InventoryDragEvent ev) - { - if (UHConfig.BEFORE_START.INVENTORY.PREVENT_USAGE.get()) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - if (excludeBuilder(ev.getWhoClicked())) return; - if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; - - ev.setCancelled(true); - } - } - - @EventHandler - public void onPlayerDrop(PlayerDropItemEvent ev) - { - if (UHConfig.BEFORE_START.INVENTORY.PREVENT_USAGE.get()) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - if (excludeBuilder(ev.getPlayer())) return; - - ev.setCancelled(true); - } - } - - @EventHandler - public void onPlayerPickup(PlayerPickupItemEvent ev) - { - if (UHCReloaded.get().getGameManager().isGameStarted()) return; - if (excludeBuilder(ev.getPlayer())) return; - - if (UHConfig.BEFORE_START.INVENTORY.PREVENT_USAGE.get()) - { - ev.setCancelled(true); - } - } - - @EventHandler - public void onGameStarts(UHGameStartsEvent ev) - { - ZLib.unregisterEvents(this); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index dddf069..4f15093 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -52,8 +52,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerLoginEvent.Result; @@ -269,45 +267,6 @@ public void onPlayerRespawn(final PlayerRespawnEvent ev) } - /** - * Used to disable all damages if the game is not started. - * - * @param ev - */ - @EventHandler - public void onEntityDamage(final EntityDamageEvent ev) - { - if (ev.getEntity() instanceof Player) - { - if (p.getGameManager().isSlowStartInProgress() || (!p.getGameManager().isGameRunning() && !UHConfig.BEFORE_START.ENABLE_PVP.get()) || (p.getGameManager().isGameRunning() && !p.getGameManager().isTakingDamage())) - { - ev.setCancelled(true); - } - } - } - - - /** - * Used to prevent the food level from dropping if the game has not started. - * - * @param ev - */ - @EventHandler - public void onFoodUpdate(final FoodLevelChangeEvent ev) - { - if (!p.getGameManager().isGameRunning()) - { - if (ev.getEntity() instanceof Player) - { - ((Player) ev.getEntity()).setFoodLevel(20); - ((Player) ev.getEntity()).setSaturation(20f); - } - - ev.setCancelled(true); - } - } - - /** * Used to display our custom state-based MOTD (if needed). */ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f46b318..c25f890 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,6 +20,7 @@ lang: # You can put internal modules or refer to modules classes from other plugins. In all # cases, replace all dots in class paths by dashes. modules: + "beginning-wait": true "beginning-cages": true "border-walls": true "border-warning": true From d00f941c5ca921d5d2e97bd3491eae79cab31ac6 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 6 Dec 2018 15:53:51 +0100 Subject: [PATCH 10/91] Command for initial spectators + moved spectators management to dedicated module. * NEW: added command to manage spectators. * NEW: spectators are exclusively managed trough the spectators module. * NEW: spectator mode is enabled/disabled when needed. --- .../amaury/UHCReloaded/core/ModuleLogger.java | 5 +- .../UHCReloaded/game/UHGameManager.java | 4 +- .../UHCReloaded/modules/core/game/Config.java | 8 + .../modules/core/game/GameModule.java | 128 ++++++++--- .../players/AlivePlayerDeathEvent.java} | 45 +++- .../players/PlayerResurrectedEvent.java} | 11 +- .../game/events/players/TeamDeathEvent.java} | 8 +- .../game/{ => submanagers}/GameBeginning.java | 5 +- .../core/spectators/SpectatorsModule.java | 141 +++++++++++- .../commands/SpectatorsCommand.java | 147 +++++++++++++ .../old/commands/commands/UHRootCommand.java | 1 - .../commands/uh/UHSpectatorsCommand.java | 205 ------------------ .../old/listeners/GameListener.java | 6 +- .../scoreboard/ScoreboardListener.java | 8 +- 14 files changed, 455 insertions(+), 267 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/events/UHPlayerDeathEvent.java => modules/core/game/events/players/AlivePlayerDeathEvent.java} (67%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/events/UHPlayerResurrectedEvent.java => modules/core/game/events/players/PlayerResurrectedEvent.java} (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/events/UHTeamDeathEvent.java => modules/core/game/events/players/TeamDeathEvent.java} (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/{ => submanagers}/GameBeginning.java (96%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index cdee9bd..3f6c5f5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -37,6 +37,7 @@ import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.text.RawMessage; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.util.logging.Level; @@ -118,7 +119,7 @@ public void broadcastAdministrative(String message) player.sendMessage(message); }); - info(message); + info(ChatColor.stripColor(message)); } public void broadcastAdministrative(RawText message) @@ -129,6 +130,6 @@ public void broadcastAdministrative(RawText message) RawMessage.send(player, message); }); - info(message.toPlainText()); + info(ChatColor.stripColor(message.toPlainText())); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index 415a5fa..d1edf01 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -38,7 +38,7 @@ import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import eu.carrade.amaury.UHCReloaded.utils.UHSound; @@ -803,7 +803,7 @@ public boolean resurrectPlayerOnlineTask(Player player) players.add(player.getName()); // Event - p.getServer().getPluginManager().callEvent(new UHPlayerResurrectedEvent(player)); + p.getServer().getPluginManager().callEvent(new PlayerResurrectedEvent(player)); return true; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index fe81003..5ea5877 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -74,4 +74,12 @@ public static final class BeginningSection extends ConfigurationSection public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0)); public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 15, 0)); } + + public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); + + public static final class SidebarSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> PLAYERS = item("players", true); + public final ConfigurationItem<Boolean> TEAMS = item("teams", true); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 5af3593..4f89392 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -35,7 +35,10 @@ import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.StartCommand; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.*; +import eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers.GameBeginning; import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; @@ -58,6 +61,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitRunnable; @@ -92,12 +96,6 @@ public class GameModule extends UHModule implements Listener */ private final Set<ZTeam> aliveTeams = new HashSet<>(); - /** - * List of players connected when the game starts but who will not - * play at all, only spectate. - */ - private final Set<UUID> initialSpectators = new HashSet<>(); - /** * {@code true} if there is teams in this game. */ @@ -154,23 +152,35 @@ public List<Class<? extends Command>> getCommands() @Override public void injectIntoSidebar(Player player, SidebarInjector injector) { - injector.injectLines( - SidebarInjector.SidebarPriority.VERY_TOP, true, - I.tn("{white}{0}{gray} player", "{white}{0}{gray} players", Bukkit.getOnlinePlayers().size(), Bukkit.getOnlinePlayers().size()) - ); + final List<String> topSidebar = new ArrayList<>(); + + if (Config.SIDEBAR.PLAYERS.get()) + { + topSidebar.add(I.tn( + "{white}{0}{gray} player", "{white}{0}{gray} players", + phase == GamePhase.WAIT ? Bukkit.getOnlinePlayers().size() : alivePlayers.size() + )); + } + + if (Config.SIDEBAR.TEAMS.get() && teamsGame && phase != GamePhase.WAIT) + { + topSidebar.add(I.tn("{white}{0}{gray} team", "{white}{0}{gray} teams", aliveTeams.size())); + } + + injector.injectLines(SidebarInjector.SidebarPriority.VERY_TOP, true, topSidebar); switch (phase) { case WAIT: injector.injectLines( - SidebarInjector.SidebarPriority.TOP, true, + SidebarInjector.SidebarPriority.VERY_TOP, true, I.t("{gray}Waiting for players...") ); break; case STARTING: injector.injectLines( - SidebarInjector.SidebarPriority.TOP, true, + SidebarInjector.SidebarPriority.VERY_TOP, true, I.t("{gray}The game is starting..."), I.t("{gray}Please wait.") ); @@ -198,6 +208,21 @@ public Set<ZTeam> getAliveTeams() return Collections.unmodifiableSet(aliveTeams); } + public boolean isAlive(final OfflinePlayer player) + { + return alivePlayers.contains(player.getUniqueId()); + } + + public boolean isAlive(final UUID playerID) + { + return alivePlayers.contains(playerID); + } + + public boolean isAlive(final ZTeam team) + { + return team.getPlayersUUID().stream().anyMatch(alivePlayers::contains); + } + /** * @return the current phase of the game. */ @@ -209,11 +234,18 @@ public GamePhase getPhase() /** * Changes the phase of the game. * - * @param phase The new phase (must be after the current one, else nothing is done). + * The phase must be a phase after the current one, with two exceptions: + * the phase order can be STARTING → WAIT or END → IN_GAME. + * + * @param phase The new phase. */ public void setPhase(GamePhase phase) { - if (this.phase == null || (this.phase != phase && phase.ordinal() > this.phase.ordinal())) + if (this.phase == null + || (this.phase != phase && phase.ordinal() > this.phase.ordinal()) + || (this.phase == GamePhase.STARTING && phase == GamePhase.WAIT) + || (this.phase == GamePhase.END && phase == GamePhase.IN_GAME) + ) { final GamePhase oldPhase = this.phase; @@ -317,7 +349,11 @@ public void run() } - @EventHandler (priority = EventPriority.LOW) + + /* *** GAME STARTUP + TELEPORTATION *** */ + + + @EventHandler(priority = EventPriority.LOW) public void onGameStarting(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.STARTING) return; @@ -343,6 +379,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) Bukkit.getOnlinePlayers().stream() .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) + .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) .forEach(player -> { // We need an unique name for the team. @@ -367,19 +404,12 @@ public void onGameStarting(final GamePhaseChangedEvent ev) ZTeams.get().getTeams().stream() .flatMap(team -> team.getPlayers().stream()) .map(OfflinePlayer::getUniqueId) - .filter(player -> !initialSpectators.contains(player)) + .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) .forEach(alivePlayers::add); updateAliveTeams(); - // Enabling spectator mode for those who will not play. - - Bukkit.getOnlinePlayers() - .forEach(player -> UR.module(SpectatorsModule.class) - .getManager().setSpectating(player, initialSpectators.contains(player.getUniqueId()))); - - // We have to check if there is enough spawn points. int spawnsNeeded = teleportationMode == TeleportationMode.IGNORE_TEAMS ? alivePlayers.size() : aliveTeams.size(); @@ -406,6 +436,9 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // We clears the teams created on-the-fly onTheFlyTeams.forEach(ZTeam::deleteTeam); + // We set the phase back to WAIT. + setPhase(GamePhase.WAIT); + return; } @@ -505,7 +538,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) } @EventHandler (priority = EventPriority.LOWEST) - public void onPlayerTeleportedToSpawnPoint(PlayerTeleportedToSpawnPointEvent ev) + public void onPlayerTeleportedToSpawnPoint(final PlayerTeleportedToSpawnPointEvent ev) { Player player = Bukkit.getPlayer(ev.getPlayer().getUniqueId()); @@ -528,7 +561,7 @@ public void onPlayerTeleportedToSpawnPoint(PlayerTeleportedToSpawnPointEvent ev) } @EventHandler (priority = EventPriority.LOWEST) - public void onTeleportationProcessComplete(AfterTeleportationPhaseEvent ev) + public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev) { log().broadcastAdministrative(I.t("{cs}All teams are teleported.")); @@ -553,7 +586,7 @@ public void onTeleportationProcessComplete(AfterTeleportationPhaseEvent ev) } @EventHandler (priority = EventPriority.LOWEST) - public void onGameStarts(GamePhaseChangedEvent ev) + public void onGameStarts(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME) return; @@ -582,8 +615,49 @@ public void onGameStarts(GamePhaseChangedEvent ev) }); } + + + /* *** PLAYER OR TEAM DEATH & GAME END *** */ + + + @EventHandler + public void onPlayerDeath(final PlayerDeathEvent ev) + { + if (phase != GamePhase.IN_GAME) return; + if (!isAlive(ev.getEntity())) return; + + final AlivePlayerDeathEvent event = new AlivePlayerDeathEvent(ev); + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) + { + alivePlayers.remove(ev.getEntity().getUniqueId()); + + updateAliveTeams(); + + // We check the player's team to see if there is players left inside. + if (teamsGame) + { + final ZTeam team = ZTeams.get().getTeamForPlayer(ev.getEntity()); + if (team != null && !aliveTeams.contains(team)) + { + Bukkit.getPluginManager().callEvent(new TeamDeathEvent(team)); + } + } + + if (aliveTeams.size() <= 1) + { + setPhase(GamePhase.END); + } + } + } + + + + /* *** OTHER PLAYERS MANAGEMENT *** */ + @EventHandler - public void onPlayerJoin(PlayerJoinEvent ev) + public void onPlayerJoin(final PlayerJoinEvent ev) { updatePlayerFlightOptions(ev.getPlayer()); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java similarity index 67% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java index c4f7e1f..cd4b35e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java @@ -30,9 +30,10 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.events; +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.PlayerDeathEvent; @@ -40,20 +41,28 @@ /** * Fired when a player playing an UHC match is dead. - * <p> - * This event is called before all the action executed on player death (sound, scoreboard updates, etc.). + * + * When this event is called, the player is not yet removed from the alive + * players (i.e. {@code UR.module(GameModule.class).isAlive(ev.getPlayer())} + * will return {@code true}). + * + * If the event is cancelled, the player will die but will not be removed + * from the alive players. */ -public class UHPlayerDeathEvent extends Event +public class AlivePlayerDeathEvent extends Event implements Cancellable { - private Player player; - private PlayerDeathEvent ev; + private final Player player; + private final PlayerDeathEvent playerDeathEvent; + + private boolean cancelled = false; - public UHPlayerDeathEvent(Player player, PlayerDeathEvent ev) + public AlivePlayerDeathEvent(final PlayerDeathEvent playerDeathEvent) { - this.player = player; - this.ev = ev; + this.player = playerDeathEvent.getEntity(); + this.playerDeathEvent = playerDeathEvent; } + /** * Returns the dead player. * @return The player. @@ -64,14 +73,26 @@ public Player getPlayer() } /** - * Returns the PlayerDeathEvent under this event. - * @return The PlayerDeathEvent. + * Returns the underlying {@link PlayerDeathEvent}. + * @return The {@link PlayerDeathEvent}. */ public PlayerDeathEvent getPlayerDeathEvent() { - return ev; + return playerDeathEvent; + } + + + @Override + public boolean isCancelled() + { + return cancelled; } + @Override + public void setCancelled(boolean cancelled) + { + this.cancelled = cancelled; + } private static final HandlerList handlers = new HandlerList(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java index 5302037..6979fc9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHPlayerResurrectedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.events; +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; import org.bukkit.entity.Player; import org.bukkit.event.Event; @@ -43,15 +43,14 @@ * This event is called when: * <ul> * <li>the command {@code /uh resurrect <player>} is executed, if the target is online;</li> - * <li>the resurrected player logins, else</li> + * <li>the resurrected player logins, else.</li> * </ul> - * (i.e. when the message “the player is resurrected” is broadcasted). */ -public class UHPlayerResurrectedEvent extends Event +public class PlayerResurrectedEvent extends Event { - private Player resurrectedPlayer; + private final Player resurrectedPlayer; - public UHPlayerResurrectedEvent(Player player) + public PlayerResurrectedEvent(final Player player) { this.resurrectedPlayer = player; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java index 65a06b7..423594e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHTeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.events; +package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; import fr.zcraft.zteams.ZTeam; import org.bukkit.event.Event; @@ -40,11 +40,11 @@ /** * Event fired when the last member of a team die. */ -public class UHTeamDeathEvent extends Event +public class TeamDeathEvent extends Event { - private ZTeam team; + private final ZTeam team; - public UHTeamDeathEvent(ZTeam team) + public TeamDeathEvent(ZTeam team) { this.team = team; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 793045a..39ab0c3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -31,8 +31,11 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game; +package eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers; +import eu.carrade.amaury.UHCReloaded.modules.core.game.Config; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index a350793..7239c9c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -35,25 +35,52 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.commands.SpectatorsCommand; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.*; @ModuleInfo ( name = "Spectators manager", description = "Handles non-playing players", - when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, + when = ModuleInfo.ModuleLoadTime.POST_WORLD, can_be_disabled = false ) public class SpectatorsModule extends UHModule { private SpectatorsManager manager; + /** + * Lists players allowed to spectate. Also used for initial spectators: players who will + * never play, only spectate. + */ + private final Set<UUID> spectators = new HashSet<>(); + @Override protected void onEnable() { manager = SpectatorsManager.getInstance(); } + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(SpectatorsCommand.class); + } + /** * @return The manager instance to use to handle spectators. */ @@ -61,4 +88,116 @@ public SpectatorsManager getManager() { return manager; } + + /** + * @return The allowed spectators. + */ + public Set<UUID> getSpectators() + { + return spectators; + } + + public boolean isSpectator(final UUID playerID) + { + return spectators.contains(playerID); + } + + public boolean isSpectator(final OfflinePlayer player) + { + return spectators.contains(player.getUniqueId()); + } + + /** + * Adds a spectator. + * + * @param playerID The spectator's ID. + */ + public void addSpectator(UUID playerID) + { + spectators.add(playerID); + + if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) + manager.setSpectating(playerID, true); + } + + /** + * Adds a spectator. + * + * @param player The spectator. + */ + public void addSpectator(OfflinePlayer player) + { + addSpectator(player.getUniqueId()); + } + + /** + * Removes a spectator. + * + * @param playerID The spectator's ID. + */ + public void removeSpectator(UUID playerID) + { + spectators.add(playerID); + + if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) + manager.setSpectating(playerID, false); + } + + /** + * Removes a spectator. + * + * @param player The spectator. + */ + public void removeSpectator(OfflinePlayer player) + { + removeSpectator(player.getUniqueId()); + } + + /** + * Ensures all players are in specator mode. + * + * @param strict If true, all spectating players not in our list are removed from the spectator mode. + * Else, only players in our list are placed into spectator mode. + */ + private void ensureSpectatorMode(final boolean strict) + { + if (strict) + { + Bukkit.getOnlinePlayers().forEach(player -> manager.setSpectating(player, isSpectator(player))); + } + else + { + spectators.forEach(spectator -> manager.setSpectating(spectator, true)); + } + } + + @EventHandler + public void onGameStart(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + + ensureSpectatorMode(true); + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + addSpectator(ev.getPlayer()); + } + + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerResurrects(final PlayerResurrectedEvent ev) + { + removeSpectator(ev.getPlayer()); + } + + @EventHandler + public void onPlayerJoin(final PlayerJoinEvent ev) + { + if (UR.module(GameModule.class).getPhase().ordinal() >= GamePhase.IN_GAME.ordinal()) + { + manager.setSpectating(ev.getPlayer(), isSpectator(ev.getPlayer())); + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java new file mode 100644 index 0000000..aab3bcb --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java @@ -0,0 +1,147 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.spectators.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + + +@CommandInfo (name = "spectators", usageParameters = "[add <player>] [remove <player>]") +public class SpectatorsCommand extends Command +{ + @Override + protected void run() throws CommandException + { + // /uh spec + if (args.length == 0) + { + final Set<String> spectators = UR.module(SpectatorsModule.class) + .getSpectators().stream() + .map(uuid -> Bukkit.getOfflinePlayer(uuid).getName()) + .collect(Collectors.toSet()); + + if (spectators.size() == 0) + { + error(I.t("{ce}There isn't any spectator to list.")); + } + else + { + info(""); + info(I.tn("{ci}{0} registered spectator.", "{ci}{0} registered spectators.", spectators.size())); + + /// A list item in the startup spectators list + spectators.stream().map(spectator -> I.tc("startup_specs", "{lightpurple} - {0}", spectator)).forEach(this::info); + } + } + + else + { + switch (args[0].toLowerCase()) + { + case "add": + case "a": + // /uh spec add + if (args.length == 1) + { + throwInvalidArgument(I.t("Please add the player you want to register as spectator.")); + } + + // /uh spec add <player> + else + { + OfflinePlayersLoader.loadPlayer(args[1], player -> { + if (player == null) + { + sender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); + + if (!Bukkit.getOnlineMode()) + sender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); + + return; + } + + UR.module(SpectatorsModule.class).addSpectator(player); + sender.sendMessage(I.t("{cs}The player {0} is now a spectator.", player.getName())); + }); + } + + break; + + case "remove": + case "r": + // /uh spec remove + if (args.length == 1) + { + throwInvalidArgument(I.t("Please add the player you want to unregister from spectators.")); + } + + // /uh spec remove <player> + else + { + final OfflinePlayer oldSpectator = OfflinePlayersLoader.getOfflinePlayer(args[1]); + if (oldSpectator == null) + { + sender.sendMessage(I.t("{ce}The player {0} was not found.", args[1])); + } + else + { + UR.module(SpectatorsModule.class).removeSpectator(oldSpectator); + sender.sendMessage(I.t("{cs}The player {0} is now a player.", args[1])); + } + } + + break; + } + } + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingSubset(args[0], "add", "remove"); + else if (args.length == 2) return getMatchingPlayerNames(args[1]); + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 8a8be53..6f20040 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -53,7 +53,6 @@ public UHRootCommand(UHCReloaded plugin) // Game registerSubCommand(new UHStartCommand(p)); registerSubCommand(new UHShiftCommand(p)); - registerSubCommand(new UHSpectatorsCommand(p)); // Bugs registerSubCommand(new UHHealCommand(p)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java deleted file mode 100644 index b012e15..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHSpectatorsCommand.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -/** - * This command manages startup spectators (aka ignored players). - * - * Usage: /uh spec (doc) - * Usage: /uh spec <add|remove|list> - */ -@Command (name = "spec") -public class UHSpectatorsCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHSpectatorsCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(final CommandSender sender, final String[] args) throws CannotExecuteCommandException - { - // /uh spec - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - else - { - String subcommand = args[0]; - - if (subcommand.equalsIgnoreCase("add")) - { - // /uh spec add - if (args.length == 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - // /uh spec add <player> - else - { - OfflinePlayersLoader.loadPlayer(args[1], player -> { - if (player == null) - { - sender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); - - if (!Bukkit.getOnlineMode()) - sender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); - - return; - } - - p.getGameManager().addStartupSpectator(player); - sender.sendMessage(I.t("{cs}The player {0} is now a spectator.", player.getName())); - }); - } - } - - else if (subcommand.equalsIgnoreCase("remove")) - { - // /uh spec remove - if (args.length == 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - // /uh spec remove <player> - else - { - OfflinePlayer oldSpectator = OfflinePlayersLoader.getOfflinePlayer(args[1]); - if (oldSpectator == null) - { - sender.sendMessage(I.t("{ce}The player {0} was not found.", args[1])); - } - else - { - p.getGameManager().removeStartupSpectator(oldSpectator); - sender.sendMessage(I.t("{cs}The player {0} is now a player.", args[1])); - } - } - } - - else if (subcommand.equalsIgnoreCase("list")) - { - HashSet<String> spectators = p.getGameManager().getStartupSpectators(); - if (spectators.size() == 0) - { - sender.sendMessage(I.t("{ce}There isn't any spectator to list.")); - } - else - { - sender.sendMessage(I.tn("{ci}{0} registered spectator.", "{ci}{0} registered spectators.", spectators.size())); - sender.sendMessage(I.t("{ci}This count includes only the initial spectators.")); - - for (String spectator : spectators) - { - /// A list item in the startup spectators list - sender.sendMessage(I.tc("startup_specs", "{lightpurple} - {0}", spectator)); - } - } - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - // Manual suggestions needed because we don't use sub-commands. - if (args.length == 1) - { - return CommandUtils.getAutocompleteSuggestions(args[0], Arrays.asList("add", "remove", "list")); - } - - // /... spec remove <?> - else if (args.length == 2 && args[1].equalsIgnoreCase("remove")) - { - List<String> suggestions = new ArrayList<>(); - - for (String spectatorName : p.getGameManager().getStartupSpectators()) - { - suggestions.add(spectatorName); - } - - return CommandUtils.getAutocompleteSuggestions(args[1], suggestions); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - List<String> help = new ArrayList<>(); - - help.add(I.t("{aqua}------ Startup spectators commands ------")); - - help.add(I.t("{cc}/uh spec add <player>{ci}: adds a startup spectator.")); - help.add(I.t("{cc}/uh spec remove <player>{ci}: removes a startup spectator.")); - help.add(I.t("{cc}/uh spec list{ci}: lists the startup spectators.")); - - return help; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh spec {ci}: manages the spectators. Execute /uh spec for details.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 4f15093..22d6936 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -34,6 +34,8 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; import eu.carrade.amaury.UHCReloaded.old.events.*; @@ -108,7 +110,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) return; } - p.getServer().getPluginManager().callEvent(new UHPlayerDeathEvent(ev.getEntity(), ev)); + p.getServer().getPluginManager().callEvent(new AlivePlayerDeathEvent(ev)); // Plays sound. p.getGameManager().getDeathSound().broadcast(); @@ -705,7 +707,7 @@ public void onGameEnd(final UHGameEndsEvent ev) * - update the MOTD. */ @EventHandler - public void onPlayerResurrected(final UHPlayerResurrectedEvent ev) + public void onPlayerResurrected(final PlayerResurrectedEvent ev) { // Spectator mode disabled p.getSpectatorsManager().setSpectating(ev.getPlayer(), false); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java index ed59396..13551cf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java @@ -32,8 +32,8 @@ package eu.carrade.amaury.UHCReloaded.scoreboard; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHPlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -84,7 +84,7 @@ public void onPlayerLoseHealth(EntityDamageEvent ev) } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerDeath(UHPlayerDeathEvent ev) + public void onPlayerDeath(AlivePlayerDeathEvent ev) { onPlayerHealthChange(ev.getPlayer()); @@ -97,7 +97,7 @@ public void onPlayerDeath(UHPlayerDeathEvent ev) } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerResurrect(UHPlayerResurrectedEvent ev) + public void onPlayerResurrect(PlayerResurrectedEvent ev) { onPlayerHealthChange(ev.getPlayer()); From 38b492badf2a03c4e97476256d17fe5f47b3e5c8 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 7 Dec 2018 17:15:58 +0100 Subject: [PATCH 11/91] Death, resurrection, game end event. - This - Related commands: /uh kill+resurrect --- .../modules/core/game/GameModule.java | 126 ++++++++++++++---- .../core/game/commands/KillCommand.java | 97 ++++++++++++++ .../core/game/commands/ResurrectCommand.java | 76 +++++++++++ .../events/players/AlivePlayerDeathEvent.java | 15 ++- .../players/PlayerResurrectedEvent.java | 14 +- .../commands/SpectatorsCommand.java | 32 ++++- .../old/listeners/GameListener.java | 16 +-- .../scoreboard/ScoreboardListener.java | 4 +- 8 files changed, 328 insertions(+), 52 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 4f89392..62eb184 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -33,9 +33,12 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.KillCommand; +import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.ResurrectCommand; import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.StartCommand; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.*; import eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers.GameBeginning; @@ -146,7 +149,11 @@ protected void onEnable() @Override public List<Class<? extends Command>> getCommands() { - return Collections.singletonList(StartCommand.class); + return Arrays.asList( + StartCommand.class, + KillCommand.class, + ResurrectCommand.class + ); } @Override @@ -223,6 +230,87 @@ public boolean isAlive(final ZTeam team) return team.getPlayersUUID().stream().anyMatch(alivePlayers::contains); } + /** + * Kills a player. + * + * This method calls an event. If the event is cancelled, the player is not + * killed. + * + * @param player The player to kill. + * @return {@code true} if the player was effectively killed (event not cancelled). + */ + public boolean kill(final OfflinePlayer player) + { + return kill(player, null); + } + + /** + * Kills a player. Internal use for natural deaths. + * + * This method calls an event. If the event is cancelled, the player is not + * killed. + * + * @param player The player to kill. + * @param ev The underlying death event. + * + * @return {@code true} if the player was effectively killed (event not cancelled). + */ + private boolean kill(final OfflinePlayer player, final PlayerDeathEvent ev) + { + final AlivePlayerDeathEvent event = new AlivePlayerDeathEvent(player, ev); + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) + { + alivePlayers.remove(player.getUniqueId()); + + updateAliveTeams(); + + // We check the player's team to see if there is players left inside. + if (teamsGame) + { + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + if (team != null && !aliveTeams.contains(team)) + { + Bukkit.getPluginManager().callEvent(new TeamDeathEvent(team)); + } + } + + if (aliveTeams.size() <= 1) + { + setPhase(GamePhase.END); + } + + return true; + } + + return false; + } + + /** + * Resurrects a player and puts it into the game (even if he/she never played + * before). + * + * @param player The player to resurrect. + * @return {@code true} if the player was effectively resurrected (i.e. not already alive). + */ + public boolean resurrect(final OfflinePlayer player) + { + if (isAlive(player)) return false; + + alivePlayers.add(player.getUniqueId()); + updateAliveTeams(); + + if (aliveTeams.size() > 1 && phase == GamePhase.END) + { + setPhase(GamePhase.IN_GAME); + } + + Bukkit.getPluginManager().callEvent(new PlayerResurrectedEvent(player)); + + return true; + } + /** * @return the current phase of the game. */ @@ -239,7 +327,7 @@ public GamePhase getPhase() * * @param phase The new phase. */ - public void setPhase(GamePhase phase) + public void setPhase(final GamePhase phase) { if (this.phase == null || (this.phase != phase && phase.ordinal() > this.phase.ordinal()) @@ -626,30 +714,22 @@ public void onPlayerDeath(final PlayerDeathEvent ev) if (phase != GamePhase.IN_GAME) return; if (!isAlive(ev.getEntity())) return; - final AlivePlayerDeathEvent event = new AlivePlayerDeathEvent(ev); - Bukkit.getPluginManager().callEvent(event); - - if (!event.isCancelled()) - { - alivePlayers.remove(ev.getEntity().getUniqueId()); + kill(ev.getEntity(), ev); + } - updateAliveTeams(); + @EventHandler + public void onPlayerKilled(final AlivePlayerDeathEvent ev) + { + log().info("{0} killed", ev.getPlayer().getName()); + } - // We check the player's team to see if there is players left inside. - if (teamsGame) - { - final ZTeam team = ZTeams.get().getTeamForPlayer(ev.getEntity()); - if (team != null && !aliveTeams.contains(team)) - { - Bukkit.getPluginManager().callEvent(new TeamDeathEvent(team)); - } - } + @EventHandler + public void onPlayerResurrected(final PlayerResurrectedEvent ev) + { + log().info("{0} resurrected", ev.getPlayer().getName()); - if (aliveTeams.size() <= 1) - { - setPhase(GamePhase.END); - } - } + /// Resurrection notification. {0} = raw resurrected player name. + Bukkit.broadcastMessage(I.t("{gold}{0} returned from the dead!", ev.getPlayer().getName())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java new file mode 100644 index 0000000..3d90606 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java @@ -0,0 +1,97 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@CommandInfo (name = "kill", usageParameters = "<player>") +public class KillCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length < 1) + { + throwInvalidArgument(I.t("You must specify the player to kill.")); + } + + final OfflinePlayer player = Arrays.stream(Bukkit.getOfflinePlayers()) + .filter(pl -> pl.getName().equalsIgnoreCase(args[0])) + .findAny().orElse(null); + + if (player == null) + { + error(I.t("{ce}This player was never seen on this server.")); + return; + } + + if (UR.module(GameModule.class).isAlive(player)) + { + UR.module(GameModule.class).kill(player); + + success(I.t("{cs}The player {0} is now marked as dead.", player.getName())); + } + else + { + error(I.t("{ce}{0} is not an alive player.", player.getName())); + } + } + + @Override + protected List<String> complete() + { + if (args.length == 1) + { + return getMatchingSubset( + UR.module(GameModule.class) + .getAlivePlayers().stream() + .map(OfflinePlayer::getName) + .collect(Collectors.toList()), + args[0] + ); + } + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java new file mode 100644 index 0000000..df73637 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java @@ -0,0 +1,76 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; + +import java.util.Arrays; + + +@CommandInfo (name = "resurrect", usageParameters = "<player>", aliases = {"revive", "undead"}) +public class ResurrectCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length != 1) + { + throwInvalidArgument(I.t("You must specify the player to resurrect.")); + } + + final OfflinePlayer player = Arrays.stream(Bukkit.getOfflinePlayers()) + .filter(pl -> pl.getName().equalsIgnoreCase(args[0])) + .findAny().orElse(null); + + if (player == null) + { + error(I.t("{ce}This player was never seen on this server.")); + } + else if (UR.module(GameModule.class).resurrect(player)) + { + success(I.t("{0} was resurrected.", player.getName())); + } + else + { + error(I.t("{ce}This player is not playing or dead!")); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java index cd4b35e..764f700 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; -import org.bukkit.entity.Player; +import org.bukkit.OfflinePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -51,29 +51,30 @@ */ public class AlivePlayerDeathEvent extends Event implements Cancellable { - private final Player player; + private final OfflinePlayer player; private final PlayerDeathEvent playerDeathEvent; private boolean cancelled = false; - public AlivePlayerDeathEvent(final PlayerDeathEvent playerDeathEvent) + public AlivePlayerDeathEvent(final OfflinePlayer player, final PlayerDeathEvent playerDeathEvent) { - this.player = playerDeathEvent.getEntity(); + this.player = player; this.playerDeathEvent = playerDeathEvent; } - /** * Returns the dead player. * @return The player. */ - public Player getPlayer() + public OfflinePlayer getPlayer() { return player; } /** - * Returns the underlying {@link PlayerDeathEvent}. + * Returns the underlying {@link PlayerDeathEvent}. Can be {@code null} if the player + * was killed using {@code /uh kill} or programmatically. + * * @return The {@link PlayerDeathEvent}. */ public PlayerDeathEvent getPlayerDeathEvent() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java index 6979fc9..69bd949 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java @@ -32,25 +32,19 @@ package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; -import org.bukkit.entity.Player; +import org.bukkit.OfflinePlayer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** * Called when a player is resurrected. - * <p> - * This event is called when: - * <ul> - * <li>the command {@code /uh resurrect <player>} is executed, if the target is online;</li> - * <li>the resurrected player logins, else.</li> - * </ul> */ public class PlayerResurrectedEvent extends Event { - private final Player resurrectedPlayer; + private final OfflinePlayer resurrectedPlayer; - public PlayerResurrectedEvent(final Player player) + public PlayerResurrectedEvent(final OfflinePlayer player) { this.resurrectedPlayer = player; } @@ -60,7 +54,7 @@ public PlayerResurrectedEvent(final Player player) * * @return The player. */ - public Player getPlayer() + public OfflinePlayer getPlayer() { return resurrectedPlayer; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java index aab3bcb..7e11e61 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java @@ -43,12 +43,13 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.stream.Collectors; -@CommandInfo (name = "spectators", usageParameters = "[add <player>] [remove <player>]") +@CommandInfo (name = "spectators", usageParameters = "[add <player>] [remove <player>]", aliases = {"spec", "sp"}) public class SpectatorsCommand extends Command { @Override @@ -141,7 +142,34 @@ protected void run() throws CommandException protected List<String> complete() { if (args.length == 1) return getMatchingSubset(args[0], "add", "remove"); - else if (args.length == 2) return getMatchingPlayerNames(args[1]); + else if (args.length == 2) + { + switch (args[0].toLowerCase()) + { + case "add": + case "a": + return getMatchingSubset( + Arrays.stream(Bukkit.getOfflinePlayers()) + .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) + .map(OfflinePlayer::getName) + .collect(Collectors.toList()), + args[1] + ); + + case "remove": + case "r": + return getMatchingSubset( + Arrays.stream(Bukkit.getOfflinePlayers()) + .filter(player -> UR.module(SpectatorsModule.class).isSpectator(player)) + .map(OfflinePlayer::getName) + .collect(Collectors.toList()), + args[1] + ); + + default: + return null; + } + } else return null; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 22d6936..07ce53c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -34,11 +34,13 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.*; +import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; +import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameEndsEvent; +import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.utils.UHSound; @@ -110,7 +112,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) return; } - p.getServer().getPluginManager().callEvent(new AlivePlayerDeathEvent(ev)); + // p.getServer().getPluginManager().callEvent(new AlivePlayerDeathEvent(ev)); // Plays sound. p.getGameManager().getDeathSound().broadcast(); @@ -710,14 +712,12 @@ public void onGameEnd(final UHGameEndsEvent ev) public void onPlayerResurrected(final PlayerResurrectedEvent ev) { // Spectator mode disabled - p.getSpectatorsManager().setSpectating(ev.getPlayer(), false); + // p.getSpectatorsManager().setSpectating(ev.getPlayer(), false); - // Death point removed on the dynmap - p.getDynmapIntegration().hideDeathLocation(ev.getPlayer()); + // TODO Death point removed on the dynmap + // p.getDynmapIntegration().hideDeathLocation(ev.getPlayer()); // All players are notified - /// Resurrection notification. {0} = raw resurrected player name. - p.getServer().broadcastMessage(I.t("{gold}{0} returned from the dead!", ev.getPlayer().getName())); // Updates the MOTD. p.getMOTDManager().updateMOTDDuringGame(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java index 13551cf..3da655d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java @@ -86,7 +86,7 @@ public void onPlayerLoseHealth(EntityDamageEvent ev) @EventHandler(priority = EventPriority.MONITOR) public void onPlayerDeath(AlivePlayerDeathEvent ev) { - onPlayerHealthChange(ev.getPlayer()); + // TODO onPlayerHealthChange(ev.getPlayer()); if (ev.getPlayerDeathEvent().getEntity().getKiller() != null) { @@ -99,7 +99,7 @@ public void onPlayerDeath(AlivePlayerDeathEvent ev) @EventHandler(priority = EventPriority.MONITOR) public void onPlayerResurrect(PlayerResurrectedEvent ev) { - onPlayerHealthChange(ev.getPlayer()); + // TODO onPlayerHealthChange(ev.getPlayer()); for (SidebarPlayerCache cache : UHCReloaded.get().getScoreboardManager().getAllSidebarPlayerCache().values()) { From 7af3ffd710bf09eff5e370e94b19ddbd9f9f3809 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 9 Dec 2018 14:50:11 +0100 Subject: [PATCH 12/91] Own team in sidebar --- .../modules/core/game/GameModule.java | 5 + .../modules/core/teams/Config.java | 42 +++++ .../modules/core/teams/TeamsModule.java | 110 +++++++++++- .../teams/sidebar/SidebarCacheListener.java} | 41 ++--- .../teams/sidebar}/SidebarPlayerCache.java | 80 ++++++--- .../UHCReloaded/scoreboard/GameSidebar.java | 169 +++++++++--------- .../scoreboard/ScoreboardManager.java | 4 +- 7 files changed, 315 insertions(+), 136 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{scoreboard/ScoreboardListener.java => modules/core/teams/sidebar/SidebarCacheListener.java} (73%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{scoreboard => modules/core/teams/sidebar}/SidebarPlayerCache.java (61%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 62eb184..b68cde8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -195,6 +195,11 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) } } + public boolean isTeamsGame() + { + return teamsGame; + } + public Set<UUID> getAlivePlayersUUIDs() { return Collections.unmodifiableSet(alivePlayers); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java index b60e091..c7d0530 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java @@ -32,9 +32,13 @@ package eu.carrade.amaury.UHCReloaded.modules.core.teams; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; import java.io.File; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + public class Config extends ConfigurationInstance { @@ -43,5 +47,43 @@ public Config(File file) super(file); } + public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); + + static public class SidebarSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + + public final TitleSection TITLE = section("title", TitleSection.class); + + static public class TitleSection extends ConfigurationSection + { + public final ConfigurationItem<String> COLOR = item("color", ""); + public final ConfigurationItem<Boolean> USE_TEAM_NAME = item("use-team-name", false); + } + + public final ContentSection CONTENT = section("content", ContentSection.class); + static public class ContentSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> DISPLAY_HEARTS = item("display-hearts", true); + public final ConfigurationItem<Boolean> COLOR_NAME = item("color-name", false); + public final ConfigurationItem<Boolean> STRIKE_DEAD_PLAYERS = item("strike-dead-players", false); + + public final LoginStateSection LOGIN_STATE = section("login-state", LoginStateSection.class); + + static public class LoginStateSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ITALIC = item("italic", true); + public final ConfigurationItem<String> SUFFIX = item("suffix", "➥"); + } + + public final DisplayMetPlayersOnlySection DISPLAY_MET_PLAYERS_ONLY = section("display-met-players-only", DisplayMetPlayersOnlySection.class); + + static public class DisplayMetPlayersOnlySection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); + public final ConfigurationItem<Double> DISPLAYED_WHEN_CLOSER_THAN = item("displayed-when-closer-than", 10d); + } + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index cb246c5..07570bf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -34,13 +34,25 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarCacheListener; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.commands.TeamsCommand; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; -import java.util.Collections; -import java.util.List; +import java.util.*; @ModuleInfo ( @@ -52,6 +64,14 @@ ) public class TeamsModule extends UHModule { + private final String HEART = "\u2764"; + private double TEAMMATES_DISTANCE_SQUARED; + + private GameModule game = null; + + private Map<UUID, SidebarPlayerCache> sidebarCache = new HashMap<>(); + + @Override protected void onEnable() { @@ -59,6 +79,15 @@ protected void onEnable() ZTeams.settings() .setScoreboard(UHCReloaded.get().getScoreboard()); + + TEAMMATES_DISTANCE_SQUARED = Math.pow(Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.DISPLAYED_WHEN_CLOSER_THAN.get(), 2d); + } + + @EventHandler + public void onGameStarting(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.STARTING) return; + ZLib.registerEvents(new SidebarCacheListener()); } @Override @@ -66,4 +95,81 @@ public List<Class<? extends Command>> getCommands() { return Collections.singletonList(TeamsCommand.class); } + + @Override + public void injectIntoSidebar(final Player player, final SidebarInjector injector) + { + if (game == null) game = UR.module(GameModule.class); + if (game == null) return; // Module not ready + + if (!game.isTeamsGame() || !Config.SIDEBAR.ENABLED.get() || game.getPhase().ordinal() < GamePhase.IN_GAME.ordinal()) + return; + + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + + if (team == null) return; + + + /* *** TEAM NAME *** */ + + injector.injectLines( + true, false, + (Config.SIDEBAR.TITLE.COLOR.get().isEmpty() ? team.getColorOrWhite().toChatColor() : Config.SIDEBAR.TITLE.COLOR.get()) + + (Config.SIDEBAR.TITLE.USE_TEAM_NAME.get() ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) + ); + + + /* *** TEAM PLAYERS: WHICH ONES *** */ + + final Set<OfflinePlayer> displayedPlayers = new TreeSet<>((player1, player2) -> { + if (player1.equals(player2)) return 0; + if (game.isAlive(player1) != game.isAlive(player2)) return game.isAlive(player1) ? -1 : 1; + return player1.getName().toLowerCase().compareTo(player2.getName().toLowerCase()); + }); + + final SidebarPlayerCache playerCache = getSidebarPlayerCache(player.getUniqueId()); + + if (Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.ENABLED.get()) + { + playerCache.updateTeammatesDisplayed(TEAMMATES_DISTANCE_SQUARED, player.getLocation(), team); + displayedPlayers.addAll(playerCache.getMetTeammates()); + } + + else displayedPlayers.addAll(team.getPlayers()); + + + /* *** TEAM PLAYERS: DISPLAY *** */ + + final List<String> playersSidebar = new ArrayList<>(); + + displayedPlayers.forEach(displayedPlayer -> { + final SidebarPlayerCache cache = getSidebarPlayerCache(displayedPlayer.getUniqueId()); + final boolean alive = game.isAlive(displayedPlayer); + + final String strike = Config.SIDEBAR.CONTENT.STRIKE_DEAD_PLAYERS.get() && !alive ? ChatColor.STRIKETHROUGH.toString() : ""; + final ChatColor aliveColor = alive ? ChatColor.WHITE : ChatColor.GRAY; + + final String heart = Config.SIDEBAR.CONTENT.DISPLAY_HEARTS.get() ? cache.getHealthColor() + strike + HEART + " " : ""; + final String name = (Config.SIDEBAR.CONTENT.COLOR_NAME.get() ? cache.getHealthColor() : aliveColor) + + strike + + (Config.SIDEBAR.CONTENT.LOGIN_STATE.ITALIC.get() && !cache.isOnline() ? ChatColor.ITALIC : "") + + cache.getPlayerName() + + (!cache.isOnline() ? ChatColor.RESET + "" + (Config.SIDEBAR.CONTENT.COLOR_NAME.get() ? cache.getHealthColor() : aliveColor) + " " + Config.SIDEBAR.CONTENT.LOGIN_STATE.SUFFIX.get() : ""); + + playersSidebar.add(heart + name); + }); + + injector.injectLines(false, true, playersSidebar); + } + + /** + * Returns the cached data about the given player. + * + * @param id The player's UUID. + * @return The cached data, created on the fly if needed. + */ + public SidebarPlayerCache getSidebarPlayerCache(UUID id) + { + return sidebarCache.computeIfAbsent(id, SidebarPlayerCache::new); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java similarity index 73% rename from src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java index 3da655d..d48fc59 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java @@ -29,11 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.scoreboard; +package eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -46,15 +48,21 @@ import org.bukkit.event.player.PlayerQuitEvent; -public class ScoreboardListener implements Listener +public class SidebarCacheListener implements Listener { + private final static GameModule game = UR.module(GameModule.class); + private final static TeamsModule teams = UR.module(TeamsModule.class); + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent ev) { - final SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(ev.getPlayer().getUniqueId()); + final SidebarPlayerCache cache = teams.getSidebarPlayerCache(ev.getPlayer().getUniqueId()); cache.updateName(ev.getPlayer().getName()); cache.updateOnlineStatus(true); + + // To be sure (and if the player was killed/resurrected while offline) + onPlayerHealthChange(ev.getPlayer()); } @EventHandler(priority = EventPriority.MONITOR) @@ -86,39 +94,28 @@ public void onPlayerLoseHealth(EntityDamageEvent ev) @EventHandler(priority = EventPriority.MONITOR) public void onPlayerDeath(AlivePlayerDeathEvent ev) { - // TODO onPlayerHealthChange(ev.getPlayer()); - - if (ev.getPlayerDeathEvent().getEntity().getKiller() != null) - { - UHCReloaded.get().getScoreboardManager() - .getSidebarPlayerCache(ev.getPlayerDeathEvent().getEntity().getKiller().getUniqueId()) - .getPlayersKilled().add(ev.getPlayer().getUniqueId()); - } + if (ev.getPlayer().isOnline()) + onPlayerHealthChange(ev.getPlayer().getPlayer()); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerResurrect(PlayerResurrectedEvent ev) { - // TODO onPlayerHealthChange(ev.getPlayer()); - - for (SidebarPlayerCache cache : UHCReloaded.get().getScoreboardManager().getAllSidebarPlayerCache().values()) - { - if (cache.getPlayersKilled().remove(ev.getPlayer().getUniqueId())) - break; - } + if (ev.getPlayer().isOnline()) + onPlayerHealthChange(ev.getPlayer().getPlayer()); } private void onPlayerQuit(Player player) { - UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()).updateOnlineStatus(false); + teams.getSidebarPlayerCache(player.getUniqueId()).updateOnlineStatus(false); } private void onPlayerHealthChange(final Player player) { // One tick later to use the updated health value. RunTask.nextTick(() -> { - final SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); - cache.updateHealth(UHCReloaded.get().getGameManager().isPlayerDead(player.getUniqueId()) ? 0d : player.getHealth()); + final SidebarPlayerCache cache = teams.getSidebarPlayerCache(player.getUniqueId()); + cache.updateHealth(game.isAlive(player.getUniqueId()) ? player.getHealth() : 0d); }); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java similarity index 61% rename from src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java index ea54e30..98c1d30 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java @@ -29,18 +29,25 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.scoreboard; +package eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.scoreboard.Sidebar; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; +import java.util.HashSet; +import java.util.Objects; import java.util.Set; import java.util.UUID; -import java.util.concurrent.CopyOnWriteArraySet; +import java.util.stream.Collectors; /** @@ -48,29 +55,29 @@ */ public class SidebarPlayerCache { - private UUID playerId; + private UUID playerID; private String playerName; private ChatColor healthColor = ChatColor.WHITE; private boolean isOnline; - private boolean isAlive; - private Set<UUID> playersKilled = new CopyOnWriteArraySet<>(); - private Set<UUID> teammatesDisplayed = new CopyOnWriteArraySet<>(); + private final Set<UUID> metTeammates = new HashSet<>(); - public SidebarPlayerCache(UUID id) + public SidebarPlayerCache(final UUID id) { - playerId = id; + playerID = id; - Player player = Sidebar.getPlayerAsync(id); + final OfflinePlayer player = Bukkit.getOfflinePlayer(id); if (player != null) { playerName = player.getName(); - isOnline = true; - updateHealth(player.getHealth()); + isOnline = player.isOnline(); + + if (isOnline) + updateHealth(player.getPlayer().getHealth()); } else { @@ -98,8 +105,6 @@ else if (health <= 16.1) healthColor = ChatColor.GREEN; else healthColor = ChatColor.DARK_GREEN; - - isAlive = (health > 0); } public void updateOnlineStatus(boolean isOnline) @@ -107,14 +112,9 @@ public void updateOnlineStatus(boolean isOnline) this.isOnline = isOnline; } - public void addKill(UUID id) - { - playersKilled.add(id); - } - - public UUID getPlayerId() + public UUID getPlayerID() { - return playerId; + return playerID; } public String getPlayerName() @@ -122,7 +122,7 @@ public String getPlayerName() if (playerName != null && !playerName.isEmpty()) return playerName; - OfflinePlayer player = OfflinePlayersLoader.getOfflinePlayer(playerId); + final OfflinePlayer player = OfflinePlayersLoader.getOfflinePlayer(playerID); if (player != null && player.getName() != null && !player.getName().isEmpty()) { playerName = player.getName(); @@ -143,18 +143,42 @@ public boolean isOnline() return isOnline; } - public boolean isAlive() + public Set<OfflinePlayer> getMetTeammates() { - return isAlive; + return metTeammates.stream() + .map(Bukkit::getOfflinePlayer) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); } - public Set<UUID> getTeammatesDisplayed() + public void updateTeammatesDisplayed(final double distanceThreshold) { - return teammatesDisplayed; + final Player player = Bukkit.getPlayer(playerID); + if (player != null) + { + updateTeammatesDisplayed( + distanceThreshold * distanceThreshold, + player.getLocation(), + ZTeams.get().getTeamForPlayer(playerID) + ); + } } - public Set<UUID> getPlayersKilled() + public void updateTeammatesDisplayed(final double distanceThresholdSquared, final Location reference, final ZTeam team) { - return playersKilled; + final GameModule game = UR.module(GameModule.class); + + // For each non-encountered online teammate, we check if they are close + team.getOnlinePlayers().stream() + .filter(p -> !metTeammates.contains(p.getUniqueId())) + .filter(game::isAlive) + .forEach(p -> { + if (p.getWorld() == null) return; + if (!p.getWorld().equals(reference.getWorld())) return; + if (p.getLocation().distanceSquared(reference) > distanceThresholdSquared) return; + + // Close enough + metTeammates.add(p.getUniqueId()); + }); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java index 00e8f92..1aadf35 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java @@ -36,12 +36,15 @@ import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.scoreboard.Sidebar; import fr.zcraft.zlib.components.scoreboard.SidebarMode; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -49,6 +52,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class GameSidebar extends Sidebar @@ -188,71 +192,70 @@ public void preRender() @Override public List<String> getContent(Player player) { + List<String> sidebar = new ArrayList<>(sidebarTop); + sidebar.add(""); -// List<String> sidebar = new ArrayList<>(sidebarTop); -// sidebar.add(""); -// -// if (OWN_TEAM_IN_SIDEBAR && gameManager.isGameStarted() && gameManager.isGameWithTeams()) -// { -// UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); -// -// if (team != null) -// { -// sidebar.add( -// (OWN_TEAM_TITLE_COLOR.isEmpty() ? team.getColorOrWhite().toChatColor() : OWN_TEAM_TITLE_COLOR) -// /// Title of the team section in the sidebar -// + (OWN_TEAM_TITLE_IS_NAME ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) -// ); -// -// Location playerLocation = player.getLocation(); -// -// for (UUID teamMember : team.getPlayersUUID()) -// { -// SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(teamMember); -// -// // If enabled, we check if the player was already met or is close to this player. -// // Only if the damages are on (= 30 seconds after the game start) to avoid false close while -// // teleporting. -// if(OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY) -// { -// if(!(teamMember.equals(player.getUniqueId()) || cache.getTeammatesDisplayed().contains(teamMember))) -// { -// if (gameManager.isGameStarted() && gameManager.isTakingDamage()) -// { -// if (gameManager.isPlayerDead(teamMember)) -// continue; // dead (spectators don't have to be displayed in the sidebar). -// -// Player teammate = Sidebar.getPlayerAsync(teamMember); -// if (teammate == null) -// continue; // offline -// -// -// Location teammateLocation = teammate.getLocation(); -// -// // Check if the players are close -// if (teammateLocation.getWorld().equals(playerLocation.getWorld())) -// { + if (OWN_TEAM_IN_SIDEBAR && gameManager.isGameStarted() && gameManager.isGameWithTeams()) + { + ZTeam team = ZTeams.get().getTeamForPlayer(player); + + if (team != null) + { + sidebar.add( + (OWN_TEAM_TITLE_COLOR.isEmpty() ? team.getColorOrWhite().toChatColor() : OWN_TEAM_TITLE_COLOR) + /// Title of the team section in the sidebar + + (OWN_TEAM_TITLE_IS_NAME ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) + ); + + Location playerLocation = player.getLocation(); + + for (UUID teamMember : team.getPlayersUUID()) + { + SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(teamMember); + + // If enabled, we check if the player was already met or is close to this player. + // Only if the damages are on (= 30 seconds after the game start) to avoid false close while + // teleporting. + if(OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY) + { + if(!(teamMember.equals(player.getUniqueId()) || cache.getMetTeammates().contains(teamMember))) + { + if (gameManager.isGameStarted() && gameManager.isTakingDamage()) + { + if (gameManager.isPlayerDead(teamMember)) + continue; // dead (spectators don't have to be displayed in the sidebar). + + Player teammate = Sidebar.getPlayerAsync(teamMember); + if (teammate == null) + continue; // offline + + + Location teammateLocation = teammate.getLocation(); + + // Check if the players are close + if (teammateLocation.getWorld().equals(playerLocation.getWorld())) + { // final double distanceSquared = teammateLocation.distanceSquared(playerLocation); // if (distanceSquared <= OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED) -// cache.getTeammatesDisplayed().add(teamMember); +// cache.getMetTeammates().add(teamMember); // else // continue; // Too far, skipped -// } -// else -// { -// continue; // Too far, skipped -// } -// } -// else -// { -// continue; -// } -// } -// } -// + } + else + { + continue; // Too far, skipped + } + } + else + { + continue; + } + } + } + // final String strike = OWN_TEAM_STRIKE_DEAD_PLAYERS && !cache.isAlive() ? ChatColor.STRIKETHROUGH.toString() : ""; // final ChatColor aliveColor = cache.isAlive() ? ChatColor.WHITE : ChatColor.GRAY; -// + // final String heart = OWN_TEAM_DISPLAY_HEARTS ? cache.getHealthColor() + strike + HEART + " " : ""; // final String name = (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) // + strike @@ -261,32 +264,32 @@ public List<String> getContent(Player player) // + (!cache.isOnline() ? ChatColor.RESET + "" + (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) + " " + OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX : ""); // // sidebar.add(heart + name); -// } -// -// sidebar.add(""); -// } -// } -// -// sidebar.addAll(sidebarBorder); -// -// if (KILLS_IN_SIDEBAR && gameManager.isGameStarted()) -// { -// SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); -// -// /// Kills count in the sidebar + } + + sidebar.add(""); + } + } + + sidebar.addAll(sidebarBorder); + + if (KILLS_IN_SIDEBAR && gameManager.isGameStarted()) + { + SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); + + /// Kills count in the sidebar // sidebar.add(I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", cache.getPlayersKilled().size(), cache.getPlayersKilled().size())); -// sidebar.add(""); -// } -// -// sidebar.addAll(sidebarTimers); -// -// if (FREEZE_STATUS_IN_SIDEBAR) -// { -// insertFreezeStatus(sidebar, player); -// } -// -// return sidebar; - return null; + sidebar.add(""); + } + + sidebar.addAll(sidebarTimers); + + if (FREEZE_STATUS_IN_SIDEBAR) + { + insertFreezeStatus(sidebar, player); + } + + return sidebar; +// return null; } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java index 03d80f0..37859e2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java @@ -33,6 +33,8 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarCacheListener; +import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; import fr.zcraft.zlib.components.scoreboard.Sidebar; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; @@ -64,7 +66,7 @@ public ScoreboardManager(UHCReloaded p) this.p = p; this.sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); - UHCReloaded.get().getServer().getPluginManager().registerEvents(new ScoreboardListener(), UHCReloaded.get()); + UHCReloaded.get().getServer().getPluginManager().registerEvents(new SidebarCacheListener(), UHCReloaded.get()); // Initialization of the scoreboard (match info in the sidebar) From 61e69b93db3dbb3a4924ba407b316675d33c562f Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 9 Dec 2018 16:10:17 +0100 Subject: [PATCH 13/91] Border in the sidebar + auto shrink + teams config + shields * NEW: added border in the sidebar. * BUG: fixed border shrinking duration not respected (multiplied by 20). * NEW: auto-shrink from config re-implemented (+ warnings 1 hour, 30 minutes & 10 minutes before). * NEW: teams configs re-implemented * NEW: banner on spawn re-implemented * NEW: banner on shield re-implemented --- .../modules/core/border/BorderModule.java | 148 ++++++++++++++---- .../modules/core/border/Config.java | 20 ++- .../core/border/commands/BorderCommand.java | 2 +- .../worldborders/BrettflanWorldBorder.java | 20 +-- .../border/worldborders/FakeWorldBorder.java | 22 ++- .../worldborders/VanillaWorldBorder.java | 31 ++-- .../core/border/worldborders/WorldBorder.java | 32 ++-- .../modules/core/game/GameModule.java | 22 +++ .../modules/core/teams/Config.java | 62 +++++++- .../modules/core/teams/TeamsModule.java | 132 +++++++++++++++- .../modules/core/timers/TimeDelta.java | 70 ++++++++- 11 files changed, 471 insertions(+), 90 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 2058df9..0fb742c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -32,25 +32,34 @@ package eu.carrade.amaury.UHCReloaded.modules.core.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.commands.BorderCommand; import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; @ModuleInfo ( @@ -65,6 +74,11 @@ public class BorderModule extends UHModule private MapShape mapShape = null; private WorldBorder border = null; + /** + * The lines in the sidebar, calculated once for every player. Caching purposes. + */ + private final List<String> sidebar = new ArrayList<>(); + @Override public void onEnable() { @@ -76,7 +90,7 @@ public void onEnable() border.setShape(mapShape); border.setCenter(world.getSpawnLocation()); - border.setDiameter(UHConfig.MAP.SIZE.get()); + border.setDiameter(Config.SIZE.get()); border.init(); @@ -89,6 +103,63 @@ public List<Class<? extends Command>> getCommands() return Collections.singletonList(BorderCommand.class); } + @Override + public void prepareInjectionIntoSidebar() + { + if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) return; + + sidebar.clear(); + + if (Config.SIDEBAR.DISPLAYED.get()) + { + /// Title of the border section in the sidebar + sidebar.add(I.t("{blue}{bold}Border")); + + int diameter = (int) Math.ceil(border.getDiameter()); + + if (Config.SIDEBAR.DISPLAY_DIAMETER.get() || border.getShape() == MapShape.CIRCULAR) + { + if (border.getShape() == MapShape.SQUARED) + /// Border diameter for a squared map in the sidebar + sidebar.add(I.tn("{white}{0} block wide", "{white}{0} blocks wide", diameter, diameter)); + else + /// Border diameter for a circular map in the sidebar + sidebar.add(I.tn("{gray}Diameter: {white}{0} block", "{gray}Diameter: {white}{0} blocks", diameter, diameter)); + } + else + { + Location center = border.getCenter(); + int radius = (int) Math.ceil(diameter / 2d); + + int minX = center.getBlockX() - radius; + int maxX = center.getBlockX() + radius; + int minZ = center.getBlockZ() - radius; + int maxZ = center.getBlockZ() + radius; + + // Same min & max, we can display both at once + if (minX == minZ && maxX == maxZ) + { + /// Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. + sidebar.add(I.t("{white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxZ))); + } + else + { + /// Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. + sidebar.add(I.t("{gray}X: {white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxX))); + /// Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. + sidebar.add(I.t("{gray}Z: {white}{0} {1}", UHUtils.integerToStringWithSign(minZ), UHUtils.integerToStringWithSign(maxZ))); + } + } + } + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; + injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, sidebar); + } + /** * Sets the shape of the map. Updates the WorldBorder too. * @@ -169,18 +240,10 @@ public double getDistanceToBorder(Location location, double diameter) */ public Set<Player> getPlayersOutside(int diameter) { - final Set<Player> playersOutside = new HashSet<>(); - - // TODO -// for (final Player player : UR.module(GameModule.class).getOnlineAlivePlayers()) -// { -// if (!isInsideBorder(player.getLocation(), diameter)) -// { -// playersOutside.add(player); -// } -// } - - return playersOutside; + return UR.module(GameModule.class) + .getAliveConnectedPlayers().stream() + .filter(player -> !isInsideBorder(player.getLocation(), diameter)) + .collect(Collectors.toSet()); } /** @@ -246,20 +309,47 @@ else if (distance > 25) /** * Schedules the automatic border reduction, if enabled in the configuration. */ - public void scheduleBorderReduction() + private void scheduleBorderReduction() + { + if (Config.SHRINKING.ENABLED.get()) + { + RunTask.later(() -> { + if (UR.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + + final int secondsPerBlock = (int) Math.rint(Config.SHRINKING.SHRINKS_DURING.get().getSeconds() / (border.getDiameter() - Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())) * 2; + + border.setDiameter(Config.SHRINKING.DIAMETER_AFTER_SHRINK.get(), Config.SHRINKING.SHRINKS_DURING.get()); + + Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); + + Bukkit.broadcastMessage(I.t("{red}{bold}The border begins to shrink...")); + Bukkit.broadcastMessage(I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())); + }, Config.SHRINKING.STARTS_AFTER.get().getSeconds() * 20L); + + scheduleBorderReductionWarning(new TimeDelta(1, 0, 0)); + scheduleBorderReductionWarning(new TimeDelta(0, 30, 0)); + scheduleBorderReductionWarning(new TimeDelta(0, 10, 0)); + } + } + + private void scheduleBorderReductionWarning(final TimeDelta warnBefore) + { + if (Config.SHRINKING.STARTS_AFTER.get().greaterThan(warnBefore.add(new TimeDelta(0, 5, 0)))) + { + RunTask.later(() -> { + if (UR.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + + Bukkit.broadcastMessage(""); + Bukkit.broadcastMessage(I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60))); + Bukkit.broadcastMessage(""); + }, Config.SHRINKING.STARTS_AFTER.get().subtract(warnBefore).getSeconds() * 20L); + } + } + + @EventHandler + public void onGameStarts(final GamePhaseChangedEvent ev) { -// if (BORDER_SHRINKING) -// { -// RunTask.later(() -> { -// Integer secondsPerBlock = (int) Math.rint(BORDER_SHRINKING_DURATION / (border.getDiameter() - BORDER_SHRINKING_FINAL_SIZE)) * 2; -// -// border.setDiameter(BORDER_SHRINKING_FINAL_SIZE, BORDER_SHRINKING_DURATION); -// -// Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); -// -// Bukkit.broadcastMessage(I.t("{red}{bold}The border begins to shrink...")); -// Bukkit.broadcastMessage(I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, BORDER_SHRINKING_FINAL_SIZE)); -// }, BORDER_SHRINKING_STARTS_AFTER * 20l); -// } + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + scheduleBorderReduction(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java index c15d00f..8f50934 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java @@ -54,17 +54,25 @@ public Config(File file) public static final ConfigurationItem<MapShape> SHAPE = item("shape", MapShape.SQUARED); public static final ConfigurationItem<WorldBorder.WorldBorderMotor> MOTOR = item("motor", WorldBorder.WorldBorderMotor.VANILLA); - public static final ConfigurationItem<Double> DAMAGES_BUFFER = item("damagesBuffer", 5d); - public static final ConfigurationItem<Double> DAMAGES_AMOUNT = item("damagesAmount", 0.2); - public static final ConfigurationItem<Integer> WARNING_DISTANCE = item("warningDistance", 5); + public static final ConfigurationItem<Double> DAMAGES_BUFFER = item("damages-buffer", 5d); + public static final ConfigurationItem<Double> DAMAGES_AMOUNT = item("damages-amount", 0.2); + public static final ConfigurationItem<Integer> WARNING_DISTANCE = item("warning-distance", 5); public static final ShrinkingSection SHRINKING = section("shrinking", ShrinkingSection.class); static public class ShrinkingSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<TimeDelta> STARTS_AFTER = item("startsAfter", new TimeDelta(0, 30, 0)); - public final ConfigurationItem<TimeDelta> SHRINKS_DURING = item("shrinksDuring", new TimeDelta(2, 0, 0)); - public final ConfigurationItem<Integer> DIAMETER_AFTER_SHRINK = item("diameterAfterShrink", 200); + public final ConfigurationItem<TimeDelta> STARTS_AFTER = item("starts-after", new TimeDelta(1, 30, 0)); + public final ConfigurationItem<TimeDelta> SHRINKS_DURING = item("shrinks-during", new TimeDelta(2, 0, 0)); + public final ConfigurationItem<Integer> DIAMETER_AFTER_SHRINK = item("diameter-after-shrink", 200); + } + + static public final BorderSection SIDEBAR = section("sidebar", BorderSection.class); + + static public class BorderSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> DISPLAYED = item("displayed", true); + public final ConfigurationItem<Boolean> DISPLAY_DIAMETER = item("display-diameter", false); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java index 27d50d2..543cbc4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java @@ -163,7 +163,7 @@ else if (args.length == 2) return; } - border.getBorderProxy().setDiameter(newDiameter, delta.getSeconds() * 20L); + border.getBorderProxy().setDiameter(newDiameter, delta); if (border.getMapShape() == MapShape.CIRCULAR) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java index e5e3a0c..f48b33a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -63,7 +63,7 @@ public class BrettflanWorldBorder extends WorldBorder private BukkitTask slowReductionTask = null; - public BrettflanWorldBorder(World world) + public BrettflanWorldBorder(final World world) { this.world = world; @@ -112,7 +112,7 @@ public double getDiameter() } @Override - public void setDiameter(double diameter) + public void setDiameter(final double diameter) { setDiameterInternal(diameter); @@ -154,7 +154,7 @@ public void setDiameter(final double diameter, final long time) }, ticksPerBlockRemoved, ticksPerBlockRemoved); } - private void setDiameterInternal(double diameter) + private void setDiameterInternal(final double diameter) { this.diameter = diameter; @@ -175,14 +175,14 @@ public Location getCenter() } @Override - public void setCenter(double x, double z) + public void setCenter(final double x, final double z) { border.setX(x); border.setZ(z); } @Override - public void setCenter(Location center) + public void setCenter(final Location center) { setCenter(center.getX(), center.getZ()); } @@ -191,25 +191,25 @@ public void setCenter(Location center) public double getDamageBuffer() { return 0; } @Override - public void setDamageBuffer(double distance) {} + public void setDamageBuffer(final double distance) {} @Override public double getDamageAmount() { return 0; } @Override - public void setDamageAmount(double damageAmount) {} + public void setDamageAmount(final double damageAmount) {} @Override public int getWarningTime() { return 0; } @Override - public void setWarningTime(int seconds) {} + public void setWarningTime(final int seconds) {} @Override public int getWarningDistance() { return 0; } @Override - public void setWarningDistance(int blocks) {} + public void setWarningDistance(final int blocks) {} @Override public MapShape getShape() @@ -218,7 +218,7 @@ public MapShape getShape() } @Override - public void setShape(MapShape shape) + public void setShape(final MapShape shape) { border.setShape(shape == MapShape.CIRCULAR); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java index e90fcdf..c513ed7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java @@ -49,11 +49,9 @@ public class FakeWorldBorder extends WorldBorder private Double diameter; private MapShape shape; - public FakeWorldBorder(World world) + public FakeWorldBorder(final World world) { this.world = world; - - init(); } @Override @@ -69,13 +67,13 @@ public double getDiameter() } @Override - public void setDiameter(double diameter) + public void setDiameter(final double diameter) { this.diameter = diameter; } @Override - public void setDiameter(double diameter, long time) + public void setDiameter(final double diameter, final long time) { this.diameter = diameter; } @@ -87,13 +85,13 @@ public Location getCenter() } @Override - public void setCenter(double x, double z) + public void setCenter(final double x, final double z) { this.center = new Location(world, x, 0, z); } @Override - public void setCenter(Location center) + public void setCenter(final Location center) { setCenter(center.getX(), center.getZ()); } @@ -102,25 +100,25 @@ public void setCenter(Location center) public double getDamageBuffer() { return 0; } @Override - public void setDamageBuffer(double distance) {} + public void setDamageBuffer(final double distance) {} @Override public double getDamageAmount() { return 0; } @Override - public void setDamageAmount(double damageAmount) {} + public void setDamageAmount(final double damageAmount) {} @Override public int getWarningTime() { return 0; } @Override - public void setWarningTime(int seconds) {} + public void setWarningTime(final int seconds) {} @Override public int getWarningDistance() { return 0; } @Override - public void setWarningDistance(int blocks) {} + public void setWarningDistance(final int blocks) {} @Override public MapShape getShape() @@ -129,7 +127,7 @@ public MapShape getShape() } @Override - public void setShape(MapShape shape) + public void setShape(final MapShape shape) { this.shape = shape; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java index d084305..7568cfe 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java @@ -31,7 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.modules.core.border.Config; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; @@ -48,7 +48,7 @@ public class VanillaWorldBorder extends WorldBorder private final World world; private final org.bukkit.WorldBorder border; - public VanillaWorldBorder(World world) + public VanillaWorldBorder(final World world) { this.world = world; this.border = world.getWorldBorder(); @@ -57,12 +57,9 @@ public VanillaWorldBorder(World world) @Override public void init() { - if (UHConfig.MAP.BORDER.isDefined()) - { - setDamageBuffer(UHConfig.MAP.BORDER.DAMAGES_BUFFER.get()); - setDamageAmount(UHConfig.MAP.BORDER.DAMAGES_AMOUNT.get()); - setWarningDistance(UHConfig.MAP.BORDER.WARNING_DISTANCE.get()); - } + setDamageBuffer(Config.DAMAGES_BUFFER.get()); + setDamageAmount(Config.DAMAGES_AMOUNT.get()); + setWarningDistance(Config.WARNING_DISTANCE.get()); } @Override @@ -78,13 +75,13 @@ public double getDiameter() } @Override - public void setDiameter(double diameter) + public void setDiameter(final double diameter) { border.setSize(diameter); } @Override - public void setDiameter(double diameter, long time) + public void setDiameter(final double diameter, final long time) { border.setSize(diameter, time); } @@ -96,13 +93,13 @@ public Location getCenter() } @Override - public void setCenter(double x, double z) + public void setCenter(final double x, final double z) { border.setCenter(x, z); } @Override - public void setCenter(Location center) + public void setCenter(final Location center) { border.setCenter(center); } @@ -114,7 +111,7 @@ public double getDamageBuffer() } @Override - public void setDamageBuffer(double distance) + public void setDamageBuffer(final double distance) { border.setDamageBuffer(distance); } @@ -126,7 +123,7 @@ public double getDamageAmount() } @Override - public void setDamageAmount(double damageAmount) + public void setDamageAmount(final double damageAmount) { border.setDamageAmount(damageAmount); } @@ -138,7 +135,7 @@ public int getWarningTime() } @Override - public void setWarningTime(int seconds) + public void setWarningTime(final int seconds) { border.setWarningTime(seconds); } @@ -150,7 +147,7 @@ public int getWarningDistance() } @Override - public void setWarningDistance(int blocks) + public void setWarningDistance(final int blocks) { border.setWarningDistance(blocks); } @@ -162,7 +159,7 @@ public MapShape getShape() } @Override - public void setShape(MapShape shape) {} + public void setShape(final MapShape shape) {} @Override public boolean supportsProgressiveResize() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java index 787ad81..ed6887c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java @@ -33,6 +33,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import org.bukkit.Location; import org.bukkit.World; @@ -63,13 +64,22 @@ public void init() {} /** * @param diameter The new diameter of the border. */ - public abstract void setDiameter(double diameter); + public abstract void setDiameter(final double diameter); /** * @param diameter The new diameter of the border. - * @param time The ticks used to change the size from the old size to the new one. + * @param time The seconds used to change the size from the old size to the new one. */ - public abstract void setDiameter(double diameter, long time); + public abstract void setDiameter(final double diameter, final long time); + + /** + * @param diameter The new diameter of the border. + * @param time The seconds used to change the size from the old size to the new one. + */ + public void setDiameter(final double diameter, final TimeDelta time) + { + setDiameter(diameter, time.getSeconds()); + } /** * @return The center of the border. @@ -82,12 +92,12 @@ public void init() {} * @param x The x coordinate of the new center. * @param z The z coordinate of the new center. */ - public abstract void setCenter(double x, double z); + public abstract void setCenter(final double x, final double z); /** * @param center The new center of the border. */ - public abstract void setCenter(Location center); + public abstract void setCenter(final Location center); /** * @return the amount of blocks a player may safely be outside the border before taking damage. @@ -98,7 +108,7 @@ public void init() {} * @param distance the amount of blocks a player may safely be outside the border before taking * damage. */ - public abstract void setDamageBuffer(double distance); + public abstract void setDamageBuffer(final double distance); /** * @return the amount of damage a player takes when outside the border plus the border buffer. @@ -109,7 +119,7 @@ public void init() {} * @param damageAmount the amount of damage a player takes when outside the border plus the * border buffer. */ - public abstract void setDamageAmount(double damageAmount); + public abstract void setDamageAmount(final double damageAmount); /** * @return the warning time that causes the screen to be tinted red when a contracting border @@ -121,7 +131,7 @@ public void init() {} * @param seconds the warning time that causes the screen to be tinted red when a contracting * border will reach the player within the specified time. */ - public abstract void setWarningTime(int seconds); + public abstract void setWarningTime(final int seconds); /** * @return the warning distance that causes the screen to be tinted red when the player is @@ -133,7 +143,7 @@ public void init() {} * @param blocks the warning distance that causes the screen to be tinted red when the player is * within the specified number of blocks from the border. */ - public abstract void setWarningDistance(int blocks); + public abstract void setWarningDistance(final int blocks); /** * @return The current border shape. @@ -143,7 +153,7 @@ public void init() {} /** * @param shape the new border shape. */ - public abstract void setShape(MapShape shape); + public abstract void setShape(final MapShape shape); /** * @return {@code true} if this border supports progressive resizes using {@link #setDiameter(double, long)}. @@ -159,7 +169,7 @@ public void init() {} * * @return An instance of a WorldBorder proxy. */ - public static WorldBorder getInstance(World world, WorldBorderMotor motor, MapShape shape) + public static WorldBorder getInstance(final World world, final WorldBorderMotor motor, final MapShape shape) { // For circular shapes, the vanilla motor cannot be used. // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index b68cde8..2b92265 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -324,6 +324,28 @@ public GamePhase getPhase() return phase; } + /** + * Compares the current phase with the given one. + * + * @param phase The compared phase. + * @return {@code true} if the current phase is strictly before this one. + */ + public boolean currentPhaseBefore(final GamePhase phase) + { + return this.phase.ordinal() < phase.ordinal(); + } + + /** + * Compares the current phase with the given one. + * + * @param phase The compared phase. + * @return {@code true} if the current phase is strictly after this one. + */ + public boolean currentPhaseAfter(final GamePhase phase) + { + return this.phase.ordinal() > phase.ordinal(); + } + /** * Changes the phase of the game. * diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java index c7d0530..bdc6760 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java @@ -31,12 +31,15 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.teams; +import eu.carrade.amaury.UHCReloaded.UHConfig; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.zteams.guis.TeamsGUIItemType; import java.io.File; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; @@ -47,7 +50,64 @@ public Config(File file) super(file); } - public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); + static public final ConfigurationItem<Boolean> CAN_SEE_FRIENDLY_INVISIBLES = item("can-see-friendly-invisibles", true); + static public final ConfigurationItem<Boolean> ALLOW_FRIENDLY_FIRE = item("allow-friendly-fire", true); + static public final ConfigurationItem<Integer> MAX_PLAYERS_PER_TEAM = item("max-players-per-team", 0); + static public final ConfigurationItem<Boolean> RANDOM_COLORS = item("random-colors", true); + + static public final ConfigurationItem<Boolean> COLORIZE_CHAT = item("colorize-chat", true); + + static public final BannerSection BANNER = section("banner", BannerSection.class); + + static public class BannerSection extends ConfigurationSection + { + public final ShapeSection SHAPE = section("shape", ShapeSection.class); + + static public class ShapeSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> WRITE_LETTER = item("write-letter", true); + public final ConfigurationItem<Boolean> ADD_BORDER = item("add-border", true); + } + + public final GiveSection GIVE = section("give", GiveSection.class); + + static public class GiveSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> PLACE_ON_SPAWN = item("place-on-spawn", true); + public final ConfigurationItem<Boolean> GIVE_IN_HOTBAR = item("give-in-hotbar", false); + public final ConfigurationItem<Boolean> GIVE_ON_HEAD = item("give-on-head", false); + } + + public final UHConfig.TeamsOptionsSection.BannerSection.ShieldSection SHIELDS = section("shields", UHConfig.TeamsOptionsSection.BannerSection.ShieldSection.class); + + static public class ShieldSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ADD_ON_SHIELDS = item("add-on-shields", true); + } + } + + static public final ChestGuiSection GUI = section("gui", ChestGuiSection.class); + + static public class ChestGuiSection extends ConfigurationSection + { + public final DisplaySection DISPLAY = section("display", DisplaySection.class); + + static public class DisplaySection extends ConfigurationSection + { + public final ConfigurationItem<TeamsGUIItemType> TEAM_ITEM = item("team-item", TeamsGUIItemType.BANNER); + public final ConfigurationItem<Boolean> GLOW_ON_SELECTED_TEAM = item("glow-on-selected-team", true); + } + } + + static public final TeamChatSection TEAM_CHAT = section("team-chat", TeamChatSection.class); + + static public class TeamChatSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> DISABLE_LOCK_ON_DEATH = item("disable-lock-on-death", true); + public final ConfigurationItem<Boolean> LOG = item("log", false); + } + + static public final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); static public class SidebarSection extends ConfigurationSection { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index 07570bf..b6e494d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -44,13 +44,23 @@ import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.commands.TeamsCommand; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.BlockStateMeta; import java.util.*; @@ -78,7 +88,22 @@ protected void onEnable() ZLib.loadComponent(ZTeams.class); ZTeams.settings() - .setScoreboard(UHCReloaded.get().getScoreboard()); + .setScoreboard(UHCReloaded.get().getScoreboard()) + .setTeamsOptions( + Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), + Config.ALLOW_FRIENDLY_FIRE.get(), + Config.COLORIZE_CHAT.get(), + false + ) + .setBannerOptions( + Config.BANNER.SHAPE.WRITE_LETTER.get(), + Config.BANNER.SHAPE.ADD_BORDER.get() + ) + .setGUIOptions( + Config.GUI.DISPLAY.TEAM_ITEM.get(), + Config.GUI.DISPLAY.GLOW_ON_SELECTED_TEAM.get() + ) + .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_TEAM.get()); TEAMMATES_DISTANCE_SQUARED = Math.pow(Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.DISPLAYED_WHEN_CLOSER_THAN.get(), 2d); } @@ -168,8 +193,111 @@ public void injectIntoSidebar(final Player player, final SidebarInjector injecto * @param id The player's UUID. * @return The cached data, created on the fly if needed. */ - public SidebarPlayerCache getSidebarPlayerCache(UUID id) + public SidebarPlayerCache getSidebarPlayerCache(final UUID id) { return sidebarCache.computeIfAbsent(id, SidebarPlayerCache::new); } + + @EventHandler + public void onGameStart(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME) return; + + // Banners + if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) + { + RunTask.later(() -> + ZTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> + { + final ItemStack banner = team.getBanner(); + + team.getOnlinePlayers().forEach(player -> + { + if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get()) + { + player.getInventory().setItem(8, banner.clone()); + } + + if (Config.BANNER.GIVE.GIVE_ON_HEAD.get()) + { + player.getInventory().setHelmet(banner.clone()); + } + + if (Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) + { + final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); + final Block under = place.getRelative(BlockFace.DOWN); + + // We don't want a stack of banners + if (under.getType() != Material.STANDING_BANNER) + { + if (!under.getType().isSolid()) + under.setType(Material.WOOD); + + place.setType(Material.STANDING_BANNER); + + Banner bannerBlock = (Banner) place.getState(); + BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); + + bannerBlock.setBaseColor(bannerMeta.getBaseColor()); + bannerBlock.setPatterns(bannerMeta.getPatterns()); + + bannerBlock.update(); + } + } + }); + }), 5L); + } + } + + /** + * Adds the team banner on crafted shields. + * + * Done indirectly because the plugin must be able to run + * on Minecraft 1.8. + */ + @EventHandler (ignoreCancelled = true) + public void onShieldPreCraft(final PrepareItemCraftEvent ev) + { + if (!Config.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; + + final Player player = (Player) ev.getViewers().get(0); + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + + if (team == null || team.getBanner() == null) return; + + final Recipe recipe = ev.getRecipe(); + if (recipe == null) return; + + final ItemStack result = recipe.getResult(); + if (result == null) return; + + final Material MATERIAL_SHIELD = Material.getMaterial("SHIELD"); + if (MATERIAL_SHIELD == null) return; // MC 1.8 + + if (result.getType() == MATERIAL_SHIELD) + { + try + { + final BannerMeta banner = (BannerMeta) team.getBanner().getItemMeta(); + + final BlockStateMeta bsMeta = (BlockStateMeta) result.getItemMeta(); + final Banner shieldBanner = (Banner) bsMeta.getBlockState(); + + shieldBanner.setBaseColor(banner.getBaseColor()); + shieldBanner.setPatterns(banner.getPatterns()); + + shieldBanner.update(); + + bsMeta.setBlockState(shieldBanner); + result.setItemMeta(bsMeta); + + ev.getInventory().setResult(result); + } + catch (ClassCastException | NullPointerException ignored) + { + // Bad Minecraft version (1.8) + } + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java index 06beaa2..942b927 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java @@ -87,7 +87,8 @@ public TimeDelta(long hours, long minutes, long seconds) * @param rawTime The raw time text. * * @throws IllegalArgumentException if the text is not formatted as above. - * @throws NumberFormatException if the text between the colons cannot be converted in integers. + * @throws NumberFormatException if the text between the colons cannot be + * converted in integers. */ public TimeDelta(final String rawTime) throws IllegalArgumentException, NumberFormatException { @@ -112,11 +113,78 @@ else if (split.length == 2) // "mm:ss" } } + /** + * @return The total number of seconds in this time delta. + */ public long getSeconds() { return seconds; } + /** + * @param other Another {@link TimeDelta}. + * @return {@code true} if the duration in this {@link TimeDelta} is less than + * (or equal to) the duration in the other one. + */ + public boolean lessThan(final TimeDelta other) + { + return this.getSeconds() <= other.getSeconds(); + } + + /** + * @param other Another {@link TimeDelta}. + * @return {@code true} if the duration in this {@link TimeDelta} is greater + * than (or equal to) the duration in the other one. + */ + public boolean greaterThan(final TimeDelta other) + { + return this.getSeconds() >= other.getSeconds(); + } + + /** + * @param other Another {@link TimeDelta} + * @return A new {@link TimeDelta} instance representing the sum of the two + * {@link TimeDelta deltas}. + */ + public TimeDelta add(final TimeDelta other) + { + return new TimeDelta(this.getSeconds() + other.getSeconds()); + } + + /** + * @param other Another {@link TimeDelta} + * @return A new {@link TimeDelta} instance representing the subtraction of + * the two {@link TimeDelta deltas}. + */ + public TimeDelta subtract(final TimeDelta other) + { + return new TimeDelta(this.getSeconds() - other.getSeconds()); + } + + /** + * @param factor A factor. + * @return A new {@link TimeDelta} instance representing the duration of this + * {@link TimeDelta delta} multiplied by the given factor. + */ + public TimeDelta multiply(final long factor) + { + return new TimeDelta(this.getSeconds() * factor); + } + + /** + * @param factor A factor. + * @return A new {@link TimeDelta} instance representing the duration of this + * {@link TimeDelta delta} divided by the given factor. + */ + public TimeDelta divide(final long factor) + { + return new TimeDelta(this.getSeconds() / factor); + } + + /** + * @return A string representation using the format “mm:ss” or “hh:mm:ss” if + * longer than one hour. + */ @Override public String toString() { From f4f994f8462719b711e33049f6b18580becce79d Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 10 Dec 2018 00:46:35 +0100 Subject: [PATCH 14/91] Health in players list --- .../amaury/UHCReloaded/core/ModuleInfo.java | 3 +- .../modules/core/game/GamePhase.java | 2 +- .../listHealth/ListHealthModule.java | 100 ++++++++++++++++++ src/main/resources/config.yml | 1 + 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index 35fd78c..82be2ca 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -113,7 +113,8 @@ enum ModuleLoadTime ON_GAME_STARTING, /** - * Loads the module when the game starts. + * Loads the module when the game starts, i.e. when all players falls from their spawn into + * the world. */ ON_GAME_START, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java index 1359a45..fdcb545 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java @@ -43,7 +43,7 @@ public enum GamePhase WAIT, /** - * While the game is starting (can last a tick, or a long time with slow start). + * While the game is starting (can last the time of the start countdown, or longer with the slow start). */ STARTING, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java new file mode 100644 index 0000000..f346641 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java @@ -0,0 +1,100 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.informations.listHealth; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Criterias; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; + + +@ModuleInfo ( + name = "Health in players list", + description = "Displays the health of players in the overlay list displayed with <TAB>", + when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING +) +public class ListHealthModule extends UHModule +{ + @Override + protected void onEnable() + { + // Initialization of the scoreboard (health in players' list) + final Objective healthObjective = UR.get().getScoreboard().registerNewObjective("Health", Criterias.HEALTH); + healthObjective.setDisplayName("Health"); + healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); + + // Sometimes, the health is initialized to 0. This is used to fix this. + updateHealthScore(); + } + + @Override + protected void onDisable() + { + UR.get().getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST); + } + + /** + * Updates the health score for all players. + */ + public void updateHealthScore() + { + Bukkit.getOnlinePlayers().forEach(this::updateHealthScore); + } + + /** + * Updates the health score for the given player. + * + * @param player The player to update. + */ + public void updateHealthScore(final Player player) + { + if (player.getHealth() != 1d) // Prevents killing the player + { + player.setHealth(player.getHealth() - 1d); + + RunTask.later(() -> + { + if (player.getHealth() <= player.getMaxHealth() - 1d) // Avoids an IllegalArgumentException + { + player.setHealth(player.getHealth() + 1d); + } + }, 3L); + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c25f890..15e804b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -25,6 +25,7 @@ modules: "border-walls": true "border-warning": true "border-check": true + "informations-listHealth": true "other-playersLoader": true "other-about": true From 761b41216c3aa78805d0b13ade2c77d227a2df7e Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 10 Dec 2018 00:53:12 +0100 Subject: [PATCH 15/91] Correct gamemode in the WAITING phase --- .../amaury/UHCReloaded/modules/beginning/wait/WaitModule.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index d699cfb..442c4c0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -127,6 +127,8 @@ private void handleNewPlayer(final Player player) player.setFoodLevel(20); player.setSaturation(20f); + player.setGameMode(builder ? GameMode.CREATIVE : GameMode.ADVENTURE); + if (!builder && Config.INVENTORY.CLEAR.get()) { player.getInventory().clear(); From a5d5ec13bf1ae9e6b094007a837daff7a411927a Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 10 Dec 2018 02:33:41 +0100 Subject: [PATCH 16/91] Episodes module * NEW: Episodes module. * NEW: /uh shift [next episode number] --- .../UHCReloaded/game/UHGameManager.java | 13 +- .../modules/core/game/GameModule.java | 6 +- .../modules/ingame/episodes/Config.java | 55 ++++++ .../ingame/episodes/EpisodesModule.java | 183 ++++++++++++++++++ .../episodes/commands/ShiftCommand.java | 66 +++++++ .../episodes/events/EpisodeChangedEvent.java} | 41 +++- .../listHealth/ListHealthModule.java | 2 +- .../modules/other/pomf/PomfModule.java | 59 ++++++ .../old/events/EpisodeChangedCause.java | 47 ----- .../old/listeners/GameListener.java | 7 +- src/main/resources/config.yml | 3 +- 11 files changed, 413 insertions(+), 69 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/events/UHEpisodeChangedEvent.java => modules/ingame/episodes/events/EpisodeChangedEvent.java} (72%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{informations => ingame}/listHealth/ListHealthModule.java (98%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java index d1edf01..68a7eb0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java @@ -35,8 +35,7 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; -import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; @@ -724,18 +723,18 @@ public void shiftEpisode(String shifter) { this.episode++; - final EpisodeChangedCause cause; - if (shifter == null || shifter.equals("")) cause = EpisodeChangedCause.FINISHED; - else cause = EpisodeChangedCause.SHIFTED; + final EpisodeChangedEvent.EpisodeChangedCause cause; + if (shifter == null || shifter.equals("")) cause = EpisodeChangedEvent.EpisodeChangedCause.FINISHED; + else cause = EpisodeChangedEvent.EpisodeChangedCause.SHIFTED; // Restarts the timer. // Useless for a normal start (restarted in the event), but needed if the episode was shifted. - if (cause == EpisodeChangedCause.SHIFTED) + if (cause == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) { // p.getTimerManager().getMainTimer().start(); } - p.getServer().getPluginManager().callEvent(new UHEpisodeChangedEvent(episode, cause, shifter)); +// p.getServer().getPluginManager().callEvent(new EpisodeChangedEvent(episode, cause, shifter)); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 2b92265..b3d8a8f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -174,20 +174,20 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) topSidebar.add(I.tn("{white}{0}{gray} team", "{white}{0}{gray} teams", aliveTeams.size())); } - injector.injectLines(SidebarInjector.SidebarPriority.VERY_TOP, true, topSidebar); + injector.injectLines(SidebarInjector.SidebarPriority.TOP, true, topSidebar); switch (phase) { case WAIT: injector.injectLines( - SidebarInjector.SidebarPriority.VERY_TOP, true, + SidebarInjector.SidebarPriority.TOP, true, I.t("{gray}Waiting for players...") ); break; case STARTING: injector.injectLines( - SidebarInjector.SidebarPriority.VERY_TOP, true, + SidebarInjector.SidebarPriority.TOP, true, I.t("{gray}The game is starting..."), I.t("{gray}Please wait.") ); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java new file mode 100644 index 0000000..0147757 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java @@ -0,0 +1,55 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes; + +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<TimeDelta> LENGTH = item("length", new TimeDelta(0, 20, 0)); + static public final ConfigurationItem<Boolean> DISPLAY_TITLE = item("display-title", true); + static public final ConfigurationItem<Boolean> DISPLAY_IN_SIDEBAR = item("display-in-sidebar", true); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java new file mode 100644 index 0000000..1f41877 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java @@ -0,0 +1,183 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector.SidebarPriority; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.commands.ShiftCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.text.Titles; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.Collections; +import java.util.List; + + +@ModuleInfo ( + name = "Episodes", + description = "Displays time marks every 20 minutes (by default), e.g. to divide a recording for diffusion.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class EpisodesModule extends UHModule +{ + private final GameModule game = UR.module(GameModule.class); + private final TimersModule timers = UR.module(TimersModule.class); + + private Timer episodesTimer; + private int episode = 1; + + @Override + protected void onEnable() + { + episodesTimer = new Timer("Episodes"); + episodesTimer.setDuration(Config.LENGTH.get()); + episodesTimer.setSystem(true); + + timers.registerTimer(episodesTimer); + + episodesTimer.setDisplayed(true); + episodesTimer.setNameDisplayed(false); + + episodesTimer.start(); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(ShiftCommand.class); + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + if (!Config.DISPLAY_IN_SIDEBAR.get() || game.currentPhaseBefore(GamePhase.IN_GAME)) return; + + injector.injectLines(SidebarPriority.VERY_TOP, true, I.t("{gray}Episode {white}{0}", episode)); + } + + @EventHandler + public void onTimerEnds(final TimerEndsEvent ev) + { + if (!ev.getTimer().equals(episodesTimer)) return; + + ev.setRestart(true); + shift(false, null, episode + 1); + } + + /** + * Used to broadcast the episode change. + */ + @EventHandler + public void onEpisodeChange(final EpisodeChangedEvent ev) + { + final String message; + + if (ev.getCause() == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) + { + final String shifterName = ev.getShifter() instanceof ConsoleCommandSender ? I.t("the console") : ev.getShifter().getName(); + message = I.t("{aqua}-------- End of episode {0} [forced by {1}] --------", ev.getOldEpisode(), shifterName); + } + else + { + message = I.t("{aqua}-------- End of episode {0} --------", String.valueOf(ev.getOldEpisode())); + } + + Bukkit.broadcastMessage(message); + + + // Broadcasts title + if (Config.DISPLAY_TITLE.get()) + { + Titles.broadcastTitle( + 5, 32, 8, + /// The title displayed when the episode change. {0} = new episode number; {1} = old. + I.t("{darkaqua}Episode {aqua}{0}", ev.getNewEpisode(), ev.getOldEpisode()), + "" + ); + } + } + + public int getEpisode() + { + return episode; + } + + public void shift(final CommandSender shifter, final int newEpisode) + { + shift(true, shifter != null ? shifter : Bukkit.getConsoleSender(), newEpisode); + } + + public void shift(final CommandSender shifter) + { + shift(shifter, episode + 1); + } + + private void shift(final boolean forced, final CommandSender shifter, final int newEpisode) + { + final int oldEpisode = episode; + episode = newEpisode; + + // If not forced, the timer is restarted in the event, else we have to restart + // it manually. + if (forced) + { + episodesTimer.start(); + } + + Bukkit.getPluginManager().callEvent( + new EpisodeChangedEvent( + episode, + oldEpisode, + forced ? EpisodeChangedCause.SHIFTED : EpisodeChangedCause.FINISHED, + shifter + ) + ); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java new file mode 100644 index 0000000..17cfe33 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java @@ -0,0 +1,66 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.EpisodesModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; + + +@CommandInfo (name = "shift", usageParameters = "[next episode number]", aliases = {"shift-episode"}) +public class ShiftCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) + { + error(I.t("{ce}You can't shift the current episode because the game is not started.")); + } + + try + { + UR.module(EpisodesModule.class).shift(sender, Integer.parseInt(args[0])); + } + catch (ArrayIndexOutOfBoundsException | NumberFormatException e) + { + UR.module(EpisodesModule.class).shift(sender); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java similarity index 72% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java index e88c463..8c5ed40 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHEpisodeChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java @@ -30,8 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.events; +package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events; +import org.bukkit.command.CommandSender; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -39,15 +40,18 @@ /** * Called when an episode changes. */ -public class UHEpisodeChangedEvent extends Event +public class EpisodeChangedEvent extends Event { private int newEpisode; + private int oldEpisode; private EpisodeChangedCause cause; - private String shifter; + private CommandSender shifter; - public UHEpisodeChangedEvent(int newEpisode, EpisodeChangedCause cause, String shifter) + public EpisodeChangedEvent(int newEpisode, int oldEpisode, EpisodeChangedCause cause, CommandSender shifter) { this.newEpisode = newEpisode; + this.oldEpisode = oldEpisode; + this.cause = cause; this.shifter = shifter; } @@ -62,6 +66,16 @@ public int getNewEpisode() return newEpisode; } + /** + * Returns the old episode. + * + * @return The old episode. + */ + public int getOldEpisode() + { + return oldEpisode; + } + /** * Why the episode changed? * @@ -75,12 +89,12 @@ public EpisodeChangedCause getCause() } /** - * Returns the name of the shifter (the one that executed the /uh shift command, or "" if + * Returns the shifter (the one that executed the /uh shift command, or {@code null} if * the episode was shifted because the previous one was finished). * * @return The shifter. */ - public String getShifter() + public CommandSender getShifter() { return shifter; } @@ -99,4 +113,19 @@ public static HandlerList getHandlerList() { return handlers; } + + + public enum EpisodeChangedCause + { + /** + * The episode changed because the previous episode was finished. + */ + FINISHED, + + /** + * The episode changed because the previous episode was shifted by someone using + * the {@code /uh shift} command. + */ + SHIFTED + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java index f346641..c0e81a3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/informations/listHealth/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.informations.listHealth; +package eu.carrade.amaury.UHCReloaded.modules.ingame.listHealth; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java new file mode 100644 index 0000000..c275aa8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java @@ -0,0 +1,59 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.pomf; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.Config; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; + +@ModuleInfo( + name = "Pomf", + description = "Pomf au milieu des épisodes #parceque", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START +) +public class PomfModule extends UHModule +{ + @EventHandler + public void onEpisodeEnds(final EpisodeChangedEvent ev) + { + if (ev.getNewEpisode() == 5) + { + RunTask.later(() -> Bukkit.broadcastMessage("- Pomf -"), Config.LENGTH.get().divide(2).getSeconds() * 20L); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java deleted file mode 100644 index beae2ac..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/EpisodeChangedCause.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.events; - -public enum EpisodeChangedCause -{ - /** - * The episode changed because the previous episode was finished. - */ - FINISHED, - - /** - * The episode changed because the previous episode was shifted by someone using - * the {@code /uh shift} command. - */ - SHIFTED -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 07ce53c..8265ba2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -37,8 +37,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.EpisodeChangedCause; -import eu.carrade.amaury.UHCReloaded.old.events.UHEpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHGameEndsEvent; import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; @@ -544,11 +543,11 @@ public void onTimerStarts(final TimerStartsEvent ev) * Used to broadcast the episode change. */ @EventHandler - public void onEpisodeChange(final UHEpisodeChangedEvent ev) + public void onEpisodeChange(final EpisodeChangedEvent ev) { String message; - if (ev.getCause() == EpisodeChangedCause.SHIFTED) + if (ev.getCause() == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) { message = I.t("{aqua}-------- End of episode {0} [forced by {1}] --------", String.valueOf(ev.getNewEpisode() - 1), ev.getShifter()); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 15e804b..6dcdf57 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -25,7 +25,8 @@ modules: "border-walls": true "border-warning": true "border-check": true - "informations-listHealth": true + "ingame-listHealth": true + "ingame-episodes": true "other-playersLoader": true "other-about": true From 6bfc3c338dfc82ac3242ad7d0b787ac22b90ccfd Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 10 Dec 2018 03:22:46 +0100 Subject: [PATCH 17/91] /uh heal, heal-all, feed, feed-all. --- .../modules/ingame/food/FoodModule.java | 58 +++++++++ .../ingame/food/commands/FeedAllCommand.java | 88 +++++++++++++ .../ingame/food/commands/FeedCommand.java | 95 ++++++++++++++ .../modules/ingame/health/HealthModule.java | 58 +++++++++ .../health/commands/HealAllCommand.java | 123 ++++++++++++++++++ .../ingame/health/commands/HealCommand.java | 115 ++++++++++++++++ src/main/resources/config.yml | 2 + 7 files changed, 539 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java new file mode 100644 index 0000000..7ec684c --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java @@ -0,0 +1,58 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.food; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedAllCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedCommand; +import fr.zcraft.zlib.components.commands.Command; + +import java.util.Arrays; +import java.util.List; + + +@ModuleInfo ( + name = "Food commands", + description = "Provides commands to update food level & saturation of some or all players", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START +) +public class FoodModule extends UHModule +{ + @Override + public List<Class<? extends Command>> getCommands() + { + return Arrays.asList(FeedCommand.class, FeedAllCommand.class); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java new file mode 100644 index 0000000..a460146 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java @@ -0,0 +1,88 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands; + +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + + +@CommandInfo (name = "feed-all", usageParameters = "[foodPoints=20] [saturation=max]") +public class FeedAllCommand extends Command +{ + @Override + protected void run() throws CommandException + { + int foodLevel = 20; + float saturation = 20f; + + // /uh feed-all <foodLevel> + if (args.length > 0) + { + try + { + foodLevel = Integer.valueOf(args[0]); + } + catch (NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + } + + // /uh feed-all <foodLevel> <saturation> + if (args.length > 1) + { + try + { + // The saturation value cannot be more than the food level. + saturation = Math.max(foodLevel, Float.valueOf(args[1])); + } + catch (NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + } + } + } + + for (final Player player : Bukkit.getOnlinePlayers()) + { + player.setFoodLevel(foodLevel); + player.setSaturation(saturation); + } + + success(I.t("Set food level to {0} and saturation to {1} for every player.", foodLevel, saturation)); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java new file mode 100644 index 0000000..3a71683 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java @@ -0,0 +1,95 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands; + +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; + +import java.util.List; + + +@CommandInfo (name = "feed", usageParameters = "<player> [foodPoints=20] [saturation=max]", aliases = {"food"}) +public class FeedCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final Player target = getPlayerParameter(0); + + int foodLevel = 20; + float saturation = 20f; + + // /uh feed <player> <foodLevel> + if (args.length > 1) + { + try + { + foodLevel = Integer.valueOf(args[1]); + } + catch (final NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + } + + // /uh feed <player> <foodLevel> <saturation> + if (args.length > 2) + { + try + { + // The saturation value cannot be more than the food level. + saturation = Math.max(foodLevel, Float.valueOf(args[2])); + } + catch (final NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + } + } + } + + target.setFoodLevel(foodLevel); + target.setSaturation(saturation); + + success(I.t("Set food level to {0} and saturation to {1} for {2}.", foodLevel, saturation, target.getName())); + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingPlayerNames(args[0]); + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java new file mode 100644 index 0000000..4a190d8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java @@ -0,0 +1,58 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.health; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealAllCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealCommand; +import fr.zcraft.zlib.components.commands.Command; + +import java.util.Arrays; +import java.util.List; + + +@ModuleInfo ( + name = "Health commands", + description = "Provides commands to update health of some or all players", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START +) +public class HealthModule extends UHModule +{ + @Override + public List<Class<? extends Command>> getCommands() + { + return Arrays.asList(HealCommand.class, HealAllCommand.class); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java new file mode 100644 index 0000000..fdbaf27 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java @@ -0,0 +1,123 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + + +@CommandInfo (name = "heal-all", usageParameters = "[half-hearts=20|±diff]", aliases = {"healall"}) +public class HealAllCommand extends Command +{ + @Override + protected void run() throws CommandException + { + double diffHealth; + boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode + + // /uh heal-all: full life for player. + if (args.length == 0) + { + diffHealth = Integer.MAX_VALUE; + } + + // /uh heal-all <hearts> + else + { + try + { + if (args[0].startsWith("+") || args[0].startsWith("-")) + { + add = true; + } + + diffHealth = Double.parseDouble(args[0]); + } + catch (final NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); + return; + } + } + + if (!add && diffHealth <= 0) + { + error(I.t("{ce}Serial killer!")); + } + + for (final Player player : Bukkit.getServer().getOnlinePlayers()) + { + double health = !add ? diffHealth : player.getHealth() + diffHealth; + + if (health <= 0D) + { + warning(I.t("{ce}The health of {0} was not updated to avoid a kill.", player.getName())); + continue; + } + else if (health > player.getMaxHealth()) + { + health = player.getMaxHealth(); + } + + player.setHealth(health); + UR.module(TeamsModule.class).getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); + } + + if (!add) + { + if (diffHealth == Integer.MAX_VALUE) + { + success(I.t("The health of all players was completely filled.", diffHealth)); + } + else + { + success(I.t("The health of all players was set to {0}.", diffHealth)); + } + } + else if (diffHealth > 0) + { + success(I.t("The health of all players was increased by {0}.", diffHealth)); + } + else + { + success(I.t("The health of all players was decreased by {0}.", -diffHealth)); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java new file mode 100644 index 0000000..97d1679 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java @@ -0,0 +1,115 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; + +import java.util.List; + + +@CommandInfo (name = "heal", usageParameters = "<player> [half-hearts=20|±diff]", aliases = {"life", "set-health", "sethealth"}) +public class HealCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length == 0) + { + throwInvalidArgument(I.t("A player is required")); + } + + final Player target = getPlayerParameter(0); + + double health; + boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode + + // /uh heal <player> : full life for player. + if (args.length == 1) + { + health = 20D; + } + + // /uh heal <player> <hearts> + else + { + double diffHealth; + + try + { + if (args[1].startsWith("+") || args[1].startsWith("-")) + { + add = true; + } + + diffHealth = Double.parseDouble(args[1]); + } + catch (final NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); + return; + } + + health = !add ? diffHealth : target.getHealth() + diffHealth; + + if (health <= 0D) + { + error(I.t("{ce}You can't kill a player with this command, to avoid typo fails.")); + } + else if (health > 20D) + { + health = 20D; + } + } + + target.setHealth(health); + + // TODO Could we get rid of this hard reference? + UR.module(TeamsModule.class).getSidebarPlayerCache(target.getUniqueId()).updateHealth(health); + + success(I.t("The health of {0} was set to {1}.", target.getName(), health)); + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingPlayerNames(args[0]); + else return null; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6dcdf57..906a9c1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -25,6 +25,8 @@ modules: "border-walls": true "border-warning": true "border-check": true + "ingame-food": true + "ingame-health": true "ingame-listHealth": true "ingame-episodes": true "other-playersLoader": true From ecbbab70b1a3e10019ec42ed12f97895d3e2aacd Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 00:38:07 +0100 Subject: [PATCH 18/91] Hardcore hearts --- .../amaury/UHCReloaded/UHCReloaded.java | 10 +-- .../amaury/UHCReloaded/core/ModuleInfo.java | 5 ++ .../UHCReloaded/core/ModuleWrapper.java | 30 ++++++++- .../cosmetics/hardcoreHearts/Config.java | 61 +++++++++++++++++ .../hardcoreHearts/HardcoreHeartsModule.java | 67 +++++++++++++++++++ .../hardcoreHearts}/PacketsListener.java | 24 +++---- .../integration/UHProtocolLibIntegration.java | 4 +- src/main/resources/config.yml | 1 + 8 files changed, 180 insertions(+), 22 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/listeners => modules/cosmetics/hardcoreHearts}/PacketsListener.java (83%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index ea84d0a..d6b4384 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -238,36 +238,38 @@ public final void registerModules(final Class<? extends UHModule>... modules) */ private void registerModule(final Class<? extends UHModule> module, final boolean enableAtStartup) { - final String name, description; + final String description; final ModuleInfo.ModuleLoadTime priority; final boolean internal; final Class<? extends ConfigurationInstance> moduleConfiguration; final String settingsFileName; + final String[] dependencies; + final ModuleInfo info = module.getAnnotation(ModuleInfo.class); if (info == null) { - name = ""; description = ""; internal = false; priority = ModuleInfo.ModuleLoadTime.POST_WORLD; moduleConfiguration = null; settingsFileName = null; + dependencies = new String[] {}; } else { - name = info.name(); description = info.description(); internal = info.internal(); priority = info.when(); moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); + dependencies = info.depends(); } this.modules.put(module, new ModuleWrapper( - name, description, internal, enableAtStartup, priority, module, moduleConfiguration, settingsFileName)); + description, internal, enableAtStartup, priority, module, moduleConfiguration, settingsFileName, dependencies)); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index 82be2ca..275176d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -71,6 +71,11 @@ */ String settings_filename() default ""; + /** + * @return A list of external Bukkit/Spigot plugin this module depends on. + */ + String[] depends() default {}; + /** * @return {@code true} if this module is an internal core module * that should always be loaded first. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 243d766..01ed1a2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -40,6 +40,7 @@ import fr.zcraft.zlib.tools.reflection.Reflection; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; import java.io.File; import java.io.IOException; @@ -56,6 +57,7 @@ public class ModuleWrapper private final Class<? extends ConfigurationInstance> moduleConfiguration; private final String settingsFileName; + private String[] dependencies; private final boolean internal; @@ -64,14 +66,14 @@ public class ModuleWrapper private UHModule instance = null; public ModuleWrapper( - final String name, final String description, final boolean internal, final boolean enabledAtStartup, final ModuleInfo.ModuleLoadTime when, final Class<? extends UHModule> moduleClass, final Class<? extends ConfigurationInstance> moduleConfiguration, - final String settingsFileName) + final String settingsFileName, + final String[] dependencies) { this.name = computeModuleName(moduleClass); this.description = description; @@ -81,6 +83,7 @@ public ModuleWrapper( this.moduleClass = moduleClass; this.moduleConfiguration = moduleConfiguration; this.settingsFileName = settingsFileName; + this.dependencies = dependencies; loadConfiguration(); } @@ -90,6 +93,29 @@ public ModuleWrapper( */ public void enable() { + // Check dependencies + + for (String dependency : dependencies) + { + final Plugin plugin = Bukkit.getPluginManager().getPlugin(dependency); + if (plugin == null) + { + if (dependencies.length >= 2) + { + PluginLogger.warning("Cannot enable module {0}: missing dependency {1} (depends on {2}).", name, dependency, String.join(", ", dependencies)); + } + else + { + PluginLogger.warning("Cannot enable module {0}: missing dependency {1}.", name, dependency); + } + } + else if (!plugin.isEnabled()) + { + // Ensures every dependency is available when a module is loaded. + Bukkit.getPluginManager().enablePlugin(plugin); + } + } + instance = ZLib.loadComponent(moduleClass); Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java new file mode 100644 index 0000000..abd90ca --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java @@ -0,0 +1,61 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> HARDCORE_HEARTS = item("hardcore-hearts", true); + + static public final AutoRespawnSection AUTO_RESPAWN = section("auto-respawn", AutoRespawnSection.class); + + static public class AutoRespawnSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> DO = item("do", true); + public final ConfigurationItem<Integer> DELAY = item("delay", 6); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java new file mode 100644 index 0000000..7b16a68 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -0,0 +1,67 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; + +import com.comphenix.protocol.ProtocolLibrary; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.core.ZLib; + + +@ModuleInfo ( + name = "Hardcore hearts", + description = "Replaces hearts with hardcore hearts. Depends on ProtocolLib.", + depends = "ProtocolLib", + settings = Config.class +) +public class HardcoreHeartsModule extends UHModule +{ + @Override + protected void onEnable() + { + final PacketsListener packetsListener = new PacketsListener(); + + if (Config.HARDCORE_HEARTS.get()) + { + ProtocolLibrary.getProtocolManager().addPacketListener(packetsListener); + } + + if (Config.AUTO_RESPAWN.DO.get()) + { + ZLib.registerEvents(packetsListener); + } + + log().info("Successfully hooked into ProtocolLib."); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java index a838418..5015384 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/PacketsListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.listeners; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; @@ -40,8 +40,8 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.EnumWrappers; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -52,17 +52,13 @@ public class PacketsListener extends PacketAdapter implements Listener { - private UHCReloaded p; - private ProtocolManager pm = ProtocolLibrary.getProtocolManager(); - + private final ProtocolManager pm = ProtocolLibrary.getProtocolManager(); private final PacketContainer respawnPacket; - public PacketsListener(UHCReloaded p) + public PacketsListener() { // This listener needs to listen on login packets only. - super(UHCReloaded.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); - - this.p = UHCReloaded.get(); + super(UR.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); // The packet to send to automatically respawn the player. respawnPacket = pm.createPacket(PacketType.Play.Client.CLIENT_COMMAND); @@ -73,7 +69,7 @@ public PacketsListener(UHCReloaded p) * Used to present the server as an hardcore server, for the clients to display hardcore hearts. */ @Override - public void onPacketSending(PacketEvent ev) + public void onPacketSending(final PacketEvent ev) { // If its a login packet, write the hardcore flag (first boolean) to true. if (ev.getPacketType().equals(PacketType.Play.Server.LOGIN)) @@ -88,7 +84,7 @@ public void onPacketSending(PacketEvent ev) @EventHandler public void onPlayerDeath(final PlayerDeathEvent ev) { - if (UHConfig.AUTO_RESPAWN.DO.get()) + if (Config.AUTO_RESPAWN.DO.get()) { RunTask.later(() -> { @@ -96,11 +92,11 @@ public void onPlayerDeath(final PlayerDeathEvent ev) { pm.recieveClientPacket(ev.getEntity(), respawnPacket); } - catch (IllegalAccessException | InvocationTargetException e) + catch (final IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + UR.log(HardcoreHeartsModule.class).error("Unable to respawn player {0}", e, ev.getEntity().getName()); } - }, UHConfig.AUTO_RESPAWN.DELAY.get() * 20L); + }, Config.AUTO_RESPAWN.DELAY.get() * 20L); } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java index f8dc2c3..506e02b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java @@ -35,7 +35,7 @@ import com.comphenix.protocol.ProtocolLibrary; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.listeners.PacketsListener; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts.PacketsListener; import fr.zcraft.zlib.tools.PluginLogger; @@ -43,7 +43,7 @@ public class UHProtocolLibIntegration { public UHProtocolLibIntegration(UHCReloaded p) { - PacketsListener packetsListener = new PacketsListener(p); + PacketsListener packetsListener = new PacketsListener(); if (UHConfig.HARDCORE_HEARTS.DISPLAY.get()) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 906a9c1..f563559 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -29,6 +29,7 @@ modules: "ingame-health": true "ingame-listHealth": true "ingame-episodes": true + "cosmetics-hardcoreHearts": true "other-playersLoader": true "other-about": true From db847873761c06d35b036a31be96813d4fd4501f Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 01:03:17 +0100 Subject: [PATCH 19/91] MOTD module --- .../modules/core/game/GameModule.java | 36 ++++ .../modules/cosmetics/motd/Config.java | 52 ++++++ .../modules/cosmetics/motd/MotdModule.java | 156 ++++++++++++++++++ src/main/resources/config.yml | 1 + 4 files changed, 245 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index b3d8a8f..a0d7d71 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -99,6 +99,11 @@ public class GameModule extends UHModule implements Listener */ private final Set<ZTeam> aliveTeams = new HashSet<>(); + /** + * When the game ends, stores the last standing team. + */ + private ZTeam winner = null; + /** * {@code true} if there is teams in this game. */ @@ -210,6 +215,11 @@ public Set<OfflinePlayer> getAlivePlayers() return alivePlayers.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toSet()); } + public int countAlivePlayers() + { + return alivePlayers.size(); + } + public Set<Player> getAliveConnectedPlayers() { return alivePlayers.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).filter(Player::isOnline).collect(Collectors.toSet()); @@ -220,6 +230,19 @@ public Set<ZTeam> getAliveTeams() return Collections.unmodifiableSet(aliveTeams); } + public int countAliveTeams() + { + return aliveTeams.size(); + } + + /** + * @return The game's winner, if any; null else. + */ + public ZTeam getWinner() + { + return winner; + } + public boolean isAlive(final OfflinePlayer player) { return alivePlayers.contains(player.getUniqueId()); @@ -759,6 +782,19 @@ public void onPlayerResurrected(final PlayerResurrectedEvent ev) Bukkit.broadcastMessage(I.t("{gold}{0} returned from the dead!", ev.getPlayer().getName())); } + @EventHandler + public void onGameEndsOrEndsCancelled(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() == GamePhase.END) + { + winner = aliveTeams.stream().findAny().orElse(null); // There will be one alive team left here. + } + else if (ev.getNewPhase() == GamePhase.IN_GAME && ev.getOldPhase() == GamePhase.END) + { + winner = null; // Win cancelled because a team was resurrected. + } + } + /* *** OTHER PLAYERS MANAGEMENT *** */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java new file mode 100644 index 0000000..3c0845b --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> DISPLAY_MATCH_NAME = item("display-match-name", true); + static public final ConfigurationItem<String> MATCH_NAME_PREFIX = item("match-name-prefix", ""); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java new file mode 100644 index 0000000..b3238a2 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java @@ -0,0 +1,156 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; +import org.bukkit.ChatColor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.server.ServerListPingEvent; + + +@ModuleInfo ( + name = "MOTD", + description = "Updates the MOTD according to the current game state", + settings = Config.class +) +public class MotdModule extends UHModule +{ + private final GameModule game = UR.module(GameModule.class); + + private String matchName = ""; + private String currentMOTD; + + public void onEnable() + { + if (Config.DISPLAY_MATCH_NAME.get()) + { + matchName = ChatColor.translateAlternateColorCodes('&', Config.MATCH_NAME_PREFIX.get()) + + eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get() + + ChatColor.RESET + "\n"; + } + } + + + @EventHandler + public void onGamePhaseChange(final GamePhaseChangedEvent ev) + { + switch (ev.getNewPhase()) + { + case WAIT: + updateMOTDBeforeStart(); + break; + + case STARTING: + updateMOTDDuringStart(); + break; + + case IN_GAME: + updateMOTDDuringGame(); + break; + + case END: + updateMOTDAfterGame(game.getWinner()); + break; + } + } + + @EventHandler + public void onServerListPing(final ServerListPingEvent ev) + { + ev.setMotd(currentMOTD); + } + + + /** + * Updates the MOTD to the one displayed before the game start. + */ + private void updateMOTDBeforeStart() + { + /// MOTD when the game is not started. + currentMOTD = matchName + I.t("Waiting for players..."); + } + + /** + * Updates the MOTD to the one displayed during the start. + */ + private void updateMOTDDuringStart() + { + /// MOTD when the game is starting (slow TP in progress). + currentMOTD = matchName + I.t("Starting in progress..."); + } + + /** + * Updates the MOTD to the one displayed during the game (includes alive counts). + * <p> + * This need to be called on each death, to update alive counts. + */ + private void updateMOTDDuringGame() + { + if (game.isTeamsGame()) + { + /// Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. + currentMOTD = matchName + I.tn("Game running! {0} player alive in {1} team.", "Game running! {0} players alive in {1} teams.", game.countAlivePlayers(), game.countAlivePlayers(), game.countAliveTeams()); + } + else + { + /// Solo game running MOTD. {0} = players alive count. + currentMOTD = matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", game.countAlivePlayers()); + } + } + + /** + * Updates the MOTD after the game. + * + * @param winner The winner. + */ + private void updateMOTDAfterGame(final ZTeam winner) + { + if (game.isTeamsGame()) + { + /// Game finished MOTD with team winner ({0} = team display name). + currentMOTD = matchName + I.t("Game finished; the team {0} wins this match!", winner != null ? winner.getDisplayName() : "??"); + } + else + { + /// Game finished MOTD with solo winner ({0} = winner raw name). + currentMOTD = matchName + I.t("Game finished; congratulation to {0} for his victory!", winner != null ? winner.getName() : "??"); + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f563559..10e13ff 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -30,6 +30,7 @@ modules: "ingame-listHealth": true "ingame-episodes": true "cosmetics-hardcoreHearts": true + "cosmetics-motd": true "other-playersLoader": true "other-about": true From 91a1e3c734a315b049777b6db249ef8f0e975329 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 01:08:53 +0100 Subject: [PATCH 20/91] Fixed NPE while using the small grid (from banner-on-shield) --- .../UHCReloaded/modules/core/teams/TeamsModule.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index b6e494d..e387a0e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -203,7 +203,6 @@ public void onGameStart(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME) return; - // Banners if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) { RunTask.later(() -> @@ -261,9 +260,12 @@ public void onShieldPreCraft(final PrepareItemCraftEvent ev) { if (!Config.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; - final Player player = (Player) ev.getViewers().get(0); - final ZTeam team = ZTeams.get().getTeamForPlayer(player); + // The viewers list is empty for crafts from the small crafting + // grid in the inventory. In this case we use another data source. + final Player player = !ev.getViewers().isEmpty() ? (Player) ev.getViewers().get(0) : (Player) ev.getView().getPlayer(); + if (player == null) return; + final ZTeam team = ZTeams.get().getTeamForPlayer(player); if (team == null || team.getBanner() == null) return; final Recipe recipe = ev.getRecipe(); From c923f282fd15eb51796b8cbc34e4ec22545e10de Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 01:13:25 +0100 Subject: [PATCH 21/91] Updated MOTD module for live-update config. --- .../modules/cosmetics/motd/MotdModule.java | 115 ++++++------------ 1 file changed, 36 insertions(+), 79 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java index b3238a2..553008a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java @@ -36,7 +36,6 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; @@ -54,103 +53,61 @@ public class MotdModule extends UHModule { private final GameModule game = UR.module(GameModule.class); - private String matchName = ""; - private String currentMOTD; - - public void onEnable() + private String getMOTD() { + final String matchName; + if (Config.DISPLAY_MATCH_NAME.get()) { matchName = ChatColor.translateAlternateColorCodes('&', Config.MATCH_NAME_PREFIX.get()) - + eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get() - + ChatColor.RESET + "\n"; + + eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get() + + ChatColor.RESET + "\n"; + } + else + { + matchName = ""; } - } - - @EventHandler - public void onGamePhaseChange(final GamePhaseChangedEvent ev) - { - switch (ev.getNewPhase()) + switch (game.getPhase()) { case WAIT: - updateMOTDBeforeStart(); - break; + return matchName + I.t("Waiting for players..."); case STARTING: - updateMOTDDuringStart(); - break; + return matchName + I.t("Starting in progress..."); case IN_GAME: - updateMOTDDuringGame(); - break; + if (game.isTeamsGame()) + { + /// Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. + return matchName + I.tn("Game running! {0} player alive in {1} team.", "Game running! {0} players alive in {1} teams.", game.countAlivePlayers(), game.countAlivePlayers(), game.countAliveTeams()); + } + else + { + /// Solo game running MOTD. {0} = players alive count. + return matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", game.countAlivePlayers()); + } case END: - updateMOTDAfterGame(game.getWinner()); - break; + default: + final ZTeam winner = game.getWinner(); + + if (game.isTeamsGame()) + { + /// Game finished MOTD with team winner ({0} = team display name). + return matchName + I.t("Game finished; the team {0} wins this match!", winner != null ? winner.getDisplayName() : "??"); + } + else + { + /// Game finished MOTD with solo winner ({0} = winner raw name). + return matchName + I.t("Game finished; congratulation to {0} for his victory!", winner != null ? winner.getName() : "??"); + } } } @EventHandler public void onServerListPing(final ServerListPingEvent ev) { - ev.setMotd(currentMOTD); - } - - - /** - * Updates the MOTD to the one displayed before the game start. - */ - private void updateMOTDBeforeStart() - { - /// MOTD when the game is not started. - currentMOTD = matchName + I.t("Waiting for players..."); - } - - /** - * Updates the MOTD to the one displayed during the start. - */ - private void updateMOTDDuringStart() - { - /// MOTD when the game is starting (slow TP in progress). - currentMOTD = matchName + I.t("Starting in progress..."); - } - - /** - * Updates the MOTD to the one displayed during the game (includes alive counts). - * <p> - * This need to be called on each death, to update alive counts. - */ - private void updateMOTDDuringGame() - { - if (game.isTeamsGame()) - { - /// Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. - currentMOTD = matchName + I.tn("Game running! {0} player alive in {1} team.", "Game running! {0} players alive in {1} teams.", game.countAlivePlayers(), game.countAlivePlayers(), game.countAliveTeams()); - } - else - { - /// Solo game running MOTD. {0} = players alive count. - currentMOTD = matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", game.countAlivePlayers()); - } - } - - /** - * Updates the MOTD after the game. - * - * @param winner The winner. - */ - private void updateMOTDAfterGame(final ZTeam winner) - { - if (game.isTeamsGame()) - { - /// Game finished MOTD with team winner ({0} = team display name). - currentMOTD = matchName + I.t("Game finished; the team {0} wins this match!", winner != null ? winner.getDisplayName() : "??"); - } - else - { - /// Game finished MOTD with solo winner ({0} = winner raw name). - currentMOTD = matchName + I.t("Game finished; congratulation to {0} for his victory!", winner != null ? winner.getName() : "??"); - } + ev.setMotd(getMOTD()); } } From 45862ce81c0bea3d1fac725574f76e80185fbacc Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 03:11:56 +0100 Subject: [PATCH 22/91] Death annoucements * NEW: Added death announcements * BUG: fixed nasty bugs related to game phases played backwards * BUG: fixed `removeSpectator` method not removing spectators --- .../carrade/amaury/UHCReloaded/UHConfig.java | 3 +- .../modules/beginning/cages/Cage.java | 2 + .../UHCReloaded/modules/core/game/Config.java | 4 +- .../modules/core/game/GameModule.java | 6 + .../core/game/commands/KillCommand.java | 13 +- .../core/game/commands/ResurrectCommand.java | 18 ++ .../core/game/submanagers/GameBeginning.java | 1 + .../core/spectators/SpectatorsModule.java | 10 +- .../modules/core/teams/TeamsModule.java | 1 + .../ingame/deathAnnouncement/Config.java | 58 +++++++ .../DeathAnnouncementModule.java | 163 ++++++++++++++++++ .../amaury/UHCReloaded/utils/UHSound.java | 5 + src/main/resources/config.yml | 1 + 13 files changed, 275 insertions(+), 10 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index e8f1479..d189d52 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -2,7 +2,6 @@ import eu.carrade.amaury.UHCReloaded.modules.beginning.cages.Cage; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.configuration.*; import org.bukkit.Material; import org.bukkit.Sound; @@ -599,6 +598,6 @@ static public class SoundSection extends ConfigurationSection static { // ConfigurationValueHandlers.registerHandlers(TeamManager.class); - ConfigurationValueHandlers.registerHandlers(UHSound.class); +// ConfigurationValueHandlers.registerHandlers(UHSound.class); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java index 489ef0a..f02a54a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java @@ -257,6 +257,8 @@ public boolean build() */ public void destroy() { + if (!built) return; + for (final Map.Entry<Location, SimpleBlock> entry : blocksBuilt.entrySet()) { final Block block = entry.getKey().getBlock(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index 5ea5877..e1fa9b5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -49,7 +49,7 @@ public Config(File file) super(file); } - public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 12); // Recommended: 7 or 12 + public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 1); // TODO 12 Recommended: 7 or 12 public static final ConfigurationItem<Boolean> STARTUP_TITLE = item("startup-title", true); public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = item("random-color-in-solo-games", true); @@ -67,7 +67,7 @@ public static final class SlowSection extends ConfigurationSection public static final class BeginningSection extends ConfigurationSection { - public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); + public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 2)); // TODO 30s public final ConfigurationItem<Boolean> DISPLAY_GRACE_PERIOD = item("display-grace-period", true); public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index a0d7d71..6db9529 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -326,12 +326,17 @@ public boolean resurrect(final OfflinePlayer player) { if (isAlive(player)) return false; + log().info("Resurrecting player {0}", player.getName()); + alivePlayers.add(player.getUniqueId()); updateAliveTeams(); + log().info("Resurrected. Alive players: {0}. Teams: {1}. Phase: {2}.", alivePlayers.size(), aliveTeams.size(), phase); + if (aliveTeams.size() > 1 && phase == GamePhase.END) { setPhase(GamePhase.IN_GAME); + log().info("Going back to IN_GAME phase. Phase is now {0}.", phase); } Bukkit.getPluginManager().callEvent(new PlayerResurrectedEvent(player)); @@ -727,6 +732,7 @@ public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev public void onGameStarts(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME) return; + if (ev.getOldPhase() != GamePhase.STARTING) return; Bukkit.getOnlinePlayers().forEach(ActionBar::removeMessage); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java index 3d90606..b9264f6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java @@ -69,7 +69,18 @@ protected void run() throws CommandException if (UR.module(GameModule.class).isAlive(player)) { - UR.module(GameModule.class).kill(player); + if (player.isOnline()) + { + // If the player is online, we kill it. + // It will be cached by normal alive players's death listeners, + // plus the inventory will drop, effects will be complete, etc. + player.getPlayer().setHealth(0d); + } + else + { + // We only kill the player this way if he is offline. + UR.module(GameModule.class).kill(player); + } success(I.t("{cs}The player {0} is now marked as dead.", player.getName())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java index df73637..c7780c3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java @@ -43,6 +43,8 @@ import org.bukkit.OfflinePlayer; import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; @CommandInfo (name = "resurrect", usageParameters = "<player>", aliases = {"revive", "undead"}) @@ -73,4 +75,20 @@ else if (UR.module(GameModule.class).resurrect(player)) error(I.t("{ce}This player is not playing or dead!")); } } + + @Override + protected List<String> complete() + { + final GameModule game = UR.module(GameModule.class); + + if (args.length == 1) + { + return getMatchingPlayerNames( + Bukkit.getOnlinePlayers().stream().filter(player -> !game.isAlive(player)).collect(Collectors.toList()), + args[0] + ); + } + + else return null; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 39ab0c3..3e04367 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -71,6 +71,7 @@ public class GameBeginning extends ZLibComponent implements Listener public void onGameStarts(GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME) return; + if (ev.getOldPhase() != GamePhase.STARTING) return; // Only the first start /* *** Grace period (damages disabled) *** */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index 7239c9c..e9cd641 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -112,7 +112,7 @@ public boolean isSpectator(final OfflinePlayer player) * * @param playerID The spectator's ID. */ - public void addSpectator(UUID playerID) + public void addSpectator(final UUID playerID) { spectators.add(playerID); @@ -125,7 +125,7 @@ public void addSpectator(UUID playerID) * * @param player The spectator. */ - public void addSpectator(OfflinePlayer player) + public void addSpectator(final OfflinePlayer player) { addSpectator(player.getUniqueId()); } @@ -135,9 +135,9 @@ public void addSpectator(OfflinePlayer player) * * @param playerID The spectator's ID. */ - public void removeSpectator(UUID playerID) + public void removeSpectator(final UUID playerID) { - spectators.add(playerID); + spectators.remove(playerID); if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) manager.setSpectating(playerID, false); @@ -148,7 +148,7 @@ public void removeSpectator(UUID playerID) * * @param player The spectator. */ - public void removeSpectator(OfflinePlayer player) + public void removeSpectator(final OfflinePlayer player) { removeSpectator(player.getUniqueId()); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index e387a0e..f14f381 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -202,6 +202,7 @@ public SidebarPlayerCache getSidebarPlayerCache(final UUID id) public void onGameStart(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME) return; + if (ev.getOldPhase() != GamePhase.STARTING) return; if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java new file mode 100644 index 0000000..cf17a88 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java @@ -0,0 +1,58 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.deathAnnouncement; + +import eu.carrade.amaury.UHCReloaded.utils.UHSound; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Boolean> NOTIFY_IF_TEAM_HAS_FALLEN = item("notify-if-team-has-fallen", true); + public static final ConfigurationItem<String> DEATH_MESSAGES_FORMAT = item("death-messages-format", "§6"); + public static final ConfigurationItem<String> TEAM_DEATH_MESSAGES_FORMAT = item("team-death-messages-format", "§6"); + + public static final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); + public static final ConfigurationItem<Boolean> PLAY_SOUND = item("play-sound", true); + public static final ConfigurationItem<UHSound> SOUND = item("sound", new UHSound("WITHER_SPAWN")); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java new file mode 100644 index 0000000..372c5bc --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java @@ -0,0 +1,163 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.deathAnnouncement; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; +import eu.carrade.amaury.UHCReloaded.utils.UHSound; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.components.rawtext.RawTextPart; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; + +@ModuleInfo ( + name = "Death Announcements", + description = "Adds announcements for players & teams deaths", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class DeathAnnouncementModule extends UHModule +{ + private UHSound deathSound; + + @Override + protected void onEnable() + { + deathSound = Config.SOUND.get(); + } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + final PlayerDeathEvent pdev = ev.getPlayerDeathEvent(); + + // Highlights the death message in the console + Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "-- Death of " + ev.getPlayer().getName() + (pdev != null ? " (" + pdev.getDeathMessage() + ")" : "") + " --"); + + // If this is a real death + if (pdev != null) + { + // We send a lightning strike. + + if (Config.LIGHTNING_STRIKE.get()) + { + pdev.getEntity().getLocation().getWorld().strikeLightningEffect(pdev.getEntity().getLocation()); + } + } + + // If it is a death of an offline player + else + { + Bukkit.broadcastMessage(colorizePlayerInString(I.t("{0} died, following a game master's order.", ev.getPlayer().getName()), ev.getPlayer())); + } + + + // Play sound + if (Config.PLAY_SOUND.get()) + { + deathSound.broadcast(); + } + } + + @EventHandler + public void onTeamDeath(final TeamDeathEvent ev) + { + if (Config.NOTIFY_IF_TEAM_HAS_FALLEN.get()) + { + // Used to display this message after the death message. + RunTask.later(() -> + { + final ZTeam team = ev.getTeam(); + final String format = ChatColor.translateAlternateColorCodes('&', Config.TEAM_DEATH_MESSAGES_FORMAT.get()); + + final RawTextPart<?> teamTooltip = new RawText() + .then(team.getName()).style(team.getColorOrWhite().toChatColor(), ChatColor.BOLD); + + for (final OfflinePlayer player : team.getPlayers()) + { + teamTooltip.then("\n") + .then("- ").color(ChatColor.GRAY) + .then(player.getName()).color(ChatColor.WHITE); + } + + RawMessage.broadcast( + new RawText(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)) + .hover(teamTooltip) + ); + }, 1L); + } + } + + /** + * Colorizes each instance of the given player name in the string with its team color, + * if the player is in a team. + * + * @param str The string to colorize. + * @param player The player to look for in the string. + * @return The colorized string. + */ + private String colorizePlayerInString(final String str, final OfflinePlayer player) + { + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + if (team == null) return str; + + // We split the name to recompose the string with the colored name in each hole + final String[] strParts = str.split(player.getName()); + final ChatColor color = team.getColorOrWhite().toChatColor(); + final StringBuilder colorizedStr = new StringBuilder(); + + for (int i = 0; i < strParts.length; i++) + { + colorizedStr.append(strParts[i]); + + if (i != strParts.length - 1) // If not the last one + { + final String previousStyles = ChatColor.getLastColors(colorizedStr.toString()); + colorizedStr.append(color).append(player.getName()).append(previousStyles); + } + } + + return colorizedStr.toString(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java index 1e57c03..9922a5e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java @@ -34,6 +34,7 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; +import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -361,4 +362,8 @@ public static Sound handleSoundValue(Object object) { return string2Sound(object.toString()); } + + static { + ConfigurationValueHandlers.registerHandlers(UHSound.class); + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 10e13ff..11617db 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -29,6 +29,7 @@ modules: "ingame-health": true "ingame-listHealth": true "ingame-episodes": true + "ingame-deathAnnouncement": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true "other-playersLoader": true From a034c7cc0b68546a789243e4a5c159479bf46b08 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 04:12:30 +0100 Subject: [PATCH 23/91] Best way to fix backwards-running game bugs. Ref. 45862ce81c0bea3d1fac725574f76e80185fbacc --- .../modules/core/game/GameModule.java | 5 ++-- .../events/game/GamePhaseChangedEvent.java | 25 +++++++++++++++++++ .../core/game/submanagers/GameBeginning.java | 3 +-- .../modules/core/teams/TeamsModule.java | 3 +-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 6db9529..738684a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -731,8 +731,7 @@ public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev @EventHandler (priority = EventPriority.LOWEST) public void onGameStarts(final GamePhaseChangedEvent ev) { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; - if (ev.getOldPhase() != GamePhase.STARTING) return; + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; Bukkit.getOnlinePlayers().forEach(ActionBar::removeMessage); @@ -795,7 +794,7 @@ public void onGameEndsOrEndsCancelled(final GamePhaseChangedEvent ev) { winner = aliveTeams.stream().findAny().orElse(null); // There will be one alive team left here. } - else if (ev.getNewPhase() == GamePhase.IN_GAME && ev.getOldPhase() == GamePhase.END) + else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) { winner = null; // Win cancelled because a team was resurrected. } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java index e9cbabe..35f577b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java @@ -38,6 +38,13 @@ /** * Fired when the game phase changes. + * + * <p><strong>Warning:</strong> if the new phase is {@link GamePhase#IN_GAME IN_GAME} + * or {@link GamePhase#WAIT WAIT}, the game may be going backwards, if the game start + * was cancelled because of an error, or if a player was resurrected at the end of the + * game. To check if you are in this case, and e.g. avoid running game-start-code when + * a player is resurrected, check the old phase with {@link #getOldPhase()}, or simpler, + * use the {@link #isRunningForward()} method.</p> */ public class GamePhaseChangedEvent extends Event { @@ -70,6 +77,24 @@ public GamePhase getNewPhase() return newPhase; } + /** + * Checks if this phase change is running forward regarding the normal phases progression. + * + * <h3>Example</h3> + * <ul> + * <li>If we have the cycle {@link GamePhase#STARTING STARTING} → {@link GamePhase#IN_GAME IN_GAME}, + * this will return {@code true}.</li> + * <li>If we have the cycle {@link GamePhase#END END} → {@link GamePhase#IN_GAME IN_GAME}, + * this will return {@code false}.</li> + * </ul> + * + * @return {@code true} if the game is running forward. + */ + public boolean isRunningForward() + { + return newPhase.ordinal() > oldPhase.ordinal(); + } + @Override public HandlerList getHandlers() { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 3e04367..e70236d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -70,8 +70,7 @@ public class GameBeginning extends ZLibComponent implements Listener @EventHandler(priority = EventPriority.LOWEST) public void onGameStarts(GamePhaseChangedEvent ev) { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; - if (ev.getOldPhase() != GamePhase.STARTING) return; // Only the first start + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; /* *** Grace period (damages disabled) *** */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index f14f381..c1fd065 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -201,8 +201,7 @@ public SidebarPlayerCache getSidebarPlayerCache(final UUID id) @EventHandler public void onGameStart(final GamePhaseChangedEvent ev) { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; - if (ev.getOldPhase() != GamePhase.STARTING) return; + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) { From 175fdace97cec4f9251c16d7d730d0f55b003077 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 04:17:16 +0100 Subject: [PATCH 24/91] Removed old files --- .../amaury/UHCReloaded/UHCReloaded.java | 10 -- .../old/commands/commands/UHRootCommand.java | 10 -- .../commands/uh/UHFeedAllCommand.java | 123 -------------- .../commands/commands/uh/UHFeedCommand.java | 133 --------------- .../commands/uh/UHHealAllCommand.java | 148 ----------------- .../commands/commands/uh/UHHealCommand.java | 151 ----------------- .../commands/commands/uh/UHKillCommand.java | 129 --------------- .../commands/uh/UHResurrectCommand.java | 129 --------------- .../commands/commands/uh/UHShiftCommand.java | 99 ------------ .../commands/commands/uh/UHStartCommand.java | 153 ------------------ .../integration/UHProtocolLibIntegration.java | 60 ------- .../UHProtocolLibIntegrationWrapper.java | 109 ------------- .../old/listeners/GameListener.java | 61 ------- 13 files changed, 1315 deletions(-) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index d6b4384..3d71104 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -48,7 +48,6 @@ import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; -import eu.carrade.amaury.UHCReloaded.old.integration.UHProtocolLibIntegrationWrapper; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; import eu.carrade.amaury.UHCReloaded.old.misc.*; @@ -117,7 +116,6 @@ public class UHCReloaded extends ZPlugin implements Listener private UHWorldBorderIntegration wbintegration = null; private UHSpectatorPlusIntegration spintegration = null; private UHDynmapIntegration dynmapintegration = null; - private UHProtocolLibIntegrationWrapper protocollibintegrationwrapper = null; @Override @@ -688,14 +686,6 @@ public UHDynmapIntegration getDynmapIntegration() return dynmapintegration; } - /** - * Returns a wrapper of the representation of the ProtocolLib integration in the plugin. - */ - public UHProtocolLibIntegrationWrapper getProtocolLibIntegrationWrapper() - { - return protocollibintegrationwrapper; - } - /** * Returns the plugin's instance. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index 6f20040..b28a87c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -50,17 +50,7 @@ public UHRootCommand(UHCReloaded plugin) { p = plugin; - // Game - registerSubCommand(new UHStartCommand(p)); - registerSubCommand(new UHShiftCommand(p)); - // Bugs - registerSubCommand(new UHHealCommand(p)); - registerSubCommand(new UHHealAllCommand(p)); - registerSubCommand(new UHFeedCommand(p)); - registerSubCommand(new UHFeedAllCommand(p)); - registerSubCommand(new UHKillCommand(p)); - registerSubCommand(new UHResurrectCommand(p)); registerSubCommand(new UHTPBackCommand(p)); registerSubCommand(new UHTPSpawnCommand(p)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java deleted file mode 100644 index 336f0eb..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedAllCommand.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; -/** - * This command feeds all player. - * - * Usage: /uh feed <player> [foodLevel=20] [saturation=20] - */ -@Command (name = "feedall") -public class UHFeedAllCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHFeedAllCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - int foodLevel = 20; - float saturation = 20f; - - if (args.length > 0) // /uh feedall <foodLevel> - { - try - { - foodLevel = Integer.valueOf(args[0]); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); - return; - } - - if (args.length > 1) // /uh feedall <foodLevel> <saturation> - { - try - { - // The saturation value cannot be more than the food level. - saturation = Math.min(foodLevel, Float.valueOf(args[1])); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); - return; - } - } - } - - for (Player player : p.getServer().getOnlinePlayers()) - { - player.setFoodLevel(foodLevel); - player.setSaturation(saturation); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh feedall [foodPoints=20] [saturation=max] {ci}: feeds all players.")); - } - - @Override - public String getCategory() - { - return Category.BUGS.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java deleted file mode 100644 index 9d4c8a6..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFeedCommand.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -/** - * This command feeds a player. - * - * Usage: /uh feed <player> [foodLevel=20] [saturation=20] - */ -@Command (name = "feed") -public class UHFeedCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHFeedCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length < 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - final Player target = p.getServer().getPlayer(args[0]); - if (target == null || !target.isOnline()) - { - sender.sendMessage(I.t("{ce}This player is offline.")); - return; - } - - int foodLevel = 20; - float saturation = 20f; - - if (args.length > 1) // /uh feed <player> <foodLevel> - { - try - { - foodLevel = Integer.valueOf(args[1]); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); - return; - } - - if (args.length > 2) // /uh feed <player> <foodLevel> <saturation> - { - try - { - // The saturation value cannot be more than the food level. - saturation = Math.min(foodLevel, Float.valueOf(args[2])); - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); - return; - } - } - } - - target.setFoodLevel(foodLevel); - target.setSaturation(saturation); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh feed <player> [foodPoints=20] [saturation=max] {ci}: feeds a player.")); - } - - @Override - public String getCategory() - { - return Category.BUGS.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java deleted file mode 100644 index b24ce4f..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealAllCommand.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -/** - * This command feeds a player. - * <p> - * Usage: /uh feed <player> [foodLevel=20] [saturation=20] - */ -@Command (name = "healall") -public class UHHealAllCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHHealAllCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - double diffHealth = 0D; - double health = 0D; - boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode - - - if (args.length == 0) // /uh healall : full life for all players. - { - diffHealth = 20D; - } - else // /uh heal <player> <hearts> - { - try - { - if (args[0].startsWith("+")) - { - diffHealth = Double.parseDouble(args[0].substring(1)); - add = true; - } - else if (args[0].startsWith("-")) - { - diffHealth = -1 * Double.parseDouble(args[0].substring(1)); - add = true; - } - else - { - diffHealth = Double.parseDouble(args[0]); - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); - return; - } - } - - if ((!add && diffHealth <= 0) || diffHealth <= -20) - { - sender.sendMessage(I.t("{ce}Serial killer!")); - return; - } - - - for (final Player player : p.getServer().getOnlinePlayers()) - { - health = !add ? diffHealth : player.getHealth() + diffHealth; - - if (health <= 0D) - { - sender.sendMessage(I.t("{ce}The health of {0} was not updated to avoid a kill.", player.getName())); - continue; - } - else if (health > 20D) - { - health = 20D; - } - - player.setHealth(health); - UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh healall [half-hearts=20|±diff] {ci}: heals all players instead of only one.")); - } - - @Override - public String getCategory() - { - return Category.BUGS.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java deleted file mode 100644 index ab9bf98..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHHealCommand.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -/** - * This command heals a player. - * - * Usage: /uh heal <player> <half-hearts> - */ -@Command (name = "heal") -public class UHHealCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHHealCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length < 1 || args.length > 2) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - Player player = p.getServer().getPlayer(args[0]); - if (player == null || !player.isOnline()) - { - sender.sendMessage(I.t("{ce}This player is offline.")); - return; - } - - double health; - boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode - - if (args.length == 1) - { // /uh heal <player> : full life for player. - health = 20D; - } - else - { // /uh heal <player> <hearts> - double diffHealth; - - try - { - if (args[1].startsWith("+")) - { - diffHealth = Double.parseDouble(args[1].substring(1)); - add = true; - } - else if (args[1].startsWith("-")) - { - diffHealth = -1 * Double.parseDouble(args[1].substring(1)); - add = true; - } - else - { - diffHealth = Double.parseDouble(args[1]); - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); - return; - } - - health = !add ? diffHealth : player.getHealth() + diffHealth; - - if (health <= 0D) - { - sender.sendMessage(I.t("{ce}You can't kill a player with this command, to avoid typo fails.")); - return; - } - else if (health > 20D) - { - health = 20D; - } - } - - player.setHealth(health); - UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh heal <player> [half-hearts=20|±diff] {ci}: heals a player to the number of half-hearts provided (default 20).")); - } - - @Override - public String getCategory() - { - return Category.BUGS.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java deleted file mode 100644 index 3976de7..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHKillCommand.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * This command marks a player as dead, even if he is offline. - * - * If the player is online, this has the same effect as {@code /kill}. - * - * Usage: /uh kill <player> - */ -@Command (name = "kill") -public class UHKillCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHKillCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length < 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - OfflinePlayer player = p.getServer().getOfflinePlayer(args[0]); - - if (player == null) - { - sender.sendMessage(I.t("{ce}This player was never seen on this server.")); - return; - } - - if (!p.getGameManager().isPlayerDead(player.getUniqueId())) - { - if (player.isOnline()) - { - ((Player) player).setHealth(0); - } - else - { - p.getGameManager().addDead(player.getUniqueId()); - } - - sender.sendMessage(I.t("{cs}The player {0} is now marked as dead.", player.getName())); - } - else - { - sender.sendMessage(I.t("{ce}{0} is not an alive player.", player.getName())); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 1) - { - List<String> suggestions = new ArrayList<>(); - - for (OfflinePlayer player : p.getGameManager().getAlivePlayers()) - { - suggestions.add(player.getName()); - } - - return CommandUtils.getAutocompleteSuggestions(args[0], suggestions); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh kill <player> {ci}: mark a player as dead, even if he is offline.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java deleted file mode 100644 index 4e57472..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHResurrectCommand.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * This command resurrects a player. - * - * Usage: /uh resurrect <player> - */ -@Command (name = "resurrect") -public class UHResurrectCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHResurrectCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length != 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - boolean success = p.getGameManager().resurrect(args[0]); - - Player player = p.getServer().getPlayer(args[0]); - if (player == null || !player.isOnline()) - { - if (!success) // Player does not exists or is nod dead. - { - sender.sendMessage(I.t("{ce}This player is not playing or dead!")); - } - else // Resurrected - { - sender.sendMessage(I.t("{cs}Because {0} is offline, he will be resurrected when he logins. If he was, he is no longer banned.", args[0])); - } - } - else - { - if (!success) // The player is not dead - { - /// Trying to resurrect an alive player - sender.sendMessage(I.t("{ce}{0} is not dead!", args[0])); - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 1) - { - List<String> suggestions = new ArrayList<>(); - - // TODO can be optimized - for (String playerName : p.getGameManager().getPlayers()) - { - OfflinePlayer player = p.getServer().getOfflinePlayer(playerName); - if (player != null && p.getGameManager().isPlayerDead(player.getUniqueId())) - { - suggestions.add(playerName); - } - } - - return CommandUtils.getAutocompleteSuggestions(args[0], suggestions); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh resurrect <player> {ci}: resurrects a player.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java deleted file mode 100644 index 3c850a0..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHShiftCommand.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -@Command (name = "shift") -public class UHShiftCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHShiftCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (p.getGameManager().isGameRunning()) - { - if (sender instanceof Player) - { - p.getGameManager().shiftEpisode(sender.getName()); - } - else - { - p.getGameManager().shiftEpisode(I.t("the console")); - } - } - else - { - sender.sendMessage(I.t("{ce}You can't shift the current episode because the game is not started.")); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh shift {ci}: shifts an episode.")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java deleted file mode 100644 index 9c78e44..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHStartCommand.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * This command starts the game. - * - * Usage: /uh start [slow:true] [ignoreTeams:true] - */ -@Command (name = "start") -public class UHStartCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHStartCommand(UHCReloaded plugin) - { - p = plugin; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 1 && args[0].equalsIgnoreCase("help")) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - else if (p.getGameManager().isSlowStartInProgress()) - { - p.getGameManager().finalizeStartSlow(sender); - return; - } - - final Map<String, String> defaultTags = new HashMap<>(); - defaultTags.put("slow", "false"); - defaultTags.put("ignoreTeams", "false"); - - final Map<String, String> tags = CommandUtils.getTagsInArgs(args, defaultTags); - - try - { - p.getGameManager().start(sender, UHUtils.stringToBoolean(tags.get("slow")), UHUtils.stringToBoolean(tags.get("ignoreTeams"))); - } - catch (IllegalStateException e) - { - sender.sendMessage(I.t("{ce}The game is already started! Reload or restart the server to restart the game.")); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - final List<String> suggestions = new ArrayList<>(); - - suggestions.add("slow:true"); - suggestions.add("ignoreTeams:true"); - - if (args.length == 1) - suggestions.add("help"); - - return CommandUtils.getAutocompleteSuggestions(args[args.length - 1], suggestions); - } - - @Override - public List<String> help(CommandSender sender) - { - return Arrays.asList( - I.t("{aqua}------ Beginning of the game ------"), - I.t("{cc}/uh start {ci}: starts the game. Period."), - I.t("{aqua}Startup options"), - I.t("{ci}You can add some tags to change the way the game is started, just append them to the command with spaces."), - I.t("{cc}slow:true {ci}: launches the game slowly, in two steps (teleportation then beginning of the game), for smaller servers."), - I.t("{cc}ignoreTeams:true {ci}: even with teams, teleports the players like in a solo game (only one player per spawn point, not a spawn point per team).") - ); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh start {ci}: launches the game. See /uh start help for options (slow and ignoreTeams).")); - } - - @Override - public String getCategory() - { - return Category.GAME.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java deleted file mode 100644 index 506e02b..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegration.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.integration; - -import com.comphenix.protocol.ProtocolLibrary; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts.PacketsListener; -import fr.zcraft.zlib.tools.PluginLogger; - - -public class UHProtocolLibIntegration -{ - public UHProtocolLibIntegration(UHCReloaded p) - { - PacketsListener packetsListener = new PacketsListener(); - - if (UHConfig.HARDCORE_HEARTS.DISPLAY.get()) - { - ProtocolLibrary.getProtocolManager().addPacketListener(packetsListener); - } - - if (UHConfig.AUTO_RESPAWN.DO.get()) - { - p.getServer().getPluginManager().registerEvents(packetsListener, p); - } - - PluginLogger.info("Successfully hooked into ProtocolLib."); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java deleted file mode 100644 index 2a86227..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHProtocolLibIntegrationWrapper.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.integration; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.tools.PluginLogger; -import org.bukkit.Bukkit; -import org.bukkit.plugin.Plugin; - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - - -public class UHProtocolLibIntegrationWrapper -{ - - private UHCReloaded p = null; - private UHProtocolLibIntegration integration = null; - - public UHProtocolLibIntegrationWrapper(UHCReloaded p) - { - this.p = p; - - // Needed to avoid a NoClassDefFoundError. - // I don't like this way of doing this, but else, the plugin will not load without ProtocolLib. - - Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("ProtocolLib"); - if (pl != null && pl.isEnabled()) - { - try - { - integration = new UHProtocolLibIntegration(p); - } - catch (NoClassDefFoundError e) - { - PluginLogger.error("ProtocolLib is present but cannot be loaded (outdated?), so the integration was disabled.", e); - } - } - else - { - PluginLogger.warning("ProtocolLib is not present, so the integration was disabled."); - } - } - - /** - * Returns true if ProtocolLib is installed and integrated into the plugin. - */ - public boolean isProtocolLibIntegrationEnabled() - { - return (this.integration != null); - } - - /** - * Checks if there are some enabled option which require ProtocolLib. - * - * @return A list of enabled options which requires ProtocolLib, or null - * if there isn't any enabled option that requires ProtocolLib. - */ - public List<String> isProtocolLibNeeded() - { - final List<String> enabledOptions = Stream.of(UHConfig.HARDCORE_HEARTS.DISPLAY, UHConfig.AUTO_RESPAWN.DO) - .filter(ConfigurationItem::get) - .map(ConfigurationItem::getFieldName) - .collect(Collectors.toList()); - - return enabledOptions.size() != 0 ? enabledOptions : null; - } - - /** - * Returns the wrapped integration. - */ - public UHProtocolLibIntegration getIntegration() - { - return integration; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 8265ba2..51dcc4e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -44,9 +44,7 @@ import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.RawMessage; import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.*; import org.bukkit.entity.Player; @@ -62,9 +60,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import java.net.URISyntaxException; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -234,15 +230,6 @@ public void onPlayerDeath(final PlayerDeathEvent ev) // p.getServer().getPluginManager().callEvent(new UHGameEndsEvent(p.getGameManager().getAliveTeams().iterator().next())); } - // Notifies the player about the possibility of respawn if hardcore hearts are enabled - if (UHConfig.HARDCORE_HEARTS.DISPLAY.get() && p.getProtocolLibIntegrationWrapper().isProtocolLibIntegrationEnabled() && UHConfig.HARDCORE_HEARTS.RESPAWN_MESSAGE.get()) - { - RunTask.later(() -> { - /// A message displayed to the players under the death screen, about the respawn possibility even if the death screen says the opposite (in hardcore mode) - ev.getEntity().sendMessage(I.t("{darkpurple}{obfuscated}----{lightpurple}{italic} YOU CAN RESPAWN{lightpurple}, just click {italic}Respawn {lightpurple}on the next screen.")); - }, 2L); - } - // Disables the team-chat-lock if needed // if (UHConfig.TEAMS_OPTIONS.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) // { @@ -355,54 +342,6 @@ public void onPlayerJoin(final PlayerJoinEvent ev) // The display name is reset when the player logs off. // p.getTeamManager().colorizePlayer(ev.getPlayer()); - if (!p.getGameManager().isGameStarted() && ev.getPlayer().hasPermission("uh.*")) - { - // A warning to the administrators if ProtocolLib is not present. - if (!p.getProtocolLibIntegrationWrapper().isProtocolLibIntegrationEnabled()) - { - final List<String> enabledOptionsWithProtocolLibNeeded = p.getProtocolLibIntegrationWrapper().isProtocolLibNeeded(); - - if (enabledOptionsWithProtocolLibNeeded != null) - { - ev.getPlayer().sendMessage(I.t("{darkred}[UHC] {ce}ProtocolLib is needed but not installed!")); - ev.getPlayer().sendMessage(I.t("{gray}The following options require the presence of ProtocolLib:")); - - for (String option : enabledOptionsWithProtocolLibNeeded) - { - /// An option requiring ProtocolLib, in the “missing PLib” message. {0} = option path. - ev.getPlayer().sendMessage(I.tc("protocollib_option", "{darkgray} - {gray}{0}", option)); - } - - String pLibDownloadURL; - if (p.getServer().getBukkitVersion().contains("1.7")) // 1.7.9 or 1.7.10 - { - pLibDownloadURL = "http://dev.bukkit.org/bukkit-plugins/protocollib/"; - } - else // 1.8+ - { - pLibDownloadURL = "http://www.spigotmc.org/resources/protocollib.1997/"; - } - - try - { - RawMessage.send(ev.getPlayer(), - new RawText(I.t("{gray}You can download ProtocolLib by clicking here.")) - .uri(pLibDownloadURL) - .hover(ChatColor.GRAY + pLibDownloadURL) - .build() - ); - } - catch (URISyntaxException e) - { - e.printStackTrace(); - - /// {0} = ProtocolLib download URL for the current Minecraft version. - ev.getPlayer().sendMessage(I.t("{gray}ProtocolLib is available here: {0}", pLibDownloadURL)); - } - } - } - } - // If the player needs to be resurrected... if (p.getGameManager().isDeadPlayersToBeResurrected(ev.getPlayer())) { From 7b71bee86c732b2a91b06bfeec50ecc487ae1d86 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 16:04:51 +0100 Subject: [PATCH 25/91] Teleportation commands --- .../amaury/UHCReloaded/UHCReloaded.java | 34 +-- .../UHCReloaded/core/ModuleWrapper.java | 61 +++- .../modules/core/modules/ModulesCommand.java | 62 +++- .../teleportation/TeleportationModule.java | 88 ++++++ .../teleportation/commands/TPBackCommand.java | 102 +++++++ .../commands/TPSpawnCommand.java | 113 +++++++ .../commands/TPSpectatorsCommand.java | 103 +++++++ .../teleportation/commands/TPTeamCommand.java | 116 ++++++++ .../commands/WorldBasedCommand.java | 59 ++++ .../old/commands/commands/UHRootCommand.java | 5 - .../commands/commands/uh/UHTPBackCommand.java | 137 --------- .../old/commands/commands/uh/UHTPCommand.java | 279 ------------------ .../commands/uh/UHTPSpawnCommand.java | 150 ---------- src/main/resources/config.yml | 1 + 14 files changed, 678 insertions(+), 632 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 3d71104..9358862 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -57,7 +57,6 @@ import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.Commands; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.i18n.I18n; @@ -236,38 +235,7 @@ public final void registerModules(final Class<? extends UHModule>... modules) */ private void registerModule(final Class<? extends UHModule> module, final boolean enableAtStartup) { - final String description; - final ModuleInfo.ModuleLoadTime priority; - final boolean internal; - - final Class<? extends ConfigurationInstance> moduleConfiguration; - final String settingsFileName; - - final String[] dependencies; - - final ModuleInfo info = module.getAnnotation(ModuleInfo.class); - - if (info == null) - { - description = ""; - internal = false; - priority = ModuleInfo.ModuleLoadTime.POST_WORLD; - moduleConfiguration = null; - settingsFileName = null; - dependencies = new String[] {}; - } - else - { - description = info.description(); - internal = info.internal(); - priority = info.when(); - moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); - settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); - dependencies = info.depends(); - } - - this.modules.put(module, new ModuleWrapper( - description, internal, enableAtStartup, priority, module, moduleConfiguration, settingsFileName, dependencies)); + this.modules.put(module, new ModuleWrapper(module)); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 01ed1a2..6e0e214 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -60,30 +60,43 @@ public class ModuleWrapper private String[] dependencies; private final boolean internal; + private final boolean canBeDisabled; + /** + * TODO reimplement properly activated modules + */ + @Deprecated private boolean enabledAtStartup; private UHModule instance = null; - public ModuleWrapper( - final String description, - final boolean internal, - final boolean enabledAtStartup, - final ModuleInfo.ModuleLoadTime when, - final Class<? extends UHModule> moduleClass, - final Class<? extends ConfigurationInstance> moduleConfiguration, - final String settingsFileName, - final String[] dependencies) + public ModuleWrapper(final Class<? extends UHModule> moduleClass) { this.name = computeModuleName(moduleClass); - this.description = description; - this.internal = internal; - this.enabledAtStartup = enabledAtStartup; - this.when = when; this.moduleClass = moduleClass; - this.moduleConfiguration = moduleConfiguration; - this.settingsFileName = settingsFileName; - this.dependencies = dependencies; + + final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); + + if (info == null) + { + description = ""; + internal = false; + canBeDisabled = true; + when = ModuleInfo.ModuleLoadTime.POST_WORLD; + moduleConfiguration = null; + settingsFileName = null; + dependencies = new String[] {}; + } + else + { + description = info.description(); + internal = info.internal(); + canBeDisabled = info.can_be_disabled(); + when = info.when(); + moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); + settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); + dependencies = info.depends(); + } loadConfiguration(); } @@ -165,6 +178,14 @@ public String getDescription() return description != null && !description.isEmpty() ? description : null; } + /** + * @return A list of external plugins this module depends on. + */ + public String[] getDependencies() + { + return dependencies; + } + /** * @return When this module should be loaded. */ @@ -242,6 +263,14 @@ public boolean isInternal() return internal; } + /** + * @return {@code true} if this module can be disabled at runtime. + */ + public boolean canBeDisabled() + { + return canBeDisabled; + } + /** * @return {@code true} if this module, according to the configuration file, should be loaded at startup. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java index 2786599..c7ae6ae 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -36,10 +36,17 @@ import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.components.rawtext.RawTextPart; +import org.bukkit.ChatColor; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Stream; @CommandInfo (name = "modules", usageParameters = "[list|enable|disable]", aliases = {"module"}) @@ -63,24 +70,55 @@ protected void run() throws CommandException modules.addAll(UHCReloaded.get().getModules()); - success(I.tn("{0} module registered", "{0} modules registered", modules.size())); + success(I.tn("{0} module registered {gray}(hover for details)", "{0} modules registered {gray}(hover for details)", modules.size())); modules.forEach(module -> { + final List<String> commands = new ArrayList<>(); + if (module.isEnabled()) { - info(I.t( - "{green} • {white}{0} (enabled - {1})", - module.getName(), - module.getWhen() - )); + final List<Class<? extends Command>> commandsClasses = module.get().getCommands(); + if (commandsClasses != null) + { + commandsClasses.forEach(clazz -> { + final Command cmd = Commands.getCommandInfo(clazz); + if (cmd != null) commands.add(cmd.getUsageString()); + }); + } } - else + + final RawTextPart<?> tooltip = new RawText(); + + tooltip.then(module.getName()).style(ChatColor.BOLD).style(module.isEnabled() ? ChatColor.GREEN : ChatColor.RED).then("\n"); + tooltip.then(module.isEnabled() ? I.t("Enabled") : I.t("Disabled")).color(ChatColor.GRAY).then("\n\n"); + tooltip.then(module.getDescription()).style(ChatColor.WHITE).then("\n\n"); + tooltip.then(I.t("Load time")).style(ChatColor.BLUE).then("\n").then(module.getWhen().toString()).style(ChatColor.WHITE); + + if (!commands.isEmpty()) + { + tooltip.then("\n\n").then(I.t("Provided commands")).style(ChatColor.BLUE); + commands.forEach(command -> tooltip.then("\n- ").style(ChatColor.GRAY).then(command).color(ChatColor.WHITE)); + } + + if (module.getDependencies().length != 0) { - info(I.t( - "{red} • {white}{0} (disabled - {1})", - module.getName(), - module.getWhen() - )); + tooltip.then("\n\n").then(I.t("External dependencies")).style(ChatColor.BLUE); + Stream.of(module.getDependencies()).forEach(dep -> tooltip.then("\n- ").style(ChatColor.GRAY).then(dep).color(ChatColor.WHITE)); } + + if (module.isInternal()) + { + tooltip.then("\n\n").then(I.t("Internal module")).style(ChatColor.DARK_GRAY); + } + if (!module.canBeDisabled()) + { + tooltip.then(module.isInternal() ? " - " : "\n\n").color(ChatColor.DARK_GRAY).then(I.t("Cannot be disabled")).color(ChatColor.DARK_GRAY); + } + + send(new RawText().hover(tooltip) + .then("• ").color(module.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + .then(module.getName()).color(ChatColor.WHITE) + .build() + ); }); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java new file mode 100644 index 0000000..c11b2a6 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java @@ -0,0 +1,88 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPBackCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpawnCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpectatorsCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPTeamCommand; +import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.event.EventHandler; + +import java.util.*; + + +@ModuleInfo ( + name = "Teleportation Commands", + description = "Provides commands to teleport to spawn, death location, or groups of players" +) +public class TeleportationModule extends UHModule +{ + private final Map<UUID, Location> deathLocations = new HashMap<>(); + + @Override + public List<Class<? extends Command>> getCommands() + { + return Arrays.asList( + TPBackCommand.class, + TPSpawnCommand.class, + TPTeamCommand.class, + TPSpectatorsCommand.class + ); + } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (ev.getPlayer().isOnline()) + { + deathLocations.put(ev.getPlayer().getUniqueId(), ev.getPlayer().getPlayer().getLocation()); + } + } + + public boolean hasDeathLocation(final OfflinePlayer player) + { + return deathLocations.containsKey(player.getUniqueId()); + } + + public Location getDeathLocation(final OfflinePlayer player) + { + return deathLocations.get(player.getUniqueId()).clone(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java new file mode 100644 index 0000000..bdc23ca --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java @@ -0,0 +1,102 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; + +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.TeleportationModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +@CommandInfo (name = "tp-back", usageParameters = "<player> [force]",aliases = {"tpback", "tpb"}) +public class TPBackCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final Player player = getPlayerParameter(0); + final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); + + if (!UR.module(TeleportationModule.class).hasDeathLocation(player)) + { + error(I.t("{ce}No death location available for the player {0}.", player.getName())); + } + + final Location deathLocation = UR.module(TeleportationModule.class).getDeathLocation(player); + + if (force) + { + UHUtils.safeTP(player, deathLocation, true); + success(I.t("{cs}The player {0} was teleported back.", player.getName())); + } + else if (UHUtils.safeTP(player, deathLocation)) + { + success(I.t("{cs}The player {0} was teleported back.", player.getName())); + } + else + { + warning(I.t("{ce}The player {0} was NOT teleported back because no safe spot was found.", player.getName())); + warning(I.t("{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this point.", player.getName())); + } + } + + @Override + protected List<String> complete() + { + if (args.length == 1) + { + final TeleportationModule tm = UR.module(TeleportationModule.class); + + return getMatchingPlayerNames( + Bukkit.getOnlinePlayers().stream().filter(tm::hasDeathLocation).collect(Collectors.toList()), + args[0] + ); + } + + else if (args.length == 2) + { + return getMatchingSubset(args[1].toLowerCase(), "force"); + } + + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java new file mode 100644 index 0000000..8ed336d --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java @@ -0,0 +1,113 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +@CommandInfo (name = "tp-spawn", usageParameters = "<player> [force]", aliases = {"tpspawn"}) +public class TPSpawnCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final Teleporter teleporter = UR.module(GameModule.class).getTeleporter(); + + if (teleporter == null) + { + error(I.t("{ce}The spawn points are not already assigned to the player, because the game is not started.")); + return; + } + + final Player player = getPlayerParameter(0); + final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); + final Location spawnLocation = teleporter.getSpawnForPlayer(player.getUniqueId()); + + if (spawnLocation == null) + { + error(I.t("{ce}No spawn location available for the player {0}.", player.getName())); + return; + } + + if (force) + { + teleporter.teleportPlayer(player.getUniqueId(), true); + success(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); + } + else if (UHUtils.safeTP(player, spawnLocation)) + { + success(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); + } + else + { + warning(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", args[0])); + warning(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", args[0])); + } + } + + @Override + protected List<String> complete() + { + final Teleporter teleporter = UR.module(GameModule.class).getTeleporter(); + + if (teleporter == null) return null; + + else if (args.length == 1) + { + return getMatchingPlayerNames( + Bukkit.getOnlinePlayers().stream().filter(player -> teleporter.hasSpawnForPlayer(player.getUniqueId())).collect(Collectors.toList()), + args[0] + ); + } + + else if (args.length == 2) + { + return getMatchingSubset(args[1].toLowerCase(), "force"); + } + + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java new file mode 100644 index 0000000..5e6d9c9 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java @@ -0,0 +1,103 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + +import java.util.List; +import java.util.Objects; + +@CommandInfo (name = "tp-spectators", usageParameters = "<x> <y> <z> | <target>", aliases = {"tpspectators", "tp-specs", "tpspecs"}) +public class TPSpectatorsCommand extends WorldBasedCommand +{ + @Override + protected void run() throws CommandException + { + final SpectatorsModule spectators = UR.module(SpectatorsModule.class); + + // /uh tp-spectators <x> <y> <z> + if (args.length == 3) + { + try + { + final World world = getTargetWorld(); + + final double x = Integer.parseInt(args[0]) + 0.5; + final double y = Integer.parseInt(args[1]) + 0.5; + final double z = Integer.parseInt(args[2]) + 0.5; + + spectators.getSpectators().stream() + .map(Bukkit::getPlayer).filter(Objects::nonNull) + .forEach(spectator -> spectator.teleport(new Location(world, x, y, z), TeleportCause.PLUGIN)); + + /// {0}: world name. {1-3}: x, y, z. + success(I.t("All spectators were teleported to ({0} ; {1} ; {2} ; {3}).", world.getName(), x, y, z)); + } + catch (final NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}The coordinates must be three valid numbers.")); + } + } + + // /uh tp-spectators <target> + else if (args.length == 1) + { + final Player target = getPlayerParameter(0); + + spectators.getSpectators().stream() + .map(Bukkit::getPlayer).filter(Objects::nonNull) + .forEach(spectator -> spectator.teleport(target, TeleportCause.PLUGIN)); + + success(I.t("All spectators were teleported to the player {0}.", target.getName())); + } + + else throwInvalidArgument(I.t("You must specify either three coordinates or a player name.")); + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingPlayerNames(args[0]); + else return null; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java new file mode 100644 index 0000000..11d2dc5 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java @@ -0,0 +1,116 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; + +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.texts.TextUtils; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.stream.Collectors; + +@CommandInfo (name = "tp-team", usageParameters = "<x> <y> <z> \"<team name>\" | <target> \"<team name>\"", aliases = {"tpteam", "tpt"}) +public class TPTeamCommand extends WorldBasedCommand +{ + @Override + protected void run() throws CommandException + { + final String[] qargs = TextUtils.extractArgsWithQuotes(args, 0); + + // possibly /uh tp-team <x> <y> <z> "<team ...>" + if (qargs.length == 4) + { + final ZTeam team = ZTeams.get().getTeamByName(qargs[3]); + + // ok, the team exists. + if (team != null) + { + try + { + final World world = getTargetWorld(); + + final double x = Integer.parseInt(args[0]) + 0.5; + final double y = Integer.parseInt(args[1]) + 0.5; + final double z = Integer.parseInt(args[2]) + 0.5; + + team.teleportTo(new Location(world, x, y, z)); + + /// {1}: players names, comma-separated. {2}: world name. {3-5}: x, y, z. + success(I.t( + "The players in the team {0} ({1}) were teleported to ({2} ; {3} ; {4} ; {5}).", + team.getName(), + String.join(", ", team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), + world.getName(), x, y, z + )); + + return; + } + catch (NumberFormatException e) + { + throwInvalidArgument(I.t("{ce}The coordinates must be three valid numbers.")); + } + } + } + + // /uh tp team <target> "<team ...>" + if (qargs.length == 2) + { + final ZTeam team = ZTeams.get().getTeamByName(qargs[1]); + + if (team == null) + { + throwInvalidArgument(I.t("{ce}This team is not registered.")); + } + else + { + final Player player = getPlayerParameter(0); + team.teleportTo(player.getLocation()); + + /// {1}: players names, comma-separated. + success(I.t( + "The players in the team {0} ({1}) were teleported to the player {2}.", + team.getName(), + String.join(", ", team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), + player.getName() + )); + } + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java new file mode 100644 index 0000000..f635e6b --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java @@ -0,0 +1,59 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; + +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.World; +import org.bukkit.command.BlockCommandSender; +import org.bukkit.entity.Player; + +public abstract class WorldBasedCommand extends Command +{ + protected World getTargetWorld() + { + if (sender instanceof Player) + { + return ((Player) sender).getWorld(); + } + else if (sender instanceof BlockCommandSender) + { + return ((BlockCommandSender) sender).getBlock().getWorld(); + } + else + { + return UR.get().getWorld(World.Environment.NORMAL); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java index b28a87c..719ca40 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java @@ -50,14 +50,9 @@ public UHRootCommand(UHCReloaded plugin) { p = plugin; - // Bugs - registerSubCommand(new UHTPBackCommand(p)); - registerSubCommand(new UHTPSpawnCommand(p)); - // Misc registerSubCommand(new UHFinishCommand(p)); registerSubCommand(new UHFreezeCommand(p)); - registerSubCommand(new UHTPCommand(p)); registerSubCommand(new UHInfosCommand(p)); registerSubCommand(new UHRulesCommand(p)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java deleted file mode 100644 index 58a03b1..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPBackCommand.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Command (name = "tpback") -public class UHTPBackCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTPBackCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length < 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - Player player = p.getServer().getPlayer(args[0]); - if (player == null || !player.isOnline()) - { - sender.sendMessage(I.t("{ce}The player {0} is not online.", args[0])); - return; - } - else if (!p.getGameManager().hasDeathLocation(player)) - { - sender.sendMessage(I.t("{ce}No death location available for the player {0}.", args[0])); - return; - } - - - Location deathLocation = p.getGameManager().getDeathLocation(player); - - if (args.length >= 2 && args[1].equalsIgnoreCase("force")) - { - UHUtils.safeTP(player, deathLocation, true); - sender.sendMessage(I.t("{cs}The player {0} was teleported back.", args[0])); - p.getGameManager().removeDeathLocation(player); - } - else if (UHUtils.safeTP(player, deathLocation)) - { - sender.sendMessage(I.t("{cs}The player {0} was teleported back.", args[0])); - p.getGameManager().removeDeathLocation(player); - } - else - { - sender.sendMessage(I.t("{ce}The player {0} was NOT teleported back because no safe spot was found.", args[0])); - sender.sendMessage(I.t("{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this point.", args[0])); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (args.length == 1) - { - List<String> suggestions = new ArrayList<>(); - - for (Player player : p.getServer().getOnlinePlayers()) - { - if (p.getGameManager().hasDeathLocation(player)) - { - suggestions.add(player.getName()); - } - } - - return CommandUtils.getAutocompleteSuggestions(args[0], suggestions); - } - - else if (args.length == 2) - { - return CommandUtils.getAutocompleteSuggestions(args[1], Collections.singletonList("force")); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh tpback <player> [force] {ci}: safely teleports back a player to his death location.")); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java deleted file mode 100644 index d8d62ae..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPCommand.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * This command teleports a team or the spectators to a given location. - * - * Usage: /uh tp team <x> <y> <z> <team name ...> - * Usage: /uh tp team <target> <team name...> - * Usage: /uh tp spectators <x> <y> <z> - * Usage: /uh tp spectators <target> - */ -@Command (name = "tp") -public class UHTPCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHTPCommand(UHCReloaded plugin) - { - this.p = plugin; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // No action provided: doc - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - else - { - String subcommand = args[0]; - - World targetWorld; - if (sender instanceof Player) - { - targetWorld = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { - targetWorld = ((BlockCommandSender) sender).getBlock().getWorld(); - } - else - { - targetWorld = p.getServer().getWorlds().get(0); - } - - if (subcommand.equalsIgnoreCase("team")) - { - boolean mayBeNaNError = false; - - // possibly /uh tp team <x> <y> <z> <team ...> - if (args.length >= 6) - { - final ZTeam team = ZTeams.get().getTeamByName(UHUtils.getStringFromCommandArguments(args, 4)); - - // ok, the team exists. - if (team != null) - { - try - { - double x = Integer.parseInt(args[1]) + 0.5; - double y = Integer.parseInt(args[2]) + 0.5; - double z = Integer.parseInt(args[3]) + 0.5; - - team.teleportTo(new Location(targetWorld, x, y, z)); - - return; - } - catch (NumberFormatException e) - { - // It can be either another name for the team, starting by "<y> <z> the name" - // or a formatting error. - // The possibility of an error is saved. - mayBeNaNError = true; - } - } - } - - // /uh tp team <target> <team ...> - if (args.length >= 3) - { - final ZTeam team = ZTeams.get().getTeamByName(UHUtils.getStringFromCommandArguments(args, 2)); - - if (team == null) - { - if (mayBeNaNError) - { - sender.sendMessage(I.t("{ce}The coordinates must be three valid numbers.")); - } - else - { - sender.sendMessage(I.t("{ce}This team is not registered.")); - } - } - else - { - Player target = p.getServer().getPlayer(args[1]); - - if (target == null) - { - sender.sendMessage(I.t("{ce}{0} is offline!", args[1])); - } - else - { - team.teleportTo(target.getLocation()); - } - } - } - } - - else if (subcommand.equalsIgnoreCase("spectators")) - { - // /uh tp spectators <x> <y> <z> - if (args.length == 4) - { - try - { - double x = Integer.parseInt(args[1]) + 0.5; - double y = Integer.parseInt(args[2]) + 0.5; - double z = Integer.parseInt(args[3]) + 0.5; - - for (Player player : p.getServer().getOnlinePlayers()) - { - if (p.getGameManager().isPlayerDead(player)) - { - player.teleport(new Location(targetWorld, x, y, z), PlayerTeleportEvent.TeleportCause.PLUGIN); - } - } - } - catch (NumberFormatException e) - { - sender.sendMessage(I.t("{ce}The coordinates must be three valid numbers.")); - } - } - - // /uh tp spectators <target> - else if (args.length == 2) - { - Player target = p.getServer().getPlayer(args[1]); - - if (target == null) - { - sender.sendMessage(I.t("{ce}{0} is offline!", args[1])); - } - else - { - for (Player player : p.getServer().getOnlinePlayers()) - { - if (p.getGameManager().isPlayerDead(player)) - { - player.teleport(target.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - } - } - } - } - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - - if (args.length == 1) - { - return CommandUtils.getAutocompleteSuggestions( - args[0], - Arrays.asList("team", "spectators") - ); - } - - else if (args.length > 1 && args[0].equalsIgnoreCase("team")) - { - ArrayList<String> teamNames = new ArrayList<>(); - for (ZTeam team : ZTeams.get().getTeams()) - { - teamNames.add(team.getName()); - } - - // /uh tp team <x> <y> <z> <?>: autocompletion for team names – multiple words autocompletion - if (args.length >= 5) - { - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 4), teamNames, args.length - 5); - } - - // /uh tp team <target> <?>: autocompletion for team names – multiple words autocompletion - if (args.length >= 3) - { - try - { - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 2), teamNames, args.length - 3); - } - catch (IllegalArgumentException ignored) - { - // Temp workaround for an unknown bug. - } - } - } - - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return Arrays.asList( - I.t("{aqua}------ Teleportation commands ------"), - I.t("{cc}/uh tp team <x> <y> <z> | <target> <team ...> {ci}: teleports the team to the given location/target."), - I.t("{cc}/uh tp spectators <x> <y> <z> | <target> {ci}: teleports the spectators (aka non-alive players) to the given location/target.") - ); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh tp {ci}: teleports the spectators or an entire team. See /uh tp for details.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java deleted file mode 100644 index 098132f..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHTPSpawnCommand.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Command (name = "tpspawn") -public class UHTPSpawnCommand extends AbstractCommand -{ - private final UHCReloaded p; - - public UHTPSpawnCommand(UHCReloaded plugin) - { - p = plugin; - } - - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - // Spawns not assigned - if (p.getGameManager().getTeleporter() == null) - { - sender.sendMessage(I.t("{ce}The spawn points are not already assigned to the player, because the game is not started.")); - return; - } - - - if (args.length < 1) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - Player player = p.getServer().getPlayer(args[0]); - if (player == null || !player.isOnline()) - { - sender.sendMessage(I.t("{ce}The player {0} is not online.", args[0])); - return; - } - - Location spawnLocation = p.getGameManager().getTeleporter().getSpawnForPlayer(player.getUniqueId()); - - if (spawnLocation == null) - { - sender.sendMessage(I.t("{ce}No spawn location available for the player {0}.", args[0])); - return; - } - - - if (args.length >= 2 && args[1].equalsIgnoreCase("force")) - { - p.getGameManager().getTeleporter().teleportPlayer(player.getUniqueId(), true); - sender.sendMessage(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); - } - else if (UHUtils.safeTP(player, spawnLocation)) - { - sender.sendMessage(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); - } - else - { - sender.sendMessage(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", args[0])); - sender.sendMessage(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", args[0])); - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - // Spawns not attributed - if (p.getGameManager().getTeleporter() == null) - return null; - - - if (args.length == 1) - { - List<String> suggestions = new ArrayList<>(); - - for (Player player : p.getServer().getOnlinePlayers()) - { - if (p.getGameManager().getTeleporter().hasSpawnForPlayer(player.getUniqueId())) - { - suggestions.add(player.getName()); - } - } - - return CommandUtils.getAutocompleteSuggestions(args[0], suggestions); - } - - else if (args.length == 2) - { - return CommandUtils.getAutocompleteSuggestions(args[1], Collections.singletonList("force")); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh tpspawn <player> [force] {ci}: safely teleports back a player to his spawn location.")); - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 11617db..f7118ca 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -28,6 +28,7 @@ modules: "ingame-food": true "ingame-health": true "ingame-listHealth": true + "ingame-teleportation": true "ingame-episodes": true "ingame-deathAnnouncement": true "cosmetics-hardcoreHearts": true From a53bc114e118618d492798e8e6fd4e66fcab72b6 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 16:19:28 +0100 Subject: [PATCH 26/91] Kick on death module --- .../modules/ingame/kick/Config.java | 54 +++++++++++++++++ .../modules/ingame/kick/KickModule.java | 58 +++++++++++++++++++ src/main/resources/config.yml | 1 + 3 files changed, 113 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java new file mode 100644 index 0000000..01b3f5d --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java @@ -0,0 +1,54 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.kick; + +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.i18n.I; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<TimeDelta> DELAY = item("delay", new TimeDelta(30)); + static public final ConfigurationItem<String> MESSAGE = item("message", I.t("jayjay")); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java new file mode 100644 index 0000000..caefb84 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java @@ -0,0 +1,58 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.kick; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.event.EventHandler; + +@ModuleInfo ( + name = "Kick On Death", + description = "Kicks players on death after a delay.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class KickModule extends UHModule +{ + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (ev.getPlayer().isOnline()) + { + RunTask.later(() -> ev.getPlayer().getPlayer().kickPlayer(Config.MESSAGE.get()), Config.DELAY.get().getSeconds() * 20L); + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f7118ca..89df197 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -31,6 +31,7 @@ modules: "ingame-teleportation": true "ingame-episodes": true "ingame-deathAnnouncement": true +# "ingame-kick": false "cosmetics-hardcoreHearts": true "cosmetics-motd": true "other-playersLoader": true From f0b71e67ba2b0ccfc90b70dd221e85234ab8c3cc Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 16:58:53 +0100 Subject: [PATCH 27/91] Spectators are not always allowed. * NEW: added spectators filter on login with options to exclude all or unknown spectators. --- .../modules/core/spectators/Config.java | 53 ++++++++++++++++++ .../core/spectators/SpectatorsModule.java | 56 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java new file mode 100644 index 0000000..804a8b3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java @@ -0,0 +1,53 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.spectators; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> SPECTATORS_CAN_JOIN = item("spectators-can-join", true); + static public final ConfigurationItem<Boolean> UNKNOWN_SPECTATORS_CAN_JOIN = item("unknown-spectators-can-join", true); + static public final ConfigurationItem<Boolean> NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN = item("notify-on-unknown-spectators-trying-to-join", true); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index e9cd641..a6b0d27 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -44,11 +44,15 @@ import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.Commands; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; import java.util.*; @@ -57,6 +61,7 @@ name = "Spectators manager", description = "Handles non-playing players", when = ModuleInfo.ModuleLoadTime.POST_WORLD, + settings = Config.class, can_be_disabled = false ) public class SpectatorsModule extends UHModule @@ -69,6 +74,12 @@ public class SpectatorsModule extends UHModule */ private final Set<UUID> spectators = new HashSet<>(); + /** + * When external spectators are disallowed, a message is sent once to inform administrators + * how to accept them if they wish to. + */ + private final Set<UUID> broadcastedUnknownSpectators = new HashSet<>(); + @Override protected void onEnable() { @@ -192,6 +203,51 @@ public void onPlayerResurrects(final PlayerResurrectedEvent ev) removeSpectator(ev.getPlayer()); } + @EventHandler + public void onPlayerLogin(final PlayerLoginEvent ev) + { + final GameModule game = UR.module(GameModule.class); + + if (game.currentPhaseBefore(GamePhase.IN_GAME)) return; + + // TODO Permissions + if (ev.getPlayer().isOp()) + { + ev.allow(); + return; + } + + if (!Config.SPECTATORS_CAN_JOIN.get() && !game.isAlive(ev.getPlayer())) + { + ev.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, I.t("Spectators are not allowed for this game.")); + return; + } + + else if (!Config.UNKNOWN_SPECTATORS_CAN_JOIN.get() && !(game.isAlive(ev.getPlayer()) || isSpectator(ev.getPlayer()))) + { + ev.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, I.t("External spectators are not allowed for this game.")); + + if (Config.NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN.get() && broadcastedUnknownSpectators.add(ev.getPlayer().getUniqueId())) + { + final String command = Commands.getCommandInfo(SpectatorsCommand.class).build("add", ev.getPlayer().getName()); + + log().broadcastAdministrative( + new RawText(I.t("{gray}The unknown player {0} just tried to join. To allow him to spectate, execute {cc}{1} or click here.", ev.getPlayer().getName(), command)) + .hover(I.t("Click here to execute\n{0}", command)) + .command(command) + ); + } + + return; + } + + // Here the spectator is allowed. If it's new, we add it to the list. + if (!game.isAlive(ev.getPlayer()) && !isSpectator(ev.getPlayer())) + { + addSpectator(ev.getPlayer()); + } + } + @EventHandler public void onPlayerJoin(final PlayerJoinEvent ev) { From aa2d56dae47a0bde5af39891374ebf577369c1f9 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 11 Dec 2018 17:29:53 +0100 Subject: [PATCH 28/91] Hardcore module (may be useful). * NEW: added hardcore module to disable natural regeneration and update game difficulty. * NEW: Improved operations on all playing worlds. --- .../amaury/UHCReloaded/UHCReloaded.java | 7 +++ .../modules/core/game/GameModule.java | 3 + .../core/game/submanagers/GameBeginning.java | 4 +- .../modules/ingame/hardcore/Config.java | 53 ++++++++++++++++++ .../ingame/hardcore/HardcoreModule.java | 55 +++++++++++++++++++ src/main/resources/config.yml | 1 + 6 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 9358862..28828ee 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -414,6 +414,13 @@ public World getWorld(final World.Environment environment) } } + /** + * @return A stream containing all three playing worlds. + */ + public List<World> getWorlds() + { + return Arrays.asList(worldNormal, worldNether, worldTheEnd); + } @EventHandler (priority = EventPriority.LOWEST) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 738684a..1902456 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -756,6 +756,9 @@ public void onGameStarts(final GamePhaseChangedEvent ev) player.setExp(0L); player.setLevel(0); }); + + // Just in case... + UR.get().getWorlds().forEach(world -> world.setGameRuleValue("keepInventory", Boolean.FALSE.toString())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index e70236d..508f5b0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -220,8 +220,6 @@ public void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) private void setPVP(final boolean pvp) { - UR.get().getWorld(World.Environment.NORMAL).setPVP(pvp); - UR.get().getWorld(World.Environment.NETHER).setPVP(pvp); - UR.get().getWorld(World.Environment.THE_END).setPVP(pvp); + UR.get().getWorlds().forEach(world -> world.setPVP(pvp)); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java new file mode 100644 index 0000000..a95b3d6 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java @@ -0,0 +1,53 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.hardcore; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import org.bukkit.Difficulty; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> NATURAL_REGENERATION = item("natural-regeneration", false); + static public final ConfigurationItem<Difficulty> DIFFICULTY = item("difficulty", Difficulty.HARD); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java new file mode 100644 index 0000000..93bfdf7 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java @@ -0,0 +1,55 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.hardcore; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; + + +@ModuleInfo ( + name = "Hardcore mode", + description = "Disables health natural regeneration and sets correct difficulty in the game's worlds.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class HardcoreModule extends UHModule +{ + @Override + protected void onEnable() + { + UR.get().getWorlds().forEach(world -> world.setDifficulty(Config.DIFFICULTY.get())); + UR.get().getWorlds().forEach(world -> world.setGameRuleValue("naturalRegeneration", Config.NATURAL_REGENERATION.get().toString())); + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 89df197..811de47 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -25,6 +25,7 @@ modules: "border-walls": true "border-warning": true "border-check": true + "ingame-hardcore": true "ingame-food": true "ingame-health": true "ingame-listHealth": true From be1b5d33bd2494096a82047c5faed30fe7127f9d Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 03:14:16 +0100 Subject: [PATCH 29/91] Added commands for team chat & shortcuts to GUIs. * NEW: added new commands and related shortcuts from zTeams for /t, /g, /togglechat, /teams and /team. * OPT: improved /uh tp-death & /uh tp-spawn, using the sender if no player is provided. * OPT: renamed /uh tp-spawn to /uh tp-death. --- .../modules/core/game/GameModule.java | 2 +- .../modules/core/teams/TeamsModule.java | 41 ++++++++++++++++++- .../teleportation/TeleportationModule.java | 4 +- ...TPBackCommand.java => TPDeathCommand.java} | 6 +-- .../commands/TPSpawnCommand.java | 2 +- 5 files changed, 46 insertions(+), 9 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/{TPBackCommand.java => TPDeathCommand.java} (94%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 1902456..b930759 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -670,7 +670,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) new PlayerTeleportedToSpawnPointEvent(player, teleporter.getSpawnForPlayer(uuid))); }) - .whenTeleportationFails(uuid -> log().error("Unable to teleport player {0} - {1}", uuid, Bukkit.getPlayer(uuid).getName())) + .whenTeleportationFails(uuid -> log().error("Unable to teleport player {0} - {1}", uuid, Bukkit.getOfflinePlayer(uuid).getName())) .whenTeleportationEnds(uuids -> { teleportationProcessLock = false; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index c1fd065..c484884 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -31,12 +31,14 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.teams; +import com.google.common.collect.ImmutableMap; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarCacheListener; import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; @@ -47,7 +49,7 @@ import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.commands.TeamsCommand; +import fr.zcraft.zteams.commands.*; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -95,6 +97,9 @@ protected void onEnable() Config.COLORIZE_CHAT.get(), false ) + .setTeamsChatOptions( + Config.TEAM_CHAT.LOG.get() + ) .setBannerOptions( Config.BANNER.SHAPE.WRITE_LETTER.get(), Config.BANNER.SHAPE.ADD_BORDER.get() @@ -118,7 +123,26 @@ public void onGameStarting(final GamePhaseChangedEvent ev) @Override public List<Class<? extends Command>> getCommands() { - return Collections.singletonList(TeamsCommand.class); + return Arrays.asList( + TeamsCommand.class, + TeamChatCommand.class, + GlobalChatCommand.class, + ToggleChatCommand.class, + TeamsGuiCommand.class, + MyTeamCommand.class + ); + } + + @Override + public Map<String, Class<? extends Command>> getCommandsAliases() + { + return ImmutableMap.of( + "t", TeamChatCommand.class, + "g", GlobalChatCommand.class, + "togglechat", ToggleChatCommand.class, + "teams", TeamsGuiCommand.class, + "team", MyTeamCommand.class + ); } @Override @@ -302,4 +326,17 @@ public void onShieldPreCraft(final PrepareItemCraftEvent ev) } } } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + // Disables the team-chat-lock if needed + if (Config.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) + { + if (ZTeams.chatManager().isTeamChatEnabled(ev.getPlayer().getUniqueId())) + { + ZTeams.chatManager().toggleChatForPlayer(ev.getPlayer().getUniqueId()); + } + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java index c11b2a6..a16d833 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java @@ -36,7 +36,7 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPBackCommand; +import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPDeathCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpawnCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpectatorsCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPTeamCommand; @@ -60,7 +60,7 @@ public class TeleportationModule extends UHModule public List<Class<? extends Command>> getCommands() { return Arrays.asList( - TPBackCommand.class, + TPDeathCommand.class, TPSpawnCommand.class, TPTeamCommand.class, TPSpectatorsCommand.class diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java index bdc23ca..955ef35 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPBackCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java @@ -47,13 +47,13 @@ import java.util.List; import java.util.stream.Collectors; -@CommandInfo (name = "tp-back", usageParameters = "<player> [force]",aliases = {"tpback", "tpb"}) -public class TPBackCommand extends Command +@CommandInfo (name = "tp-death", usageParameters = "[player] [force]",aliases = {"tpback", "tpdeath", "tpd"}) +public class TPDeathCommand extends Command { @Override protected void run() throws CommandException { - final Player player = getPlayerParameter(0); + final Player player = args.length > 0 ? getPlayerParameter(0) : playerSender(); final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); if (!UR.module(TeleportationModule.class).hasDeathLocation(player)) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java index 8ed336d..451e805 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java @@ -62,7 +62,7 @@ protected void run() throws CommandException return; } - final Player player = getPlayerParameter(0); + final Player player = args.length > 0 ? getPlayerParameter(0) : playerSender(); final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); final Location spawnLocation = teleporter.getSpawnForPlayer(player.getUniqueId()); From ba2df98a921f86fa7ea001e7a5620716198be162 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 03:24:23 +0100 Subject: [PATCH 30/91] Added aliases in module tooltip --- .../modules/core/modules/ModulesCommand.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java index c7ae6ae..dd545e0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -42,10 +42,7 @@ import fr.zcraft.zlib.components.rawtext.RawTextPart; import org.bukkit.ChatColor; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; import java.util.stream.Stream; @@ -84,6 +81,15 @@ protected void run() throws CommandException if (cmd != null) commands.add(cmd.getUsageString()); }); } + + final Map<String, Class<? extends Command>> commandsAliases = module.get().getCommandsAliases(); + if (commandsAliases != null) + { + commandsAliases.forEach((alias, clazz) -> { + final Command cmd = Commands.getCommandInfo(clazz); + if (cmd != null) commands.add("/" + alias + " " + cmd.getUsageParameters() + ChatColor.DARK_GRAY + " (alias)"); + }); + } } final RawTextPart<?> tooltip = new RawText(); From 044fcf16b7fd3e4f6f6bea31bc6cb70278c1552f Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 03:25:58 +0100 Subject: [PATCH 31/91] fixup! Added commands for team chat & shortcuts to GUIs. --- .../ingame/teleportation/commands/TPSpawnCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java index 451e805..6b14354 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java @@ -75,16 +75,16 @@ protected void run() throws CommandException if (force) { teleporter.teleportPlayer(player.getUniqueId(), true); - success(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); + success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); } else if (UHUtils.safeTP(player, spawnLocation)) { - success(I.t("{cs}The player {0} was teleported to his spawn location.", args[0])); + success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); } else { - warning(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", args[0])); - warning(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", args[0])); + warning(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", player.getName())); + warning(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", player.getName())); } } From 144520404b2fb83a96a7d4bb7c8ad62fc724d1ad Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 15:36:27 +0100 Subject: [PATCH 32/91] Weather module --- .../modules/ingame/weather/Config.java | 54 +++++++++ .../modules/ingame/weather/WeatherModule.java | 103 ++++++++++++++++++ src/main/resources/config.yml | 1 + 3 files changed, 158 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java new file mode 100644 index 0000000..54cdc45 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java @@ -0,0 +1,54 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.weather; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import org.bukkit.WeatherType; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> WEATHER_CYCLE = item("enable-weather-cycle", false); + static public final ConfigurationItem<WeatherType> INITIAL_WEATHER = item("initial-weather", WeatherType.DOWNFALL); + static public final ConfigurationItem<WeatherType> WAITING_PHASE_WEATHER = item("waiting-phase-weather", WeatherType.CLEAR); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java new file mode 100644 index 0000000..abd90d9 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java @@ -0,0 +1,103 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.weather; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import org.bukkit.WeatherType; +import org.bukkit.World; +import org.bukkit.event.EventHandler; +import org.bukkit.event.weather.WeatherChangeEvent; + +import java.util.HashSet; +import java.util.Set; + + +@ModuleInfo ( + name = "Weather", + description = "Manages the in-game weather", + settings = Config.class +) +public class WeatherModule extends UHModule +{ + private Set<World> firstWeatherUpdateOccurred = new HashSet<>(); + + @Override + protected void onEnable() + { + UR.get().getWorlds().forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); + } + + @EventHandler + public void onGameStarts(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) + { + UR.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); + } + } + + @EventHandler + public void onWeatherChange(final WeatherChangeEvent ev) + { + switch (UR.module(GameModule.class).getPhase()) + { + case WAIT: + case STARTING: + ev.setCancelled(true); + break; + + case IN_GAME: + case END: + if (!Config.WEATHER_CYCLE.get()) + { + // We allow a single weather update, as it will be + // the one from the onGameStart event. + if (firstWeatherUpdateOccurred.contains(ev.getWorld())) + { + ev.setCancelled(true); + } + else + { + firstWeatherUpdateOccurred.add(ev.getWorld()); + } + } + break; + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 811de47..009cff5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -26,6 +26,7 @@ modules: "border-warning": true "border-check": true "ingame-hardcore": true + "ingame-weather": true "ingame-food": true "ingame-health": true "ingame-listHealth": true From 0a8c7946b0a15a35f56a3e897dbc26c64142af57 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 16:53:06 +0100 Subject: [PATCH 33/91] Game time module * NEW: added game time module. * NEW: (new feature) the duration of a daylight cycle can be changed. --- .../modules/ingame/daylightCycle/Config.java | 56 +++++++++ .../daylightCycle/DaylightCycleModule.java | 107 ++++++++++++++++++ .../modules/ingame/weather/Config.java | 4 +- src/main/resources/config.yml | 1 + 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java new file mode 100644 index 0000000..8e6bfda --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java @@ -0,0 +1,56 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.daylightCycle; + +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> ENABLE_DAYLIGHT_CYCLE = item("enable-daylight-cycle", true); + static public final ConfigurationItem<TimeDelta> DAYLIGHT_CYCLE_DURATION = item("daylight-cycle-duration", new TimeDelta(0, 20, 0)); + + static public final ConfigurationItem<Long> WAITING_PHASE_HOUR = item("waiting-phase-hour", 6000L); + static public final ConfigurationItem<Long> INITIAL_GAME_HOUR = item("initial-game-hour", 0L); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java new file mode 100644 index 0000000..ae5ed39 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java @@ -0,0 +1,107 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.daylightCycle; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.World; +import org.bukkit.event.EventHandler; + +import java.util.concurrent.atomic.AtomicLong; + + +@ModuleInfo ( + name = "Daylight Cycle", + description = "Configures the daylight cycle (disabled, slowed down, normal, accelerated) and the initial time.", + settings = Config.class +) +public class DaylightCycleModule extends UHModule +{ + // Here are the Magic Values™. + private final static long TICKS_IN_ONE_DAYLIGHT_CYCLE = 24000L; + private final static TimeDelta NORMAL_DAYLIGHT_CYCLE_DURATION = new TimeDelta(0, 20, 0); + + + @Override + protected void onEnable() + { + UR.get().getWorlds().forEach(world -> { + world.setFullTime(Config.WAITING_PHASE_HOUR.get()); + world.setGameRuleValue("doDaylightCycle", Boolean.FALSE.toString()); + }); + } + + @EventHandler + public void onGameStart(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + + final World world = UR.get().getWorld(World.Environment.NORMAL); + + world.setFullTime(Config.INITIAL_GAME_HOUR.get()); + world.setGameRuleValue("doDaylightCycle", Config.ENABLE_DAYLIGHT_CYCLE.get().toString()); + + // If the day cycle duration needs to be altered + if (!Config.DAYLIGHT_CYCLE_DURATION.get().equals(NORMAL_DAYLIGHT_CYCLE_DURATION)) + { + // We disable the automatic cycle to avoid the sun and the moon to boggle on the clients + world.setGameRuleValue("doDaylightCycle", Boolean.FALSE.toString()); + + final long ticksPerDay = Config.DAYLIGHT_CYCLE_DURATION.get().getSeconds() * 20L; + + // For days slower than Minecraft days, it is not required to update every tick, as the daytime + // will be the same for multiple updates. + final long updateInterval = (long) Math.max(1L, (ticksPerDay * 1.0f) / TICKS_IN_ONE_DAYLIGHT_CYCLE); + + final AtomicLong tick = new AtomicLong((Config.INITIAL_GAME_HOUR.get() * 20L) % TICKS_IN_ONE_DAYLIGHT_CYCLE); + if (tick.get() < 0L) tick.addAndGet(TICKS_IN_ONE_DAYLIGHT_CYCLE); + + RunTask.timer(() -> { + // We keep the current tick in one daylight cycle. + if (tick.addAndGet(updateInterval) >= ticksPerDay) tick.set(0L); + + // On each tick, we calculate the time of day we should be at this point. + final long convertedTick = (long) Math.floor((tick.floatValue() / ticksPerDay) * TICKS_IN_ONE_DAYLIGHT_CYCLE); + + // We update the main world. + world.setTime(convertedTick); + }, updateInterval, updateInterval); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java index 54cdc45..ac64d0c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java @@ -48,7 +48,7 @@ public Config(File file) super(file); } - static public final ConfigurationItem<Boolean> WEATHER_CYCLE = item("enable-weather-cycle", false); - static public final ConfigurationItem<WeatherType> INITIAL_WEATHER = item("initial-weather", WeatherType.DOWNFALL); + static public final ConfigurationItem<Boolean> WEATHER_CYCLE = item("enable-weather-cycle", true); + static public final ConfigurationItem<WeatherType> INITIAL_WEATHER = item("initial-weather", WeatherType.CLEAR); static public final ConfigurationItem<WeatherType> WAITING_PHASE_WEATHER = item("waiting-phase-weather", WeatherType.CLEAR); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 009cff5..e9e438a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -27,6 +27,7 @@ modules: "border-check": true "ingame-hardcore": true "ingame-weather": true + "ingame-daylightCycle": true "ingame-food": true "ingame-health": true "ingame-listHealth": true From d950c1d622b435e4d3234b5d1d517260e1276121 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 12 Dec 2018 17:33:53 +0100 Subject: [PATCH 34/91] Normalized modules descriptions --- .../UHCReloaded/modules/beginning/cages/CagesModule.java | 2 +- .../UHCReloaded/modules/border/walls/WallsModule.java | 4 ++-- .../UHCReloaded/modules/border/warning/WarningModule.java | 6 +----- .../UHCReloaded/modules/core/border/BorderModule.java | 2 +- .../amaury/UHCReloaded/modules/core/game/GameModule.java | 2 +- .../modules/core/modules/ModulesManagerModule.java | 4 ++-- .../UHCReloaded/modules/core/sidebar/SidebarModule.java | 2 +- .../UHCReloaded/modules/core/spawns/SpawnsModule.java | 2 +- .../modules/core/spectators/SpectatorsModule.java | 4 ++-- .../amaury/UHCReloaded/modules/core/teams/TeamsModule.java | 2 +- .../UHCReloaded/modules/core/timers/TimersModule.java | 2 +- .../cosmetics/hardcoreHearts/HardcoreHeartsModule.java | 4 ++-- .../UHCReloaded/modules/cosmetics/motd/MotdModule.java | 2 +- .../ingame/deathAnnouncement/DeathAnnouncementModule.java | 2 +- .../amaury/UHCReloaded/modules/ingame/food/FoodModule.java | 4 ++-- .../UHCReloaded/modules/ingame/hardcore/HardcoreModule.java | 2 +- .../UHCReloaded/modules/ingame/health/HealthModule.java | 4 ++-- .../modules/ingame/listHealth/ListHealthModule.java | 4 ++-- .../modules/ingame/teleportation/TeleportationModule.java | 2 +- .../UHCReloaded/modules/ingame/weather/WeatherModule.java | 2 +- .../amaury/UHCReloaded/modules/other/pomf/PomfModule.java | 2 +- 21 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java index d99de30..d36eec1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java @@ -51,7 +51,7 @@ @ModuleInfo ( name = "Cages", - description = "Puts players in cages instead of floating in the air, during the startup process", + description = "Puts players in cages (or platforms) instead of letting them float in the air, during the startup process.", when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, settings = Config.class ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java index 11d5351..ba40708 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java @@ -49,8 +49,8 @@ @ModuleInfo ( - name = "Walls generator", - description = "Generates a solid wall around the arena", + name = "Walls Generator", + description = "Generates a solid wall around the arena.", when = ModuleInfo.ModuleLoadTime.POST_WORLD, settings = Config.class ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java index 7b6d60c..e8a5fcc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java @@ -35,7 +35,6 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; @@ -53,13 +52,12 @@ @ModuleInfo ( name = "Border Warning", - description = "Warns players about the future border size", + description = "Warns players about the future border size.", when = ModuleInfo.ModuleLoadTime.ON_GAME_START, settings = Config.class ) public class WarningModule extends UHModule { - private BorderModule borderModule; private Integer warningSize = 0; private BukkitRunnable warningTask = null; @@ -75,8 +73,6 @@ protected void onEnable() { /// The name of the warning timer displaying the time left before the next border warningTimerName = I.t("Border shrinking"); - - borderModule = UR.module(BorderModule.class); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 0fb742c..b8f2872 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -64,7 +64,7 @@ @ModuleInfo ( name = "Border", - description = "Manages the border size and reduction", + description = "Manages the border size and reduction.", settings = Config.class, can_be_disabled = false, internal = true diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index b930759..3573f17 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -75,7 +75,7 @@ @ModuleInfo ( name = "Game", - description = "Manages the game execution and phases", + description = "Manages the game execution and phases.", settings = Config.class, internal = true, can_be_disabled = false diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java index 4a5b6e9..6987a2e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -48,8 +48,8 @@ @ModuleInfo ( - name = "Modules manager", - description = "Offers to the users a way to manage modules", + name = "Modules Manager", + description = "Offers to the users a way to manage modules.", when = ModuleInfo.ModuleLoadTime.STARTUP, can_be_disabled = false ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java index 6918ba2..2d4b778 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java @@ -41,7 +41,7 @@ @ModuleInfo ( name = "Sidebar", - description = "Manages the sidebar and allows hooks for all modules into it", + description = "Manages the sidebar and allows hooks for all modules into it.", settings = Config.class, internal = true, can_be_disabled = false diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java index 8275cf0..1953d82 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java @@ -59,7 +59,7 @@ @ModuleInfo( name = "Spawns", - description = "Manages the spawns point and allow users to generate them randomly", + description = "Manages the spawn points and allow users to generate them randomly.", settings = Config.class, internal = true, can_be_disabled = false diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index a6b0d27..be228ea 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -58,8 +58,8 @@ @ModuleInfo ( - name = "Spectators manager", - description = "Handles non-playing players", + name = "Spectators Manager", + description = "Handles non-playing players.", when = ModuleInfo.ModuleLoadTime.POST_WORLD, settings = Config.class, can_be_disabled = false diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index c484884..084af31 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -69,7 +69,7 @@ @ModuleInfo ( name = "Teams", - description = "Manages the teams and related commands", + description = "Manages the teams and related commands.", settings = Config.class, internal = true, can_be_disabled = false diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java index f43538f..c7805ee 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java @@ -53,7 +53,7 @@ @ModuleInfo ( name = "Timers", - description = "The timekeeper of the whole UHCReloaded plugin & companions", + description = "The timekeeper of the whole UHCReloaded plugin & companions.", internal = true, can_be_disabled = false ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java index 7b16a68..9090bb5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -40,8 +40,8 @@ @ModuleInfo ( - name = "Hardcore hearts", - description = "Replaces hearts with hardcore hearts. Depends on ProtocolLib.", + name = "Hardcore Hearts", + description = "Replaces hearts with hardcore hearts.", depends = "ProtocolLib", settings = Config.class ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java index 553008a..c213788 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java @@ -46,7 +46,7 @@ @ModuleInfo ( name = "MOTD", - description = "Updates the MOTD according to the current game state", + description = "Updates the MOTD according to the current game state.", settings = Config.class ) public class MotdModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java index 372c5bc..96b956c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java @@ -53,7 +53,7 @@ @ModuleInfo ( name = "Death Announcements", - description = "Adds announcements for players & teams deaths", + description = "Adds announcements for players & teams deaths.", when = ModuleInfo.ModuleLoadTime.ON_GAME_START, settings = Config.class ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java index 7ec684c..93b351f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java @@ -44,8 +44,8 @@ @ModuleInfo ( - name = "Food commands", - description = "Provides commands to update food level & saturation of some or all players", + name = "Food Commands", + description = "Provides commands to update food level & saturation of some or all players.", when = ModuleInfo.ModuleLoadTime.ON_GAME_START ) public class FoodModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java index 93bfdf7..f94acc8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java @@ -39,7 +39,7 @@ @ModuleInfo ( - name = "Hardcore mode", + name = "Hardcore Mode", description = "Disables health natural regeneration and sets correct difficulty in the game's worlds.", when = ModuleInfo.ModuleLoadTime.ON_GAME_START, settings = Config.class diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java index 4a190d8..0ececaa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java @@ -44,8 +44,8 @@ @ModuleInfo ( - name = "Health commands", - description = "Provides commands to update health of some or all players", + name = "Health Commands", + description = "Provides commands to update health of some or all players.", when = ModuleInfo.ModuleLoadTime.ON_GAME_START ) public class HealthModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java index c0e81a3..b7735d7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java @@ -45,8 +45,8 @@ @ModuleInfo ( - name = "Health in players list", - description = "Displays the health of players in the overlay list displayed with <TAB>", + name = "Health in Players List", + description = "Displays the health of players in the overlay list displayed with <TAB>.", when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING ) public class ListHealthModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java index a16d833..d6a8564 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java @@ -50,7 +50,7 @@ @ModuleInfo ( name = "Teleportation Commands", - description = "Provides commands to teleport to spawn, death location, or groups of players" + description = "Provides commands to teleport to spawn, death location, or groups of players." ) public class TeleportationModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java index abd90d9..65858c9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java @@ -50,7 +50,7 @@ @ModuleInfo ( name = "Weather", - description = "Manages the in-game weather", + description = "Manages the in-game weather.", settings = Config.class ) public class WeatherModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java index c275aa8..9e23f64 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java @@ -43,7 +43,7 @@ @ModuleInfo( name = "Pomf", - description = "Pomf au milieu des épisodes #parceque", + description = "Pomf au milieu d'un épisode. #parceque", when = ModuleInfo.ModuleLoadTime.ON_GAME_START ) public class PomfModule extends UHModule From b800dc228fbb10b95c3f40aeaa62ebaa55227899 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 14 Dec 2018 15:46:56 +0100 Subject: [PATCH 35/91] Alliances scenario * NEW: added alliances scenario (similar to True Love). --- .../scenarii/alliances/AllianceRequest.java | 549 ++++++++++++++++++ .../scenarii/alliances/AlliancesModule.java | 238 ++++++++ .../modules/scenarii/alliances/Config.java | 54 ++ .../alliances/TeamsPermissionsChecker.java | 72 +++ .../commands/AllianceRequestCommand.java | 166 ++++++ .../commands/RequestAnswerCommand.java | 88 +++ src/main/resources/config.yml | 8 + 7 files changed, 1175 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java new file mode 100644 index 0000000..1ecd673 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java @@ -0,0 +1,549 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHSound; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.colors.TeamColor; +import org.apache.commons.lang3.Validate; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class AllianceRequest +{ + private final GameModule game; + private final AlliancesModule alliances; + + private final UUID allianceRequestUUID = UUID.randomUUID(); + + private final UUID requesterID; + private final UUID requestedID; + private final Map<UUID, Boolean> approvalsIDs = new HashMap<>(); + + private final ZTeam requesterTeam; + private final ZTeam requestedTeam; + + private final RequestError requestError; + + public AllianceRequest(final UUID requesterID, final UUID requestedTo) + { + Validate.notNull(requesterID, "The requester must not be null"); + Validate.notNull(requestedTo, "The requested must not be null"); + + game = UR.module(GameModule.class); + alliances = UR.module(AlliancesModule.class); + + this.requesterID = requesterID; + this.requestedID = requestedTo; + + this.requesterTeam = ZTeams.get().getTeamForPlayer(requesterID); + this.requestedTeam = ZTeams.get().getTeamForPlayer(requestedTo); + + final Player requesterPlayer = Bukkit.getPlayer(requesterID); + final Player requestedPlayer = Bukkit.getPlayer(requestedID); + + + // Cases of request incompatibility: + // - not both the requester and the requested are online; + // - the requester is too far from the requested; + // - the requester is out of alliances for the amount requested (the amount being + // the future amount of players in the new alliance); + // - the requested is out of alliances for the amount requested; + // - both the requester and the requested are in an alliance (at least one of them + // must be solo, or have their teammate dead); + // - both the requester and the requested are in the same alliance (obviously); + // - such an alliance would end the game (e.g. if there is two players left, they + // cannot ally). + + // We first check for errors + + if (requestedTeam.equals(requesterTeam)) + { + requestError = RequestError.BOTH_IN_THE_SAME_ALLIANCE; + } + else if (requesterPlayer == null || !requesterPlayer.isOnline() || requestedPlayer == null || !requestedPlayer.isOnline()) + { + requestError = RequestError.TOO_FAR; + } + else if (!requesterPlayer.getWorld().equals(requestedPlayer.getWorld())) + { + requestError = RequestError.TOO_FAR; + } + else if (requesterPlayer.getLocation().distanceSquared(requestedPlayer.getLocation()) > Math.pow(Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get(), 2)) + { + requestError = RequestError.TOO_FAR; + } + else if (!checkAlliancesLeft(requesterID)) + { + requestError = RequestError.REQUESTER_OUT_OF_ALLIANCES; + } + else if (!checkAlliancesLeft(requestedTo)) + { + requestError = RequestError.REQUESTED_OUT_OF_ALLIANCES; + } + else if (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1) + { + requestError = RequestError.BOTH_IN_A_DIFFERENT_ALLIANCE; + } + else if (!checkFutureAllianceSize()) + { + requestError = RequestError.FUTURE_ALLIANCE_TOO_BIG; + } + else if (!checkGameEnd()) + { + requestError = RequestError.WOULD_END_THE_GAME; + } + else + { + requestError = RequestError.OK; + } + + if (requestError != RequestError.OK) return; + + + // Okay so here we have a valid request. Yay! + + // Possible cases + // - If both are in a solo team, it's a request for a two-players alliance + // - If the requester is in a two-players alliance, an invite is sent to the + // third-party player to join the alliance. + // - If the requester is solo but the requested in a two-players alliance, an + // invite is sent to the requested and the other member of the alliance, to + // be sure everyone is OK. + // - And so on until the maximal amount of players per alliance is reached. + // + // To summarize, the request is sent to: + // - the requested player, of course; + // - if the requester is in an alliance, other players in the alliance; + // - if the requested is in an alliance, other players in that alliance. + + approvalsIDs.put(requestedTo, false); + + if (requesterTeam.size() > 1 || requestedTeam.size() > 1) + { + (requestedTeam.size() > 1 ? requestedTeam : requesterTeam) + .getPlayers().stream() + .map(OfflinePlayer::getUniqueId) + .forEach(player -> approvalsIDs.put(player, false)); + } + + // We don't forget to self-register as an ongoing request. + + alliances.registerRequest(this); + } + + /** + * Sends an approval request to the players. + */ + public void sendApprovalRequests() + { + checkError(); + + final UHSound[] jingle = new UHSound[] { + new UHSound(1f, 0.8f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.4f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.1f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT") + }; + + approvalsIDs.keySet().stream() + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .forEach(player -> { + player.sendMessage(""); + + player.sendMessage(I.t("{green}{bold}{0} would like to join you in an alliance.", getName(requesterID))); + + if (!player.getUniqueId().equals(requestedID)) + { + player.sendMessage(I.t("{gray}This request was sent to {0}, but everyone in the alliance also need to accept.", getName(requestedID))); + } + + player.sendMessage(""); + + RawMessage.send(player, new RawText(" ") + .then(I.t("{darkgreen}{bold}» {green}{bold}Accept {darkgreen}{bold}«")) + .command(RequestAnswerCommand.class, allianceRequestUUID.toString(), "yes") + .hover(I.t("{green}{bold}Accept {green}this alliance")) + .then(" ") + .then(I.t("{darkred}{bold}» {red}{bold}Decline {darkred}{bold}«")) + .command(RequestAnswerCommand.class, allianceRequestUUID.toString(), "no") + .hover(I.t("{red}{bold}Decline {red}this alliance")) + .build() + ); + + player.sendMessage(""); + + for (int i = 0; i < jingle.length; i++) + { + final int index = i; + RunTask.later(() -> jingle[index].play(player), i * 5L); + } + }); + } + + public void registerApproval(final UUID approver, final boolean approval) + { + checkError(); + + if (!approvalsIDs.containsKey(approver)) + { + throw new IllegalArgumentException("This player was not asked for approval"); + } + + if (!approval) + { + denyAndClose(approver); + } + else + { + approvalsIDs.put(approver, true); + + // Missing approvers for notifications + final int missingApproversCount = (int) approvalsIDs.values().stream().filter(answer -> !answer).count(); + final String missingApprovers = missingApproversCount > 0 + ? " " + I.tn("{gray}Still waiting for {0}'s answer.", "{gray}Still waiting for answers from: {0}.", missingApproversCount, String.join(", ", approvalsIDs.keySet().stream().filter(id -> !approvalsIDs.get(id)).map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName).collect(Collectors.toSet()))) + : ""; + + // We notify the player who just approved the request. + if (missingApproversCount > 0) + { + final Player player = Bukkit.getPlayer(approver); + if (player != null && player.isOnline()) + { + final UUID allianceWith; + + if (requesterTeam.containsPlayer(player)) allianceWith = requestedID; + else allianceWith = requesterID; + + player.sendMessage(I.t("You accepted the request for an alliance with {0}.", getName(allianceWith))); + } + } + + // If one of the sides is an existing alliance, we notify the players in that + // alliance. + final ZTeam notifiedTeam; + final UUID allianceWith; + + if (alliances.allianceSize(requesterTeam) > 1) + { + notifiedTeam = requesterTeam; + allianceWith = requestedID; + } + else if (alliances.allianceSize(requestedTeam) > 1) + { + notifiedTeam = requestedTeam; + allianceWith = requesterID; + } + else + { + notifiedTeam = null; + allianceWith = null; + } + + if (notifiedTeam != null) + { + for (Player player : requesterTeam.getOnlinePlayers()) + { + if (game.isAlive(player) && !player.getUniqueId().equals(approver)) + { + player.sendMessage(I.t("{green}The request for an alliance with {0} was accepted by {1}.", getName(allianceWith), getName(approver)) + missingApprovers); + } + } + } + + // If everyone agree + if (approvalsIDs.values().stream().allMatch(answer -> answer)) + { + applyApprovedRequest(); + } + } + } + + private void denyAndClose(final UUID closedBy) + { + // If one of the players deny the request, it is closed. All players must agree. + // If the request was closed by one of the members of an existing alliance, players + // *of this alliance only* are notified. + + alliances.unregisterRequest(this); + + final ZTeam notifiedTeam; + final OfflinePlayer allianceWith; + final OfflinePlayer closer = Bukkit.getOfflinePlayer(closedBy); + + if (alliances.allianceSize(requesterTeam) > 1 && requesterTeam.containsPlayer(closedBy)) + { + notifiedTeam = requesterTeam; + allianceWith = Bukkit.getOfflinePlayer(requestedID); + } + else if (alliances.allianceSize(requestedTeam) > 1 && requestedTeam.containsPlayer(closedBy)) + { + notifiedTeam = requestedTeam; + allianceWith = Bukkit.getOfflinePlayer(requesterID); + } + else + { + notifiedTeam = null; + allianceWith = null; + } + + if (notifiedTeam != null) + { + notifiedTeam.getOnlinePlayers().stream().filter(player -> !player.getUniqueId().equals(closedBy)).forEach( + player -> { + player.sendMessage(""); + player.sendMessage(I.t("{red}The alliance with {0} was {bold}denied{red} by {1}.", allianceWith.getName(), closer.getName())); + player.sendMessage(""); + } + ); + } + + if (closer.isOnline()) // Should always be true in normal context + { + closer.getPlayer().sendMessage(I.t("{red}You declined {0}'s alliance request.", getName(requesterID))); + } + } + + private void applyApprovedRequest() + { + // In all cases we unregisters this request. + + alliances.unregisterRequest(this); + + + // We first check if we still can approve this request. + + if (!checkAlliancesLeft(requestedID) + || !checkAlliancesLeft(requesterID) + || !checkGameEnd() + || (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1)) + { + UR.log(AlliancesModule.class).warning("The alliance request from {0} to {1} was about to be approved but is now invalid.", getName(requesterID), getName(requestedID)); + + Stream.of(requesterID, requestedID) + .map(Bukkit::getPlayer).filter(Objects::nonNull) + .forEach(player -> player.sendMessage(I.t("{ce}This alliance request is no longer valid. Please re-send it."))); + return; + } + + + // We create a new team for this new alliance. Old teams are dropped. + + final ZTeam allianceTeam = ZTeams.get().createTeam(I.t("Your alliance"), TeamColor.WHITE); + + final Set<UUID> alliancePlayers = Stream.of(requesterTeam, requestedTeam) + .flatMap(team -> team.getPlayersUUID().stream()) + .filter(game::isAlive) + .collect(Collectors.toSet()); + + allianceTeam.addAll(alliancePlayers); + + requestedTeam.deleteTeam(); + requesterTeam.deleteTeam(); + + + // We consume the alliances + + alliances.consumeAlliance(requesterID, allianceTeam.size() - 1); + alliances.consumeAlliance(requestedID, allianceTeam.size() - 1); + + + // We notify the players + + final UHSound[] jingle = new UHSound[] { + new UHSound(1f, 1.10f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.22f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.33f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.44f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new UHSound(1f, 1.80f, "ENTITY_PLAYER_LEVELUP", "LEVEL_UP", "LEVELUP") + }; + + allianceTeam.getOnlinePlayers().forEach(player -> { + player.sendMessage(""); + + if (allianceTeam.size() == 2) + { + player.sendMessage(I.t("{green}{bold}You are now allied with {0}!", allianceTeam.getPlayers().stream().filter(p -> !p.getUniqueId().equals(player.getUniqueId())).findAny().map(OfflinePlayer::getName).orElse("<Unknown>"))); + player.sendMessage(I.t("{green}Your objective is to win together. But chhhh! Other players are not aware of your alliance...")); + } + else + { + player.sendMessage(I.t("{green}{bold}The alliance expands!")); + player.sendMessage(I.t("{gray}Players in the alliance: {0}", String.join(", ", allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())))); + } + + player.sendMessage(""); + + for (int i = 0; i < jingle.length; i++) + { + final int index = i; + RunTask.later(() -> jingle[index].play(player), i * 3L); + } + }); + + + // A small log message + + UR.log(AlliancesModule.class).info( + "{0} succeeded! A new alliance was created between these players: {1}.", + this, + String.join(", ", allianceTeam.getPlayers().stream() + .map(player -> player.getName() + " (a=" + alliances.getAlliancesLeft(player.getUniqueId()) + ")") + .collect(Collectors.toSet()) + ) + ); + } + + /** + * @return The request's UUID, used for request identification in commands. + */ + public UUID getUniqueId() + { + return allianceRequestUUID; + } + + /** + * @return The request sender's UUID. + */ + public UUID getRequesterID() + { + return requesterID; + } + + /** + * @return The request's target UUID. + */ + public UUID getRequestedID() + { + return requestedID; + } + + /** + * @return The error for this request (including « OK »). + */ + public RequestError getError() + { + return requestError; + } + + /** + * A shortcut to get a player's name. + * + * @param playerID A player's UUID. + * @return The player name as a string. + */ + private String getName(final UUID playerID) + { + return Optional.of(Bukkit.getOfflinePlayer(playerID)).map(OfflinePlayer::getName).orElse("<Unknown>"); + } + + /** + * Checks if the future alliance formed if the request is accepted is not too big according + * to the configuration. + * + * @return {@code true} if the future size is OK. + */ + private boolean checkFutureAllianceSize() + { + return alliances.allianceSize(requestedTeam) + alliances.allianceSize(requesterTeam) <= Config.MAX_PLAYERS_PER_ALLIANCE.get(); + } + + /** + * Checks if the given player have sufficient alliances left for this request. + * + * @param checkedPlayerID The player to check. + * @return {@code true} if there are enough alliances left. + */ + private boolean checkAlliancesLeft(final UUID checkedPlayerID) + { + return alliances.getAlliancesLeft(checkedPlayerID) >= 1; + } + + /** + * Checks if this alliance would end the game. + * + * @return {@code true} if this alliance would <strong>not</strong> end the game. + */ + private boolean checkGameEnd() + { + final Set<UUID> playersInFutureAlliance = Stream.of(requestedTeam.getPlayers(), requesterTeam.getPlayers()) + .flatMap(Collection::stream) + .map(OfflinePlayer::getUniqueId) + .collect(Collectors.toSet()); + return game.getAlivePlayersUUIDs().stream().anyMatch(player -> !playersInFutureAlliance.contains(player)); + } + + /** + * Throws an {@link IllegalStateException} if the request has errored. + */ + private void checkError() + { + if (requestError != RequestError.OK) throw new IllegalStateException("This alliance request errored."); + } + + @Override + public String toString() + { + return "AllianceRequest [from " + getName(requesterID) + " (n=" + requesterTeam.size() + ", a=" + alliances.getAlliancesLeft(requesterID) + ") to " + getName(requestedID) + " (n=" + requesterTeam.size() + ", a=" + alliances.getAlliancesLeft(requesterID) + ")]"; + } + + /** + * The request error state. If not OK, all methods except {@link #getError()} will throw + * an {@link IllegalStateException}. + */ + public enum RequestError + { + OK, + TOO_FAR, + REQUESTER_OUT_OF_ALLIANCES, + REQUESTED_OUT_OF_ALLIANCES, + FUTURE_ALLIANCE_TOO_BIG, + BOTH_IN_A_DIFFERENT_ALLIANCE, + BOTH_IN_THE_SAME_ALLIANCE, + WOULD_END_THE_GAME + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java new file mode 100644 index 0000000..1057d58 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java @@ -0,0 +1,238 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; + +import com.google.common.collect.ImmutableMap; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.AllianceRequestCommand; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.colors.TeamColor; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.*; +import java.util.stream.Collectors; + + +@ModuleInfo ( + name = "Alliances Scenario", + description = "If enabled, the game will be alliances-based.\n\n" + + "To use this scenario, start without any team configured. All players " + + "will be alone at the beginning. If they meet someone, they can ask for " + + "an alliance with this player. If everyone is OK, they form a new team, " + + "but they are the only ones to know, as players names are not colored.\n\n" + + "An existing alliance can recruit a new ally using the same mechanism: " + + "if a player ask for an alliance to another player in an existing alliance, " + + "the two players in the alliance will be notified and will have to accept. " + + "If a player in an existing alliance want to invite someone, both the potential " + + "new ally and the other player in the existing alliance will have to agree.\n\n" + + "The number of alliances over time for a given player is limited. You start with " + + "an amount of alliances (default 2). If you create a two-players alliance, you lose " + + "one alliance. If you form a three-players alliance, you lose two alliances. If you " + + "run out of alliances, you can no longer form new alliances, and requests sent to you " + + "will be silently declined.", + settings = Config.class +) +public class AlliancesModule extends UHModule +{ + private GameModule game = null; + + private final Map<UUID, Integer> alliancesLeft = new HashMap<>(); + private final Map<UUID, AllianceRequest> ongoingRequests = new HashMap<>(); + + @Override + protected void onEnable() + { + game = UR.module(GameModule.class); + + // We update some teams settings + + eu.carrade.amaury.UHCReloaded.modules.core.game.Config.SIDEBAR.TEAMS.set(false); + eu.carrade.amaury.UHCReloaded.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); + + ZTeams.settings() + .setTeamsOptions( + eu.carrade.amaury.UHCReloaded.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), + false, + false, + true // Important! As we use the same team names for lots of teams, as titles. + ) + .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_ALLIANCE.get()); + + + // ...And permissions + + ZTeams.setPermissionsChecker(new TeamsPermissionsChecker(ZTeams.get().permissionsChecker())); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Arrays.asList(AllianceRequestCommand.class, RequestAnswerCommand.class); + } + + @Override + public Map<String, Class<? extends Command>> getCommandsAliases() + { + return ImmutableMap.of( + "alliance", AllianceRequestCommand.class, + "a", AllianceRequestCommand.class + ); + } + + + /** + * Inits the count of left alliances to the configured max if not already stored. + * @param playerID The player to initialize the count for. + */ + private void initAlliancesCountIfRequired(final UUID playerID) + { + alliancesLeft.putIfAbsent(playerID, Config.ALLIANCES_PER_PLAYER.get()); + } + + /** + * Consumes an amount of alliances for the given player. + * + * @param playerID The player's ID. + * @param amount The amount to consume. + */ + public void consumeAlliance(final UUID playerID, final int amount) + { + initAlliancesCountIfRequired(playerID); + alliancesLeft.put(playerID, Math.max(0, alliancesLeft.get(playerID) - amount)); + } + + /** + * Returns the amount of alliances left for the given player. + * + * @param playerID The player's ID. + * @return The amount of alliances left. + */ + public int getAlliancesLeft(final UUID playerID) + { + initAlliancesCountIfRequired(playerID); + return alliancesLeft.get(playerID); + } + + /** + * Checks if we can borrow the given amount of alliances to a player. If so, + * borrows them and returns {@code true}. Else, returns {@code false}. + * + * @param playerID The player's ID. + * @param amount The amount of alliances to borrow. + * + * @return {@code true} if they could (and were) borrowed. + */ + public boolean consumeAlliancesIfPossible(final UUID playerID, final int amount) + { + if (getAlliancesLeft(playerID) >= amount) + { + consumeAlliance(playerID, amount); + return true; + } + else return false; + } + + + public void registerRequest(final AllianceRequest request) + { + ongoingRequests.put(request.getUniqueId(), request); + } + + public void unregisterRequest(final AllianceRequest request) + { + ongoingRequests.remove(request.getUniqueId()); + } + + public AllianceRequest getRequestByID(final UUID requestID) + { + return ongoingRequests.get(requestID); + } + + public Set<AllianceRequest> getRequestsBySender(final UUID requestSenderID) + { + return ongoingRequests.values().stream() + .filter(request -> request.getRequesterID().equals(requestSenderID)) + .collect(Collectors.toSet()); + } + + public AllianceRequest getRequestByCouple(final UUID requestSenderID, final UUID requestedID) + { + return ongoingRequests.values().stream() + .filter(request -> request.getRequesterID().equals(requestSenderID)) + .filter(request -> request.getRequestedID().equals(requestedID)) + .findAny().orElse(null); + } + + public int allianceSize(UUID playerID) + { + final ZTeam team = ZTeams.get().getTeamForPlayer(playerID); + + if (team != null) return allianceSize(team); + else return 1; + } + + public int allianceSize(final ZTeam team) + { + return (int) team.getPlayers().stream().filter(game::isAlive).count(); + } + + + /** + * Creates teams for each player before the beginning of the game: the teams will be + * indistinguishable, and the game will be considered as a teams game, even with + * everyone in solo. + */ + @EventHandler (priority = EventPriority.LOWEST) + public void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) + { + final SpectatorsModule spectators = UR.module(SpectatorsModule.class); + + new HashSet<>(ZTeams.get().getTeams()).forEach(ZTeam::deleteTeam); + + Bukkit.getOnlinePlayers().stream() + .filter(player -> !spectators.isSpectator(player)) + .forEach(player -> ZTeams.get().createTeam(I.t("Alone"), TeamColor.WHITE, player)); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java new file mode 100644 index 0000000..7ae9c99 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java @@ -0,0 +1,54 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public ConfigurationItem<Integer> ALLIANCES_PER_PLAYER = item("alliances-per-player", 2); + static public ConfigurationItem<Integer> MAX_PLAYERS_PER_ALLIANCE = item("max-players-per-alliance", 3); + + static public ConfigurationItem<Integer> MAX_DISTANCE_TO_CREATE_AN_ALLIANCE = item("max-distance-to-create-an-alliance", 60); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java new file mode 100644 index 0000000..4f7a03e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java @@ -0,0 +1,72 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; + +import fr.zcraft.zteams.ZTeamsPermission; +import fr.zcraft.zteams.permissions.PermissionsChecker; +import org.bukkit.permissions.Permissible; + +public class TeamsPermissionsChecker implements PermissionsChecker +{ + private PermissionsChecker delegate; + + public TeamsPermissionsChecker(PermissionsChecker delegate) + { + this.delegate = delegate; + } + + @Override + public boolean hasPermission(Permissible permissible, ZTeamsPermission permission) + { + switch (permission) + { + + case CREATE_TEAM: + case DELETE_TEAM: + case RESET_TEAMS: + case LIST_TEAMS: // Very important! Would allow to see all alliances. + case JOIN_TEAM: + case LEAVE_TEAM: + case UPDATE_TEAMS_PLAYERS_LIST: + case UPDATE_TEAM_COLOR: + case UPDATE_OTHER_TEAM_NAME: + case UPDATE_OTHER_TEAM_COLOR: + case UPDATE_OTHER_TEAM_BANNER: + return false; + + default: + return delegate.hasPermission(permissible, permission); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java new file mode 100644 index 0000000..8c77abc --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java @@ -0,0 +1,166 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AllianceRequest; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.Config; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.stream.Collectors; + +@CommandInfo (name = "alliance-request", usageParameters = "<player>", aliases = {"alliancerequest", "alliance", "ally"}) +public class AllianceRequestCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) + { + error("The game is not started."); + } + else if (args.length == 0) + { + throwInvalidArgument(I.t("You must provide a player name.")); + } + + final AlliancesModule alliances = UR.module(AlliancesModule.class); + + final Player requested = getPlayerParameter(0); + + if (requested.getUniqueId().equals(playerSender().getUniqueId())) + { + error(I.t("You cannot create an alliance with yourself.")); + } + else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.getUniqueId()) != null) + { + error(I.t("You already have an ongoing alliance request sent to {0}. Please be patient!", requested.getName())); + } + + final AllianceRequest request = new AllianceRequest(playerSender().getUniqueId(), requested.getUniqueId()); + + UR.log(AlliancesModule.class).info("New request: {0} - {1}", request, request.getError()); + + // The rule to send error messages is: no answer should not be distinguishable from + // errors linked to existing alliances, because the alliances are secret. + + switch (request.getError()) + { + case TOO_FAR: + error(I.t("{0} is too far. You must be within {1} blocks of each other.", requested.getName(), Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get())); + return; + + case REQUESTER_OUT_OF_ALLIANCES: + error(I.t("You can no longer join an alliance.")); + return; + + case REQUESTED_OUT_OF_ALLIANCES: + yourRequestHasBeenSent(requested); + + requested.sendMessage(""); + requested.sendMessage(I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because you have no alliance left.", sender.getName())); + requested.sendMessage(I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", sender.getName())); + requested.sendMessage(""); + + return; + + case FUTURE_ALLIANCE_TOO_BIG: + // Here, if the player is solo, we say that the request was sent and we warn the + // other alliance members. If the player is in an alliance he know its size and + // the other one is solo. + if (alliances.allianceSize(playerSender().getUniqueId()) == 1) + { + yourRequestHasBeenSent(requested); + + ZTeams.get().getTeamForPlayer(requested).getOnlinePlayers().forEach(teammate -> { + teammate.sendMessage(""); + teammate.sendMessage(I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because your alliance is already at full capacity.", sender.getName())); + teammate.sendMessage(I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", sender.getName())); + teammate.sendMessage(""); + }); + } + else + { + error(I.t("You cannot send a request alliance as your alliance is already at full capacity. Don't be too greedy!")); + } + + return; + + case BOTH_IN_A_DIFFERENT_ALLIANCE: + // Here we cannot inform the other alliance because they would know the sender is in an alliance. + yourRequestHasBeenSent(requested); + return; + + case BOTH_IN_THE_SAME_ALLIANCE: + error(I.t("You're already allied with {0}!", requested.getName())); + return; + + case WOULD_END_THE_GAME: + error(I.t("You cannot create this alliance as it would end the game.")); + return; + + case OK: + yourRequestHasBeenSent(requested); + + request.sendApprovalRequests(); + + break; + } + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingPlayerNames(Bukkit.getOnlinePlayers().stream().filter(player -> !player.equals(sender)).collect(Collectors.toSet()), args[0]); + else return null; + } + + private void yourRequestHasBeenSent(final Player to) + { + info(""); + success(I.t("{bold}Your request has been sent to {0}.", to.getName())); + success(I.t("Wait until it is accepted. Let's hope you don't hear only silence...")); + info(""); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java new file mode 100644 index 0000000..fce82f4 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java @@ -0,0 +1,88 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands; + +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AllianceRequest; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; + +import java.util.UUID; + +@CommandInfo (name = "alliance-request-answer", usageParameters = "<requestUUID> <yes|no> §8(internal)") +public class RequestAnswerCommand extends Command +{ + @Override + protected void run() throws CommandException + { + if (args.length < 2) + { + UR.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + throwInvalidArgument(I.t("Invalid command usage. But, you shouldn't use this command directly. What are you doing?")); + } + + try + { + final Player player = playerSender(); + final UUID requestID = UUID.fromString(args[0]); + final boolean answer = getBooleanParameter(1); + + final AllianceRequest request = UR.module(AlliancesModule.class).getRequestByID(requestID); + + if (request != null) + { + try + { + UR.log(AlliancesModule.class).info("{0}: reply from {1}: {2}", request, player.getName(), answer); + request.registerApproval(player.getUniqueId(), answer); + } + catch (IllegalArgumentException e) + { + UR.log(AlliancesModule.class).warning("{0}: {1} tried to reply {2} but was not in the approvers list.", request, player.getName(), answer); + error(I.t("You weren't asked for your opinion regarding this request.")); + } + } + else error(I.t("This request has expired.")); + } + catch (IllegalArgumentException e) + { + UR.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + throwInvalidArgument("Malformed UUID."); + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e9e438a..b37c764 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,6 +15,7 @@ # Empty value: system language. lang: + # The modules to load & enable. You can add modules provided by other plugins. # Each module's configuration is in plugins/UHPlugin/modules/<modulename>.yml . # You can put internal modules or refer to modules classes from other plugins. In all @@ -22,9 +23,11 @@ lang: modules: "beginning-wait": true "beginning-cages": true + "border-walls": true "border-warning": true "border-check": true + "ingame-hardcore": true "ingame-weather": true "ingame-daylightCycle": true @@ -35,11 +38,16 @@ modules: "ingame-episodes": true "ingame-deathAnnouncement": true # "ingame-kick": false + "cosmetics-hardcoreHearts": true "cosmetics-motd": true + "other-playersLoader": true "other-about": true + "scenarii-alliances": true + + # The worlds to use as main worlds. # If not found, fallbacks on the first world found with the right type. worlds: From e52d6bf3c0b87f3b7b8cefc9858dee8623ce6b62 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 14 Dec 2018 16:43:24 +0100 Subject: [PATCH 36/91] Partial french translation + fixes * OPT: French translation updated. * OPT: The spawns generator takes spectators into account for the default spawns amount to generate. * OPT: the UR.log() method never returns null, even if the module class is not registered (returns a generic logger in these cases). * OPT: improved UHSound compatibility with recent Minecraft versions. * BUG: fixed configuration option ignored for end-of-grace-period broadcast. --- .../amaury/UHCReloaded/core/ModuleLogger.java | 2 +- .../UHCReloaded/modules/core/game/Config.java | 4 +- .../core/game/submanagers/GameBeginning.java | 7 +- .../core/spawns/commands/SpawnsCommand.java | 3 +- .../amaury/UHCReloaded/shortcuts/UR.java | 5 +- .../amaury/UHCReloaded/utils/UHSound.java | 5 +- src/main/resources/i18n/fr_FR.po | 4209 +++++++++-------- 7 files changed, 2258 insertions(+), 1977 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index 3f6c5f5..1cae3c2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -48,7 +48,7 @@ public class ModuleLogger extends Logger { private final String loggerName; - ModuleLogger(Class<?extends UHModule> module) + public ModuleLogger(Class<?extends UHModule> module) { super(ZLib.getPlugin().getClass().getCanonicalName(), null); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index e1fa9b5..e16c911 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -67,12 +67,12 @@ public static final class SlowSection extends ConfigurationSection public static final class BeginningSection extends ConfigurationSection { - public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 2)); // TODO 30s + public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); public final ConfigurationItem<Boolean> DISPLAY_GRACE_PERIOD = item("display-grace-period", true); public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0)); - public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 15, 0)); + public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 20, 0)); } public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 508f5b0..6a399b2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -92,8 +92,13 @@ public void onGameStarts(GamePhaseChangedEvent ev) RunTask.later(() -> { inGracePeriod = false; + UR.module(GameModule.class).getAliveConnectedPlayers().forEach(ActionBar::removeMessage); - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); + + if (Config.BEGINNING.BROADCAST_GRACE_END.get()) + { + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); + } }, grace.getSeconds() * 20L); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java index 53a4142..043de87 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java @@ -37,6 +37,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; @@ -402,7 +403,7 @@ else if (sender instanceof BlockCommandSender) // Solo mode? if (spawnsCount == 0) { - spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - 0/* TODO UR.module(GameModule.class).getStartupSpectators().size()*/; + spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - UR.module(SpectatorsModule.class).getSpectators().size(); info(I.t("{ci}No team found: assuming the game is a solo game.")); } else diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index 9590fc5..20a1128 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -80,7 +80,10 @@ public static ModuleLogger log(final Class<? extends UHModule> moduleClass) } catch (final NullPointerException e) { - return null; + // Ensures no NPE so IDEs are happy. + return new ModuleLogger(UnknownModule.class); } } + + private class UnknownModule extends UHModule {} } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java index 9922a5e..7d11452 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java @@ -43,6 +43,7 @@ import org.bukkit.entity.Player; import java.util.Arrays; +import java.util.Objects; /** @@ -315,7 +316,7 @@ else if (!pitch.equals(other.pitch)) { return false; } - return sound == other.sound && (volume == null ? other.volume == null : volume.equals(other.volume)); + return sound == other.sound && (Objects.equals(volume, other.volume)); } @@ -335,7 +336,7 @@ public static Sound string2Sound(String soundName) { if (soundName != null) { - soundName = soundName.trim().toUpperCase().replace(" ", "_"); + soundName = soundName.trim().toUpperCase().replace(' ', '_').replace('.', '_'); try { return Sound.valueOf(soundName); diff --git a/src/main/resources/i18n/fr_FR.po b/src/main/resources/i18n/fr_FR.po index cd773ab..e9e750c 100644 --- a/src/main/resources/i18n/fr_FR.po +++ b/src/main/resources/i18n/fr_FR.po @@ -32,8 +32,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-19 16:34+0100\n" -"PO-Revision-Date: 2016-12-19 16:35+0100\n" +"POT-Creation-Date: 2018-12-14 15:48+0100\n" +"PO-Revision-Date: 2018-12-14 16:22+0100\n" "Last-Translator: Amaury Carrade\n" "Language-Team: Amaury Carrade\n" "Language: fr_FR\n" @@ -41,1290 +41,1576 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n>1;\n" -"X-Generator: Poedit 1.7.5\n" +"X-Generator: Poedit 2.2\n" -#. The name of the warning timer displaying the time left before the next border -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:86 -msgid "Border shrinking" -msgstr "Réduction" +#. A simple information, because this start is slower (yeah, Captain Obvious here) +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:393 +msgid "{lightpurple}Teleportation in progress... Please wait." +msgstr "{lightpurple}Téléportation en cours... Merci de patienter." + +#. / Displayed in the action bar while the slow teleportation occurs. +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:408 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:701 +msgid "{lightpurple}Teleporting... {gray}({0}/{1})" +msgstr "{lightpurple}Téléportation... {gray}({0}/{1})" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:425 +msgid "{gray}Player {0}{gray} teleported." +msgstr "{gray}Joueur {0}{gray} téléporté." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:448 +msgid "{ce}Cannot teleport player {0}!" +msgstr "{ce]Impossible de téléporter le joueur {0} !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:458 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:709 +msgid "{cs}All teams are teleported." +msgstr "{cs}Toutes les équipes ont été téléportées." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:459 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:713 +msgid "{gray}Use {cc}/uh start{gray} or click here to start the game." +msgstr "" +"{gray}Utilisez {cc}/uh start{gray} ou cliquez ici pour démarrer le jeu." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:460 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:714 +msgid "Click here to start the game" +msgstr "Cliquez ici pour démarrer la partie" + +#. / Displayed in the action bar when the slow teleportation is finished but the game not started. +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:469 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:726 +msgid "{lightpurple}Teleportation complete. {gray}The game will start soon..." +msgstr "{lightpurple}Téléportation terminée. {gray}Ça ne devrait pas tarder..." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:496 +msgid "{ce}Please execute {cc}/uh start slow:true{ce} before." +msgstr "{ce}Veuillez exécuter {cc}/uh start slow:true{ce} avant." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:502 +msgid "{ce}Please wait while the players are teleported." +msgstr "{ce}Veuillez patienter, les équipes sont en train d'être téléportées." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:591 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java:100 +msgid "" +"{red}{bold}Warning!{white} The grace period ended, you are now vulnerable." +msgstr "" +"{red}{bold}Attention !{white} La période de grâce est terminée ; vous êtes " +"désormais vulnérable." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:603 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java:113 +msgid "{red}{bold}Warning!{white} PvP is now enabled." +msgstr "{red}{bold}Attention !{white} Le PvP est désormais actif." + +#. / Spectators list item if the nick cannot be found +#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:927 +#, java-format +msgid "Unknown player with UUID {0}" +msgstr "Joueur inconnu ayant l'UUID {0}" + +#. / Title of the rules box. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java:120 +msgid "{red}{bold}Rules and informations" +msgstr "{red}{bold}Règles et informations" + +#. / Rule item in the rule box. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java:131 +msgid "{darkgray}- {reset}{0}" +msgstr "{darkgray}- {reset}{0}" + +#. / Episode in the player list ({episodeText} replacement). {0} = current episode number. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java:115 +#, java-format +msgid "Episode {0}" +msgstr "Épisode {0}" + +#. / Players in the player list ({playersText} replacement). {0} = current alive players count. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java:117 +#, java-format +msgid "{0} player" +msgid_plural "{0} players" +msgstr[0] "{0} joueur" +msgstr[1] "{0} joueurs" + +#. / Teams in the player list ({teamsText} replacement). {0} = current alive teams count. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java:119 +#, java-format +msgid "{0} team" +msgid_plural "{0} teams" +msgstr[0] "{0} équipe" +msgstr[1] "{0} équipes" + +#. / MOTD when the game is not started. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:92 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:74 +msgid "Waiting for players..." +msgstr "En attente de joueurs..." + +#. / MOTD when the game is starting (slow TP in progress). +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:101 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:77 +msgid "Starting in progress..." +msgstr "Démarrage en cours..." + +#. / Solo game running MOTD. {0} = players alive count. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:116 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:88 +#, java-format +msgid "Game running! {0} player alive." +msgid_plural "Game running! {0} players alive." +msgstr[0] "Partie en cours ! {0} joueur encore en vie." +msgstr[1] "Partie en cours ! {0} joueurs encore en vie." + +#. / Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:121 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:83 +#, java-format +msgid "Game running! {0} player alive in {1} team." +msgid_plural "Game running! {0} players alive in {1} teams." +msgstr[0] "Partie en cours ! {0} joueur en vie dans {1} équipe." +msgstr[1] "Partie en cours ! {0} joueurs en vie dans {1} équipes." + +#. / Game finished MOTD with solo winner ({0} = winner raw name). +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:138 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:103 +#, java-format +msgid "Game finished; congratulation to {0} for his victory!" +msgstr "Partie terminée ; félicitation à {0} pour sa victoire !" + +#. / Game finished MOTD with team winner ({0} = team display name). +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java:143 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java:98 +#, java-format +msgid "Game finished; the team {0} wins this match!" +msgstr "Partie terminée ; l'équipe {0} remporte la victoire !" + +#. / Usage of the /g and /t commands +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java:109 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java:108 +msgid "{ce}Usage: /{0} <message>" +msgstr "{ce}Utilisation : /{0} <message>" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java:63 +msgid "{ce}No rules are set in the config file." +msgstr "{ce}Aucune règle n'est enregistrée dans le fichier de configuration." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java:75 +msgid "{cs}Rules sent to {0}." +msgstr "{cs}Les règles ont été envoyées à {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java:79 +msgid "{ce}Cannot display the rules to {0} because he (or she) is offline." +msgstr "" +"{ce}Impossible d'afficher les règles à {0} car il ou elle est hors-ligne." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java:103 +msgid "" +"{cc}/uh rules [player] {ci}: sends the server rules to the server or the " +"given player." +msgstr "" +"{cc}/uh rules [joueur] {ci}: envoie les règles du jeu au serveur ou au " +"joueur spécifié." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:92 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:118 +msgid "{cst}You where frozen by {0}." +msgstr "{cst}Vous avez été immobilisé(e) par {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:96 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:123 +msgid "{cst}You where unfrozen by {0}." +msgstr "{cst}Vous avez été libéré(e) par {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:111 +msgid "{ce}{0} is offline!" +msgstr "{ce}{0} est hors-ligne !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:119 +msgid "{cs}{0} is now frozen." +msgstr "{cs}{0} est désormais immobilisé(e)." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:124 +msgid "{cs}{0} is now unfrozen." +msgstr "{cs}{0} est désormais libéré(e)." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:138 +msgid "{darkaqua}The entire game is now frozen." +msgstr "{darkaqua}Le jeu est désormais en pause." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:142 +msgid "{darkaqua}The game is now unfrozen." +msgstr "{darkaqua}Le jeu n'est plus en pause." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:182 +msgid "{aqua}------ Freeze commands ------" +msgstr "{aqua}------ Commandes liées à l'immobilisation ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:183 +msgid "" +"{cc}/uh freeze on [player]{ci}: freezes a player, or the sender without a " +"specified player." +msgstr "" +"{cc}/uh freeze on [joueur] {ci}: immobilise un joueur, ou l'exécuteur sans " +"joueur spécifié." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:184 +msgid "" +"{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if " +"the entire game is frozen." +msgstr "" +"{cc}/uh freeze off [player] {ci}: libère un joueur (ou l'envoyeur), même si " +"le jeu est en pause." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:185 +msgid "{cc}/uh freeze all{ci}: freezes the entire game (players, mobs, timer)." +msgstr "" +"{cc}/uh freeze all {ci}: met le jeu en pause (immobilise les joueurs, mobs, " +"et le compteur)." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:186 +msgid "" +"{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this " +"in order to relaunch the timer." +msgstr "" +"{cc}/uh freeze none {ci}: relance le jeu. Vous DEVEZ exécuter ceci pour " +"relancer le compteur." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java:193 +msgid "" +"{cc}/uh freeze {ci}: (un)freezes the entire game, or a player. See /uh " +"freeze for details." +msgstr "" +"{cc}/uh freeze {ci}: (dés)immobilise l'ensemble du jeu, ou un joueur. " +"Consultez /uh freeze pour plus de détails." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java:76 +msgid "{ce}The game is not started!" +msgstr "{ce}Le jeu n'est pas encore démarré !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java:80 +msgid "{ce}There's not one team alive!" +msgstr "{ce}Il n'y a pas qu'une équipe encore en vie !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java:104 +msgid "" +"{cc}/uh finish {ci}: displays the name of the winner(s) and launches some " +"fireworks." +msgstr "" +"{cc}/uh finish {ci}: affiche le nom du/des vainqueurs et lance des feux " +"d'artifices." + +#. / Header of the /uh infos command. Plural based on the players count. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:70 +msgid "{ci}{0} player alive in {1} team." +msgid_plural "{ci}{0} players alive in {1} teams." +msgstr[0] "{ci}{0} joueur en vie, dans {1} équipe." +msgstr[1] "{ci}{0} joueurs en vie, répartis dans {1} équipes." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:74 +msgid "{ci}The game is not started." +msgstr "{ci}Le jeu n'est pas encore démarré." + +#. / Online status dot in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:93 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:150 +msgid "{green} • " +msgstr "{green} • " + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:94 +msgid "Currently online" +msgstr "Actuellement connecté(e)" + +#. / Offline status dot in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:99 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:154 +msgid "{red} • " +msgstr "{red} • " + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:100 +msgid "Currently offline" +msgstr "Actuellement hors-ligne" + +#. / Team name in tooltip in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:109 +#, java-format +msgid "Team: {0}" +msgstr "Équipe : {0}" + +#. / Separator in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:116 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:161 +msgid "{gray} - " +msgstr "{gray} - " + +#. / Alive state in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:123 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:165 +msgid "{green}alive" +msgstr "{green}vivant" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:126 +#, java-format +msgid "{0} half-hearts" +msgstr "{0} demi-cœurs" + +#. / Alive state in /uh infos +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:132 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:169 +msgid "{red}dead" +msgstr "{red}mort" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java:197 +msgid "{cc}/uh infos {ci}: prints some infos about the current game." +msgstr "{cc}/uh infos {ci}: affiche des informations à propos du jeu en cours." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java:39 +msgid "{aqua}------ Game-related commands ------" +msgstr "{aqua}------ Commandes liées au jeu ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java:40 +msgid "{aqua}------ Bugs-related commands ------" +msgstr "{aqua}------ Commandes liées aux bugs ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java:41 +msgid "{aqua}------ Miscellaneous commands ------" +msgstr "{aqua}------ Commandes diverses ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:208 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:54 +msgid "{yellow}{0} - version {1}" +msgstr "{yellow}{0} - version {1}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:209 +msgid "" +"{ci}Legend: {cc}/uh command <required> [optional=default] <spaces allowed ..." +">{ci}." +msgstr "" +"{ci}Légende: {cc}/uh command <requis> [optionnel=valeur par défaut] <espaces " +"autorisées ...>{ci}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:225 +msgid "{ce}{bold}You cannot execute this command this way." +msgstr "{ce}{bold}Vous ne pouvez exécuter cette commande ainsi." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:226 +msgid "{ce}The help is displayed above." +msgstr "{ce}L'aide est rappelée ci-dessus." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:257 +msgid "{ce}You are not allowed to execute this command." +msgstr "{ce}Vous n'avez pas le droit d'exécuter cette commande." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java:261 +msgid "{ce}This can only be executed as a player." +msgstr "{ce}Vous ne pouvez exécuter cela qu'en étant un joueur." + +#. / Golden head lore for withers +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:280 +msgid "Made from the fallen head of a malignant monster" +msgstr "Fabriquée depuis la tête tranchée d'un monstre maléfique" + +#. / Golden head lore for players. {0} = player name. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:285 +#, java-format +msgid "Made from the fallen head of {0}" +msgstr "Fabriquée depuis la tête tranchée de {0}" + +#. / Item name of a golden head (from a player) +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:388 +msgctxt "player_head" +msgid "{aqua}Golden head" +msgstr "{aqua}Tête d'or" + +#. / Item name of an enchanted golden head (from a player) +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:394 +msgctxt "player_head" +msgid "{lightpurple}Golden head" +msgstr "{lightpurple}Tête d'or" + +#. / Item name of a golden head (from a monster) +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:421 +msgctxt "monster_head" +msgid "{aqua}Golden head" +msgstr "{aqua}Tête d'or" + +#. / Item name of an enchanted golden head (from a monster) +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:427 +msgctxt "monster_head" +msgid "{lightpurple}Golden head" +msgstr "{lightpurple}Tête d'or" -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:365 -msgid "{cs}All players are inside the given border." -msgstr "{cs}Tous les joueurs sont à l'intérieur de cette bordure." +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:42 +msgctxt "protip" +msgid "{gray}You can lock and unlock the team chat with {cc}/togglechat{gray}." +msgstr "" +"{gray}Verrouillez le chat d'équipe avec {cc}/togglechat{gray}, qui permet de " +"passer d'un chat à l'autre." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:369 -msgid "{ci}There are {0} players outside the given border." -msgstr "{ci}Il y a {0} joueurs hors de cette bordure." +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:43 +msgctxt "protip" +msgid "{gray}You can send a global message using {cc}/g <message>{gray}." +msgstr "" +"{gray}Vous pouvez envoyer un message à tout le monde avec {cc}/g " +"<message>{gray}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:375 -msgid "{lightpurple} - {red}{0}{ci} (far away from the border)" -msgstr "{lightpurple} - {red}{0}{ci} (loin de la bordure)" +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:44 +msgctxt "protip" +msgid "{gray}You can send a team-chat message with {cc}/t <message>{gray}." +msgstr "" +"{gray}Vous pouvez envoyer un message à votre équipe avec {cc}/t " +"<message>{gray}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:379 -msgid "{lightpurple} - {yellow}{0}{ci} (close to the border)" -msgstr "{lightpurple} - {yellow}{0}{ci} (proche de la bordure)" +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:46 +msgctxt "protip" +msgid "" +"{gray}You can craft golden apples with heads (same recipe with a head " +"instead of an apple)." +msgstr "" +"{gray}Vous pouvez fabriquer des pommes d'or avec les têtes (même recette " +"avec une tête à la place de la pomme)." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:383 -msgid "{lightpurple} - {green}{0}{ci} (very close to the border)" -msgstr "{lightpurple} - {green}{0}{ci} (très proche de la bordure)" +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:47 +msgctxt "protip" +msgid "" +"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " +"spider eye and a gunpowder." +msgstr "" +"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " +"zombie, un œil d'araignée et une poudre à canon." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:429 -msgid "{red}Warning!" -msgstr "{red}Attention !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:48 +msgctxt "protip" +msgid "" +"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " +"spider eye and a gunpowder; in the center, an ender pearl." +msgstr "" +"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " +"zombie, un œil d'araignée et une poudre à canon ; au centre une Perle du " +"Néant." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:429 -msgid "{white}The border begins to shrink..." -msgstr "{white}La bordure commence à se réduire..." +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:49 +msgctxt "protip" +msgid "" +"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " +"spider eye and a gunpowder; in the center, an Eye of Ender." +msgstr "" +"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " +"zombie, un œil d'araignée et une poudre à canon ; au centre un Œil du Néant." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:431 -msgid "{red}{bold}The border begins to shrink..." -msgstr "{red}{bold}La bordure commence à se réduire..." +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:50 +msgctxt "protip" +msgid "{gray}The glistering melon is crafted with a melon and a gold block." +msgstr "" +"{gray}La pastèque scintillante se fabrique avec une pastèque et un bloc d'or." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:52 +msgctxt "protip" +msgid "{gray}The enchanted golden apple is disabled for this game." +msgstr "{gray}La pomme d'or enchantée est désactivée pour cette partie." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:54 +msgctxt "protip" +msgid "" +"{gray}Fallen on a tree? Jump, you have a few seconds left to remain " +"invincible." +msgstr "" +"{gray}Tombé(e) sur un arbre ? Sautez, il vous reste quelques dizaines de " +"secondes d'invincibilité." + +#. / ProTip invite, displayed before a ProTip. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java:132 +msgid "{darkpurple}ProTip!" +msgstr "{darkpurple}Astuce !" + +#. / The kick message of a player when death.kick.do = true in config +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:133 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java:53 +msgid "jayjay" +msgstr "jayjay" + +#. / The kick message displayed if a player tries to relog after his death and it's forbidden by the config. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:288 +msgid "You are dead!" +msgstr "Vous êtes mort !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:491 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java:125 +msgid "{aqua}-------- End of episode {0} [forced by {1}] --------" +msgstr "{aqua}-------- Fin de l'épisode {0} [forcé par {1}] --------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:495 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java:129 +msgid "{aqua}-------- End of episode {0} --------" +msgstr "{aqua}-------- Fin de l'épisode {0} --------" + +#. / The title displayed when the episode change. {0} = new episode number; {1} = old. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:507 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java:141 +msgid "{darkaqua}Episode {aqua}{0}" +msgstr "{darkaqua}Épisode {aqua}{0}" + +#. Broadcast +#. / Start message broadcasted in chat +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:531 +msgid "{green}--- GO ---" +msgstr "{green}--- GO ---" + +#. / Title of title displayed when the game starts. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:539 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:465 +msgid "{darkgreen}Let's go!" +msgstr "{darkgreen}C'est parti !" + +#. / Subtitle of title displayed when the game starts. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java:541 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:467 +msgid "{green}Good luck, and have fun" +msgstr "{green}Bonne chance et bon jeu à tous" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:205 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:259 +msgid "{aqua}Golden head" +msgstr "{aqua}Tête d'or" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:206 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:260 +msgid "{lightpurple}Golden head" +msgstr "{lightpurple}Tête d'or" + +#. / Error message if a player tries to use his pointing compass without rotten flesh. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:311 +msgid "{gray}{italic}You do not have rotten flesh." +msgstr "{gray}{italic}Vous n'avez pas de chair de zombie." + +#. / Error message if a player tries to use his pointing compass without a player nearby. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:342 +msgid "{gray}{italic}Only silence answers your request." +msgstr "{gray}{italic}Seul le silence comble votre requête." + +#. / Success message when a player uses his pointing compass. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:349 +msgid "{gray}The compass now points to the closest player." +msgstr "{gray}Le compas pointe désormais vers le joueur le plus proche." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:258 +msgid "Golden head" +msgstr "Tête d'or" + +#. / Dynmap marker label of a death point +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java:151 +#, java-format +msgid "Death point of {0}" +msgstr "Ici disparu {0}" + +#. / Dynmap marker label of a spawn point of a team. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java:230 +#, java-format +msgid "Spawn point of the team {0}" +msgstr "Lieu de démarrage de l'équipe {0}" + +#. / Dynmap marker label of a spawn point of a player, in solo. +#. / Dynmap marker label of a spawn point of a player, when the teleportation ignores the teams. +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java:235 +#: src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java:292 +#, java-format +msgid "Spawn point of {0}" +msgstr "Lieu de démarrage de {0}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java:58 +msgid "{ce}You cannot load unknown players in offline mode, sorry." +msgstr "" +"{ce}Vous ne pouvez pas charger des joueurs inconnus en mode hors-ligne, " +"désolé." + +#. / Error returned if one calls /uh loadplayers without arguments. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java:65 +msgid "{ce}You need to provide at least one player name." +msgstr "{ce}Vous devez spécifier au moins un nom de joueur." + +#. / Message displayed when the /uh loadplayers command is used, as the execution may take some time. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java:70 +msgid "{cst}Loading players..." +msgstr "{cst}Chargement des joueurs..." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java:76 +msgid "{cs}Loaded {0} player successfully." +msgid_plural "{cs}Loaded {0} players successfully." +msgstr[0] "{cs}{0} joueur a été chargé." +msgstr[1] "{cs}{0} joueurs ont été chargés." + +#. / Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java:79 +msgid "{ce}{0} player is missing: {1}." +msgid_plural "{ce}{0} players are missing: {1}." +msgstr[0] "{ce}Il manque {0} joueur : {1}." +msgstr[1] "{ce}Il manque {0} joueurs : {1}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java:110 +msgid "{yellow}Beta version" +msgstr "{yellow}Version bêta" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java:118 +msgid "{red}Development version" +msgstr "{red}Version de développement" + +#. / The "and" in the authors list (like "Amaury Carrade, azenet and João Roda") +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java:197 +msgctxt "authors_list" +msgid "and" +msgstr "et" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:55 +#, java-format +msgid "Plugin made with love by {0}." +msgstr "Plugin réalisé avec amour par {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:59 +#, java-format +msgid "Build number: {0}." +msgstr "Numéro de construction : {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:63 +msgid "Build number not available." +msgstr "Numéro de construction indisponible." + +#. Translation +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:68 +msgid "{aqua}------ Translations ------" +msgstr "{aqua}------ Traductions ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:69 +#, java-format +msgid "Current language: {0} (translated by {1})." +msgstr "Langue courante : {0} (traduit par {1})." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:70 +#, java-format +msgid "Fallback language: {0} (translated by {1})." +msgstr "Langue par défaut : {0} (traduit par {1})." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:71 +msgid "{aqua}------ License ------" +msgstr "{aqua}------ Licence ------" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java:72 +msgid "Published under the CeCILL-B License." +msgstr "Publié sous la licence CeCILL-B." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:75 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java:85 +msgid "{ce}Hey, this is not a number of half-hearts. It's a text. Pfff." +msgstr "" +"{ce}Hey, ce n'est pas un nombre de demi-coeurs... C'est un texte... Pfff." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:82 +msgid "{ce}Serial killer!" +msgstr "{ce}S'pèce de tueur en série !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:91 +msgid "{ce}The health of {0} was not updated to avoid a kill." +msgstr "{ce}La vie de {0} n'a pas été changée, pour ne pas le/la tuer." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:107 +msgid "The health of all players was completely filled." +msgstr "La vie de l'ensemble des joueurs a été régénérée." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:111 +#, java-format +msgid "The health of all players was set to {0}." +msgstr "La vie de l'ensemble des joueurs a été mise à {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:116 +#, java-format +msgid "The health of all players was increased by {0}." +msgstr "La vie de l'ensemble des joueurs a été augmentée de {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java:120 +#, java-format +msgid "The health of all players was decreased by {0}." +msgstr "La vie de l'ensemble des joueurs a été diminuée de {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java:55 +msgid "A player is required" +msgstr "Un joueur est requis" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java:93 +msgid "{ce}You can't kill a player with this command, to avoid typo fails." +msgstr "" +"{ce}Vous ne pouvez pas tuer un joueur avec cette commande, pour éviter toute " +"faute de frappe." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java:106 +#, java-format +msgid "The health of {0} was set to {1}." +msgstr "La vie de {0} a été mise à {1}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java:61 +msgid "{ce}No death location available for the player {0}." +msgstr "{ce}Pas de localisation de mort enregistrée pour le joueur {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java:69 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java:73 +msgid "{cs}The player {0} was teleported back." +msgstr "{cs}Le joueur {0} a été téléporté là où il est mort." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java:77 +msgid "" +"{ce}The player {0} was NOT teleported back because no safe spot was found." +msgstr "" +"{ce}Le joueur {0} n'a PAS été téléporté car aucun point de téléportation sûr " +"n'a été trouvé." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java:78 +msgid "" +"{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this " +"point." +msgstr "" +"{ci}Utilisez {cc}/uh tpback {0} force{ci} pour le téléporter malgré tout." + +#. / {0}: world name. {1-3}: x, y, z. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java:74 +#, java-format +msgid "All spectators were teleported to ({0} ; {1} ; {2} ; {3})." +msgstr "Tous les spectateurs ont été téléportés en ({0} ; {1} ; {2} ; {3})." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java:78 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java:87 +msgid "{ce}The coordinates must be three valid numbers." +msgstr "{ce}Les coordonnées doivent être trois nombres." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java:91 +#, java-format +msgid "All spectators were teleported to the player {0}." +msgstr "Tous les spectateurs ont été téléportés sur {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java:94 +msgid "You must specify either three coordinates or a player name." +msgstr "Vous devez spécifier ou bien trois coordonnées, ou un joueur." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:61 +msgid "" +"{ce}The spawn points are not already assigned to the player, because the " +"game is not started." +msgstr "" +"{ce}Les points de démarrage n'ont pas encore été assignés aux joueurs, car " +"le jeu n'a pas encore démarré." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:71 +msgid "{ce}No spawn location available for the player {0}." +msgstr "{ce}Pas de localisation de démarrage enregistrée pour le joueur {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:78 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:82 +msgid "{cs}The player {0} was teleported to his spawn location." +msgstr "{cs}Le joueur {0} a été téléporté à son point de démarrage attribué." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:86 +msgid "" +"{ce}The player {0} was NOT teleported to his spawn because no safe spot was " +"found." +msgstr "" +"{ce}Le joueur {0} n'a PAS été téléporté car aucun point de téléportation sûr " +"n'a été trouvé." -#: src/main/java/eu/carrade/amaury/UHCReloaded/borders/BorderManager.java:432 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java:87 msgid "" -"{gray}It will shrink by one block every {0} second(s) until {1} blocks in " -"diameter." +"{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this " +"point." msgstr "" -"{gray}Elle réduira d'un bloc toutes les {0} seconde(s) jusqu'à atteindre {1} " -"blocs de diamètre." +"{ci}Utilisez {cc}/uh tpspawn {0} force{ci} pour le téléporter malgré tout." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:42 -msgctxt "protip" -msgid "{gray}You can lock and unlock the team chat with {cc}/togglechat{gray}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java:77 +#, java-format +msgid "" +"The players in the team {0} ({1}) were teleported to ({2} ; {3} ; {4} ; {5})." msgstr "" -"{gray}Verrouillez le chat d'équipe avec {cc}/togglechat{gray}, qui permet de " -"passer d'un chat à l'autre." +"Les joueurs de l'équipe {0} ({1}) ont été téléportés en ({2} ; {3} ; {4} ; " +"{5})." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:43 -msgctxt "protip" -msgid "{gray}You can send a global message using {cc}/g <message>{gray}." -msgstr "" -"{gray}Vous pouvez envoyer un message à tout le monde avec {cc}/g " -"<message>{gray}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java:99 +msgid "{ce}This team is not registered." +msgstr "{ce}Cette équipe n'est pas enregistrée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:44 -msgctxt "protip" -msgid "{gray}You can send a team-chat message with {cc}/t <message>{gray}." -msgstr "" -"{gray}Vous pouvez envoyer un message à votre équipe avec {cc}/t " -"<message>{gray}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java:108 +#, java-format +msgid "The players in the team {0} ({1}) were teleported to the player {2}." +msgstr "Les joueurs de l'équipe {0} ({1} ont été téléportés sur {2}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:46 -msgctxt "protip" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java:62 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java:75 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java:65 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java:78 msgid "" -"{gray}You can craft golden apples with heads (same recipe with a head " -"instead of an apple)." +"{ce}Food points and saturation must be numbers (floats for the saturation)!" msgstr "" -"{gray}Vous pouvez fabriquer des pommes d'or avec les têtes (même recette " -"avec une tête à la place de la pomme)." +"{ce}Les valeurs de faim et de saturation doivent être des nombres " +"(possiblement à virgule pour la saturation) !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:47 -msgctxt "protip" -msgid "" -"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " -"spider eye and a gunpowder." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java:86 +#, java-format +msgid "Set food level to {0} and saturation to {1} for every player." msgstr "" -"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " -"zombie, un œil d'araignée et une poudre à canon." +"Les niveaux de faim et de saturation ont été configurés à respectivement {0} " +"et {1} pour l'ensemble des joueurs." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:48 -msgctxt "protip" -msgid "" -"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " -"spider eye and a gunpowder; in the center, an ender pearl." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java:86 +#, java-format +msgid "Set food level to {0} and saturation to {1} for {2}." msgstr "" -"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " -"zombie, un œil d'araignée et une poudre à canon ; au centre une Perle du " -"Néant." +"Les niveaux de faim et de saturation ont été configurés à respectivement {0} " +"et {1} pour {2}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:49 -msgctxt "protip" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java:92 +#, java-format +msgid "{0} died, following a game master's order." +msgstr "{0} est mort, par volonté d'un maître du jeu." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java:125 +#, java-format +msgid "{0}The team {1} has fallen!" +msgstr "{0}L'équipe {1} est vaincue !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java:54 msgid "" -"{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a " -"spider eye and a gunpowder; in the center, an Eye of Ender." +"{ce}You can't shift the current episode because the game is not started." msgstr "" -"{gray}La boussole se fabrique avec dans les coins un os, une chaire de " -"zombie, un œil d'araignée et une poudre à canon ; au centre un Œil du Néant." +"{ce}Vous ne pouvez pas passer l'épisode actuel car le jeu n'a pas démarré." -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:50 -msgctxt "protip" -msgid "{gray}The glistering melon is crafted with a melon and a gold block." -msgstr "" -"{gray}La pastèque scintillante se fabrique avec une pastèque et un bloc d'or." +#. / Current episode in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java:102 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:142 +msgid "{gray}Episode {white}{0}" +msgstr "{gray}Épisode {white}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:52 -msgctxt "protip" -msgid "{gray}The enchanted golden apple is disabled for this game." -msgstr "{gray}La pomme d'or enchantée est désactivée pour cette partie." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java:124 +msgid "the console" +msgstr "la console" -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java:54 -msgctxt "protip" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java:236 +msgid "Alone" +msgstr "Seul" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java:56 msgid "" -"{gray}Fallen on a tree? Jump, you have a few seconds left to remain " -"invincible." +"Invalid command usage. But, you shouldn't use this command directly. What " +"are you doing?" msgstr "" -"{gray}Tombé(e) sur un arbre ? Sautez, il vous reste quelques dizaines de " -"secondes d'invincibilité." - -#. ProTip invite, displayed before a ProTip. -#: src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTip.java:132 -msgid "{darkpurple}ProTip!" -msgstr "{darkpurple}Astuce !" +"Utilisation invalide de cette commande. Mais, vous ne devriez pas vous en " +"servir directement. Que faites-vous donc ?" -#: src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java:209 -msgid "Ultra Hardcore plugin loaded." -msgstr "Plugin Ultra Hardcore chargé." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java:77 +msgid "You weren't asked for your opinion regarding this request." +msgstr "Votre opinion n'a jamais été demandée concernant cette requête." -#. Title of the item displayed if a team was deleted while someone edited it in a GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java:70 -msgid "{red}Team deleted" -msgstr "{red}Équipe supprimée." - -#. Lore of the item displayed if a team was deleted while someone edited it in a GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java:72 -msgid "{gray}The team {0}{gray} was deleted by another player." -msgstr "{gray}L'équipe {0}{gray} a été supprimée par un autre joueur." - -#. Lore of the item displayed if a team was deleted while someone edited it in a GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java:75 -msgid "{gray}Press {white}Escape{gray} to go back to the teams list." -msgstr "" -"{gray}Appuyez sur {white}Échap{gray} pour retourner à la liste des équipes." - -#. The title of the delete team GUI. {0} = team name (raw). -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java:58 -msgid "{0} » {darkred}Delete" -msgstr "{0} » {darkred}Supprimer" - -#. The title of the "keep" button in the delete team GUI -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java:72 -msgid "{green}Keep this team alive" -msgstr "{green}Garder cette équipe en vie" - -#. The title of the "delete" button in the delete team GUI -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java:84 -msgid "{red}Delete this team {italic}forever" -msgstr "{red}Supprimer cette équipe {italic}pour l'éternité" - -#. The title of the edit team members GUI. {0} = team name (raw). -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:67 -msgid "{0} » {black}Members" -msgstr "{0} » {black}Membres" - -#. Go back button in GUIs. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:76 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:131 -msgid "{green}« Go back" -msgstr "{green}« Retour" - -#. The title of a button to select a player (a skull button). {0} = player's display name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:93 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:135 -msgid "{reset}{0}" -msgstr "{reset}{0}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:95 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:137 -msgid "{gray}Online" -msgstr "{gray}En ligne" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:95 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:137 -msgid "{gray}Offline" -msgstr "{gray}Hors ligne" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:96 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:138 -msgid "{gray}Current team: {0}" -msgstr "{gray}Équipe : {0}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:96 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:138 -msgid "{gray}Current team: none" -msgstr "{gray}Équipe : aucune" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:98 -msgid "{darkgray}» {white}Click {gray}to remove this player" -msgstr "{darkgray}» {white}Cliquez {gray}pour retirer ce joueur" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditMembersGUI.java:98 -msgid "{darkgray}» {white}Click {gray}to add this player" -msgstr "{darkgray}» {white}Cliquez {gray}pour ajouter ce joueur" - -#. The title of the edit team color GUI. {0} = team name (raw). -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditColorGUI.java:54 -msgid "{0} » {black}Color" -msgstr "{0} » {black}Couleur" - -#. The title of the edit team GUI. {0} = team display name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:66 -msgid "Teams » {black}{0}" -msgstr "Équipes » {black}{0}" - -#. Members count in the banner description, in the team edit GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:79 -msgid "{white}{0} {gray}member" -msgid_plural "{white}{0} {gray}members" -msgstr[0] "{white}{0} {gray}membre" -msgstr[1] "{white}{0} {gray}membres" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:81 -msgid "{white}Click with a banner {gray}to update this team's banner" -msgstr "" -"{white}Cliquez avec une bannière {gray}pour changer la bannière de l'équipe" - -#. Update team color button in edit GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:89 -msgid "{green}Update the color" -msgstr "{green}Changer la couleur" - -#. Current team color in edit GUI. {0} = formatted color name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:91 -msgctxt "current_team_color" -msgid "{gray}Current: {white}{0}" -msgstr "{gray}Actuelle : {white}{0}" - -#. Rename team button in edit GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:98 -msgid "{green}Rename the team" -msgstr "{green}Renommer l'équipe" - -#. Current team name in edit GUI. {0} = raw team name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:100 -msgctxt "current_team_name" -msgid "{gray}Current: {white}{0}" -msgstr "{gray}Actuel : {white}{0}" - -#. Online status dot in /uh infos -#. Online dot in /uh team list -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:107 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:92 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:149 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:83 -msgid "{green} • " -msgstr "{green} • " +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java:80 +msgid "This request has expired." +msgstr "Cette requête a expiré." -#. Offline status dot in /uh infos -#. Offline dot in /uh team list -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:109 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:98 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:153 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:88 -msgid "{red} • " -msgstr "{red} • " +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:65 +msgid "You must provide a player name." +msgstr "Vous devez spécifier un nom de joueur." -#. Update team members button in edit GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:114 -msgid "{green}Add or remove players" -msgstr "{green}Modifier les membres" - -#. Delete team button in edit GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:122 -msgid "{red}Delete this team" -msgstr "{red}Supprimer cette équipe" - -#. Warning under the "delete team" button title. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditGUI.java:124 -msgid "{gray}Cannot be undone" -msgstr "{gray}Non annulable" - -#. The title of the teams selector GUI. {0} = teams count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:75 -msgid "{black}Select a team {reset}({0})" -msgstr "{black}Sélectionnez votre équipe {reset}({0})" - -#. The title of a button to rename our team, in the selector GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:87 -msgid "{white}Rename your team" -msgstr "{white}Renommer votre équipe" - -#. Warning displayed in the "Rename your team" button, if the player is not in a team -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:89 -msgid "{gray}You have to be in a team" -msgstr "{gray}Vous devez être dans une équipe" - -#. The title of a button to create a new team, in the selector GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:98 -msgid "{white}New team" -msgstr "{white}Nouvelle équipe" - -#. The "Players" title in the selector GUI, on a team's tooltip -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:116 -msgid "{blue}Players" -msgstr "{blue}Joueurs" - -#. An item of the players list in the selector GUI, on a team's tooltip -#. A member bullet in the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:120 -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:118 -msgid "{darkgray}- {white}{0}" -msgstr "{darkgray}- {white}{0}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:130 -msgid "{darkgray}» {white}Click {gray}to join this team" -msgstr "{darkgray}» {white}Cliquez {gray}pour rejoindre l'équipe" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:134 -msgid "{darkgray}» {red}This team is full" -msgstr "{darkgray}» {red}Cette équipe est pleine" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:139 -msgid "{darkgray}» {white}Click {gray}to leave this team" -msgstr "{darkgray}» {white}Cliquez {gray}pour quitter l'équipe" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:144 -msgid "{darkgray}» {white}Right-click {gray}to manage this team" -msgstr "{darkgray}» {white}Cliquez droit {gray}pour gérer cette équipe" - -#. Title of the team item in the teams selector GUI (with max). {0}: team display name. {1}: players count. {2}: max count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:182 -msgid "{white}Team {0} {gray}({1}/{2})" -msgstr "{white}Équipe {0} {gray}({1}/{2})" - -#. Title of the team item in the teams selector GUI (without max) {0}: team display name. {1}: players count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:184 -msgid "{white}Team {0} {gray}({1} player)" -msgid_plural "{white}Team {0} {gray}({1} players)" -msgstr[0] "{white}Équipe {0} {gray}({1} joueur)" -msgstr[1] "{white}Équipe {0} {gray}({1} joueurs)" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:198 -msgid "{red}No team created" -msgstr "{cs}Aucune équipe créée" - -#. Subtitle of the item displayed in the teams selector GUI if there isn't anything to display. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:201 -msgid "{gray}Click the emerald button below to create one." -msgstr "{gray}Cliquez sur le bouton d'émeraude ci-dessous pour en créer une." - -#. Subtitle of the item displayed in the teams selector GUI if there isn't anything to display and the player cannot create a team. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/TeamsSelectorGUI.java:203 -msgid "{gray}Wait for an administrator to create one." -msgstr "{gray}Patientez le temps qu'un administrateur en ajoute une." - -#. The title of the first step in the team creator GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java:109 -msgid "{gray}1. {white}{bold}Team color" -msgstr "{gray}1. {white}{bold}Couleur de l'équipe" - -#. The title of the second step in the team creator GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java:111 -msgid "{gray}2. {white}{bold}Team name" -msgstr "{gray}2. {white}{bold}Nom de l'équipe" - -#. The title of the third step in the team creator GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderBaseGUI.java:113 -msgid "{gray}3. {white}{bold}Team members" -msgstr "{gray}3. {white}{bold}Membres de l'équipe" - -#. The title of the name selector GUI, in the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java:57 -msgid "New team » {black}Name" -msgstr "Nouvelle équipe » {black}Nom" - -#. The title of the button opening the sign to write the team name (creator GUIs) -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java:65 -msgid "{white}Name the team" -msgstr "{white}Nommer l'équipe" - -#. The legend of the button opening the sign to write the team name (creator GUIs) -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java:67 -msgid "" -"{gray}When clicked, a sign will open; write the name of the team inside." -msgstr "" -"{gray}Cliquez ici pour ouvrir un panneau, et écrivez le nom de l'équipe " -"dedans." - -#. The title of the color selector GUI, in the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepColorGUI.java:61 -msgid "New team » {black}Color" -msgstr "Nouvelle équipe » {black}Couleur" - -#. The random color button in a colors selector GUI. -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepColorGUI.java:74 -msgid "{lightpurple}Random color" -msgstr "{lightpurple}Couleur aléatoire" - -#. The title of the members selector GUI, in the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:80 -msgid "New team » {black}Members" -msgstr "Nouvelle équipe » {black}Membres" - -#. The summary title in the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:106 -msgid "{blue}{bold}Summary" -msgstr "{blue}{bold}Récapitulatif" - -#. The team name in the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:108 -msgid "{gray}Team name: {white}{0}" -msgstr "{gray}Nom : {white}{0}" - -#. The team color in the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:110 -msgid "{gray}Color: {0}" -msgstr "{gray}Couleur : {0}" - -#. The team members count in the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:112 -msgid "{gray}Members: {white}{0}" -msgstr "{gray}Membres : {white}{0}" - -#. The title of the final « create the team » button of the create team GUIs -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:122 -msgid "{green}Create the team" -msgstr "{green}Créer l'équipe" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:140 -msgid "{lightpurple}Selected!" -msgstr "{lightpurple}Ajouté !" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:140 -msgid "{darkgray}» {white}Click {gray}to add to the team" -msgstr "{darkgray}» {white}Cliquez {gray}pour l'ajouter à l'équipe" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:170 -msgid "{cs}Team created." -msgstr "{cs}Équipe créée." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepPlayersGUI.java:176 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:89 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:117 -msgid "{ce}This team already exists." -msgstr "{ce}Cette équipe existe déjà." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java:148 -msgid "{cs}Your team is now called {0}{cs}." -msgstr "{cs}Votre équipe s'appelle désormais {0}{cs}." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java:321 -msgid "{aqua}You are now in the {0}{aqua} team." -msgstr "{aqua}Vous faites désormais partie de l'équipe {0}{aqua}." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/UHTeam.java:374 -msgid "{darkaqua}You are no longer part of the {0}{darkaqua} team." -msgstr "{darkaqua}Vous ne faites plus partie de l'équipe {0}{darkaqua}." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:85 -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:212 -msgid "{ce}You are not allowed to send a private message to your team." -msgstr "" -"{ce}Vous n'avez pas le droit d'envoyer des messages privés à votre équipe." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:90 -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:217 -msgid "{ce}You are not allowed to enter in the private chat of another team." -msgstr "" -"{ce}Vous n'avez pas le droit d'entrer dans le chat privé d'une autre équipe." - -#. Format of a private team message from a team member. {0} = sender display name, {1} = message. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:100 -msgid "{gold}[{0}{gold} -> his team] {reset}{1}" -msgstr "{gold}[{0}{gold} -> son équipe] {reset}{1}" - -#. Error message if someone try to send a team private message out of any team -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:106 -msgid "{ce}You are not in a team!" -msgstr "{ce}Vous n'êtes pas dans une équipe !" - -#. Format of a private team message from a non-team-member. {0} = sender display name, {1} = team display name, {2} = message. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamChatManager.java:113 -msgid "{gold}[{0}{gold} -> team {1}{gold}] {reset}{2}" -msgstr "{gold}[{0}{gold} -> équipe {1}{gold}] {reset}{2}" - -#. Invite displayed in the chat team selector -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:514 -msgid "{gold}Click on the names below to join a team" -msgstr "{gold}Cliquez ci-dessous pour rejoindre une équipe" - -#. Displayed in team tooltip of the chat team selector for a dead player -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:535 -msgid "{0} ({red}dead{reset})" -msgstr "{0} ({red}mort{reset})" - -#. Displayed in team tooltip of the chat team selector for an alive player -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:540 -msgid "{0} ({green}alive{reset})" -msgstr "{0} ({green}en vie{reset})" - -#. Team count with max players (ex. [3/5]) followed in-game by the team name. {0} = current count, {1} = max. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:550 -msgid "{gray}[{white}{0}{gray}/{white}{1}{gray}]" -msgstr "{gray}[{white}{0}{gray}/{white}{1}{gray}]" - -#. Team count without max players (ex. [3]) followed in-game by the team name. {0} = current count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:552 -msgid "{gray}[{white}{0}{gray}]" -msgstr "{gray}[{white}{0}{gray}]" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:554 -#, java-format -msgid "{0} player in this team" -msgid_plural "{0} players in this team" -msgstr[0] "{0} joueur dans cette équipe" -msgstr[1] "{0} joueurs dans cette équipe" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:74 +msgid "You cannot create an alliance with yourself." +msgstr "Vous ne pouvez créer une alliance avec vous-même." -#. Tooltip on the chat team selector GUI when the player is in the team. {0} = team display name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:565 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:78 #, java-format -msgid "You are in the team {0}" -msgstr "Vous êtes dans l'équipe {0}" +msgid "" +"You already have an ongoing alliance request sent to {0}. Please be patient!" +msgstr "Vous avez déjà envoyé une requête d'alliance à {0}. Soyez patient !" -#. Tooltip on the chat team selector GUI when the player is not in the team. {0} = team display name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:567 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:91 #, java-format -msgid "Click here to join the team {0}" -msgstr "Cliquez ici pour rejoindre l'équipe {0}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:577 -msgid "{darkred}[×] {red}Click here to leave your team" -msgstr "{darkred}[×] {red}Cliquez ici pour quitter votre équipe" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:582 -msgid "{gray}Run /join to display this again" -msgstr "{gray}Exécutez /join pour réafficher ceci" +msgid "{0} is too far. You must be within {1} blocks of each other." +msgstr "" +"{0} est trop éloigné. Vous devez être à moins de {1} blocs l'un⋅e de l'autre." -#. No teams. -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:588 -msgid "{ce}There isn't any team available." -msgstr "{ce}Il n'y a aucune équipe disponible." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:95 +msgid "You can no longer join an alliance." +msgstr "Vous ne pouvez plus rejoindre d'alliance." -#: src/main/java/eu/carrade/amaury/UHCReloaded/teams/TeamManager.java:621 -msgid "{gold}Your team: {0}" -msgstr "{gold}Votre équipe : {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:102 +msgid "" +"{gray}{bold}{0} just sent you an alliance request, but you cannot accept it " +"because you have no alliance left." +msgstr "" +"{gray}{bold}{0} vient de vous envoyer une requête d'alliance, mais vous ne " +"pouvez l'accepter car vous n'avez plus d'alliances disponibles." -#. The kick message of a player when death.kick.do = true in config -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:158 -msgid "jayjay" -msgstr "jayjay" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:103 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:119 +msgid "" +"{gray}{0} is not aware of this, but I preferred to warn you so that you " +"would not be caught off guard if he or she mentions it." +msgstr "" +"{gray}{0} l'ignore, mais je préfère vous prévenir afin que vous puissiez " +"réagir convenablement s'il ou elle le mentionne." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:236 -#, java-format -msgid "{0}The team {1} has fallen!" -msgstr "{0}L'équipe {1} est vaincue !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:118 +msgid "" +"{gray}{bold}{0} just sent you an alliance request, but you cannot accept it " +"because your alliance is already at full capacity." +msgstr "" +"{gray}{bold}{0} vient de vous envoyer une requête d'alliance, mais vous ne " +"pouvez l'accepter car votre alliance est pleine." -#. A message displayed to the players under the death screen, about the respawn possibility even if the death screen says the opposite (in hardcore mode) -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:280 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:125 msgid "" -"{darkpurple}{obfuscated}----{lightpurple}{italic} YOU CAN " -"RESPAWN{lightpurple}, just click {italic}Respawn {lightpurple}on the next " -"screen." +"You cannot send a request alliance as your alliance is already at full " +"capacity. Don't be too greedy!" msgstr "" -"{darkpurple}{obfuscated}----{lightpurple}{italic} VOUS POUVEZ " -"REVENIR{lightpurple}, cliquez sur {italic}Ressusciter {lightpurple}sur " -"l'écran suivant." +"Vous ne pouvez envoyer une requête car votre alliance est déjà pleine. Ne " +"soyez pas trop gourmand !" -#. The kick message displayed if a player tries to relog after his death and it's forbidden by the config. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:385 -msgid "You are dead!" -msgstr "Vous êtes mort !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:136 +msgid "You're already allied with {0}!" +msgstr "Vous êtes déjà allié avec {0} !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:140 +msgid "You cannot create this alliance as it would end the game." +msgstr "Vous ne pouvez créer cette alliance, car cela terminerait le jeu." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:458 -msgid "{darkred}[UHC] {ce}WorldBorder is not installed: no borders' check!" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:162 +msgid "{bold}Your request has been sent to {0}." +msgstr "{bold}Votre requête a été envoyée à {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java:163 +msgid "Wait until it is accepted. Let's hope you don't hear only silence..." msgstr "" -"{darkred}[UHC] {ce}WorldBorder pas installé : bordures non surveillées !" +"Patientez le temps qu'elle soit acceptée. Espérons que vous n'entendrez pas " +"uniquement le bruit du silence..." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:198 +msgid "{green}{bold}{0} would like to join you in an alliance." +msgstr "{green}{bold}{0} aimerait s'allier avec vous." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:459 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:202 msgid "" -"{gray}Also, without WorldBorder, the border can't be reduced during the game " -"(warnings excluded)." +"{gray}This request was sent to {0}, but everyone in the alliance also need " +"to accept." msgstr "" -"{gray}Aussi, sans WorldBorder, impossible de réduire la bordure pendant le " -"jeu (sauf avertissements)." +"{gray}Cette requête a été envoyée à {0}, mais l'ensemble des membres de " +"l'alliance doivent également l'accepter." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:460 -msgid "" -"{gray}Just install the plugin; UHPlugin will automatically configure it." -msgstr "{gray}Installez le plugin ; UHPlugin va automatiquement le configurer." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:208 +msgid "{darkgreen}{bold}» {green}{bold}Accept {darkgreen}{bold}«" +msgstr "{darkgreen}{bold}» {green}{bold}Accepter {darkgreen}{bold}«" -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:470 -msgid "{darkred}[UHC] {ce}ProtocolLib is needed but not installed!" -msgstr "{darkred}[UHC] {ce}ProtocolLib est requis mais non installé !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:210 +msgid "{green}{bold}Accept {green}this alliance" +msgstr "{green}{bold}Accepter {green}cette alliance" -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:471 -msgid "{gray}The following options require the presence of ProtocolLib:" -msgstr "{gray}Les options suivantes requièrent la présence de ProtocolLib :" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:212 +msgid "{darkred}{bold}» {red}{bold}Decline {darkred}{bold}«" +msgstr "{darkred}{bold}» {red}{bold}Refuser {darkred}{bold}«" -#. An option requiring ProtocolLib, in the “missing PLib” message. {0} = option path. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:475 -msgctxt "protocollib_option" -msgid "{darkgray} - {gray}{0}" -msgstr "{darkgray} - {gray}{0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:214 +msgid "{red}{bold}Decline {red}this alliance" +msgstr "{red}{bold}Refuser {red}cette alliance" -#. {0} = ProtocolLib download URL for the current Minecraft version. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:488 -msgid "{gray}ProtocolLib is available here: {0}" -msgstr "{gray}ProtocolLib est disponible ici : {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:248 +msgid "{gray}Still waiting for {0}'s answer." +msgid_plural "{gray}Still waiting for answers from: {0}." +msgstr[0] "{gray}Nous attendons toujours la réponse de {0}." +msgstr[1] "{gray}Nous attendons toujours la réponse de ces joueurs : {0}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:607 -msgid "{cs}The timer before the new border is up!" -msgstr "{cs}Le temps imparti avant la nouvelle bordure est écoulé !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:262 +#, java-format +msgid "You accepted the request for an alliance with {0}." +msgstr "Vous avez accepté la requête d'alliance avec {0}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:639 -msgid "{aqua}-------- End of episode {0} [forced by {1}] --------" -msgstr "{aqua}-------- Fin de l'épisode {0} [forcé par {1}] --------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:293 +msgid "{green}The request for an alliance with {0} was accepted by {1}." +msgstr "{green}La requête d'alliance avec {0} a été acceptée par {1}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:643 -msgid "{aqua}-------- End of episode {0} --------" -msgstr "{aqua}-------- Fin de l'épisode {0} --------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:339 +msgid "{red}The alliance with {0} was {bold}denied{red} by {1}." +msgstr "{red}La requête d'alliance avec {0} a été {bold}refusée{red} par {1}." -#. The title displayed when the episode change. {0} = new episode number; {1} = old. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:655 -msgid "{darkaqua}Episode {aqua}{0}" -msgstr "{darkaqua}Épisode {aqua}{0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:347 +msgid "{red}You declined {0}'s alliance request." +msgstr "{red}Vous avez refusé la requête d'alliance de {0}." -#. Broadcast -#. Start message broadcasted in chat -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:679 -msgid "{green}--- GO ---" -msgstr "{green}--- GO ---" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:369 +msgid "{ce}This alliance request is no longer valid. Please re-send it." +msgstr "" +"{ce}Cette requête d'alliance n'est plus valide. Merci de la ré-envoyer." -#. Title of title displayed when the game starts. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:687 -msgid "{darkgreen}Let's go!" -msgstr "{darkgreen}C'est parti !" +#. We create a new team for this new alliance. Old teams are dropped. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:376 +msgid "Your alliance" +msgstr "Votre alliance" -#. Subtitle of title displayed when the game starts. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:689 -msgid "{green}Good luck, and have fun" -msgstr "{green}Bonne chance et bon jeu à tous" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:410 +msgid "{green}{bold}You are now allied with {0}!" +msgstr "{green}{bold}Vous êtes désormais allié avec {0} !" -#. All players are notified -#. Resurrection notification. {0} = raw resurrected player name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameListener.java:821 -msgid "{gold}{0} returned from the dead!" -msgstr "{gold}{0} est revenu d'entre les morts !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:411 +msgid "" +"{green}Your objective is to win together. But chhhh! Other players are not " +"aware of your alliance..." +msgstr "" +"{green}Votre objectif est de gagner ensemble. Mais chhhh ! Les autres " +"joueurs ignorent que vous êtes alliés..." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:415 +msgid "{green}{bold}The alliance expands!" +msgstr "{green}{bold}L'alliance s'agrandit !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:416 +msgid "{gray}Players in the alliance: {0}" +msgstr "{gray}Joueurs dans l'alliance : {0}" -#. The title of the item given before the game to select a team -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/BeforeGameListener.java:110 +#. / The title of the item given before the game to select a team +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java:144 msgid "{green}{bold}Select a team {gray}(Right-Click)" msgstr "{green}{bold}Choisir une équipe {gray}(Clic droit)" -#. The lore of the item given before the game to select a team -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/BeforeGameListener.java:112 +#. / The lore of the item given before the game to select a team +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java:146 msgid "{gray}Right-click to select your team for this game" -msgstr "{gray}Cliquez-droit pour sélectionner votre équipe pour ce jeu." +msgstr "{gray}Cliquez-droit pour sélectionner votre équipe pour ce jeu" -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:201 -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/CraftingListener.java:285 -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java:178 +msgid "{gold}Your team: {0}" +msgstr "{gold}Votre équipe : {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:202 -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/CraftingListener.java:286 -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java:63 +msgid "{ce}You are currently out of the future border (diameter of {0} block)." +msgid_plural "" +"{ce}You are currently out of the future border (diameter of {0} blocks)." +msgstr[0] "{ce}Vous êtes hors de la future bordure de {0} bloc de diamètre." +msgstr[1] "{ce}Vous êtes hors de la future bordure de {0} blocs de diamètre." -#. Error message if a player tries to use his pointing compass without rotten flesh. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:305 -msgid "{gray}{italic}You do not have rotten flesh." -msgstr "{gray}{italic}Vous n'avez pas de chair de zombie." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java:67 +msgid "{ce}You are currently out of the future border of {0}×{0} blocks." +msgstr "{ce}Vous êtes hors de la future bordure de {0}×{0} blocs." -#. Error message if a player tries to use his pointing compass without a player nearby. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:336 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}Seul le silence comble votre requête." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java:70 +msgid "{ci}You have {0} block to go before being inside." +msgid_plural "{ci}You have {0} blocks to go before being inside." +msgstr[0] "{ci}Il vous reste {0} blocs à parcourir avant d'y être." +msgstr[1] "{ci}Il vous reste {0} bloc à parcourir avant d'y être." -#. Success message when a player uses his pointing compass. -#: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:343 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}Le compas pointe désormais vers le joueur le plus proche." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java:60 +msgid "Missing future border size." +msgstr "La future taille de la bordure est manquante." -#. Dynmap marker label of a death point -#: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:153 -#, java-format -msgid "Death point of {0}" -msgstr "Ici disparu {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java:67 +msgid "{cs}Warning canceled." +msgstr "{cs}Avertissement annulé." -#. Dynmap marker label of a spawn point of a team. -#: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:232 -#, java-format -msgid "Spawn point of the team {0}" -msgstr "Lieu de démarrage de l'équipe {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java:87 +msgid "" +"{cs}Future size saved. All players outside this future border will be warned " +"every {0} second." +msgid_plural "" +"{cs}Future size saved. All players outside this future border will be warned " +"every {0} seconds." +msgstr[0] "" +"{cs}Future taille enregistrée. Les joueurs hors de la bordure vont être " +"avertis toutes les {0} seconde." +msgstr[1] "" +"{cs}Future taille enregistrée. Les joueurs hors de la bordure vont être " +"avertis toutes les {0} secondes." -#. Dynmap marker label of a spawn point of a player, in solo. -#. Dynmap marker label of a spawn point of a player, when the teleportation ignores the teams. -#: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:237 -#: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:294 -#, java-format -msgid "Spawn point of {0}" -msgstr "Lieu de démarrage de {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java:92 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java:60 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:107 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:131 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:152 +msgid "{ce}“{0}” is not a number..." +msgstr "{ce}“{0}” n'est pas un nombre..." -#. Golden head lore for withers -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:280 -msgid "Made from the fallen head of a malignant monster" -msgstr "Fabriquée depuis la tête tranchée d'un monstre maléfique" +#. / The name of the warning timer displaying the time left before the next border +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java:75 +msgid "Border shrinking" +msgstr "Réduction de la bordure" -#. Golden head lore for players. {0} = player name. -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:285 -#, java-format -msgid "Made from the fallen head of {0}" -msgstr "Fabriquée depuis la tête tranchée de {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java:52 +msgid "{cst}Generating the walls..." +msgstr "{cst}Génération des murs en cours..." -#. Item name of a golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:388 -msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java:67 +msgid "{ci}From the console, generating the walls of the default world, {0}" +msgstr "{ci}Depuis la console, génération du mur du monde par défaut, {0}" -#. Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:394 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java:76 +msgid "" +"{ce}Unable to generate the wall: see logs for details. The blocks set in the " +"config are probably invalid." +msgstr "" +"{ce}Impossible de générer le mur: voir logs pour plus de détails. Les blocs " +"configurés sont probablement invalide." -#. Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:421 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java:82 +msgid "{ce}An error occurred, see console for details." +msgstr "" +"{ce}Une erreur s'est produite, consultez la console pour plus de détails." -#. Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:427 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java:87 +msgid "{cst}Generation done." +msgstr "{cst}Génération terminée." -#. Current episode in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:140 -msgid "{gray}Episode {white}{0}" -msgstr "{gray}Épisode {white}{0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java:51 +msgid "You must provide a check radius." +msgstr "Vous devez spécifier un rayon de vérification." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java:88 +msgid "{green}Grace period {gray}-{green} All damages are disabled" +msgstr "{green}Période de grâce {gray}-{green} Tous les dégâts sont désactivés" -#. Players alive in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:149 -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:158 +#. / Players alive in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:172 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:151 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:160 msgid "{white}{0}{gray} player" msgid_plural "{white}{0}{gray} players" msgstr[0] "{white}{0}{gray} joueur" msgstr[1] "{white}{0}{gray} joueurs" -#. Teams alive in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:162 +#. / Teams alive in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:179 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:164 msgid "{white}{0}{gray} team" msgid_plural "{white}{0}{gray} teams" msgstr[0] "{white}{0}{gray} équipe" msgstr[1] "{white}{0}{gray} équipes" -#. Title of the team section in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:207 -msgid "{bold}Your team" -msgstr "{bold}Votre équipe" - -#. Kills count in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:280 -msgid "{white}{0}{gray} player killed" -msgid_plural "{white}{0}{gray} players killed" -msgstr[0] "{white}{0}{gray} joueur tué" -msgstr[1] "{white}{0}{gray} joueurs tués" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:189 +msgid "{gray}Waiting for players..." +msgstr "{gray}En attente de joueurs..." -#. Title of the border section in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:311 -msgid "{blue}{bold}Border" -msgstr "{blue}{bold}Bordure" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:196 +msgid "{gray}The game is starting..." +msgstr "{gray}Le jeu démarre..." -#. Border diameter for a squared map in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:319 -msgid "{white}{0} block wide" -msgid_plural "{white}{0} blocks wide" -msgstr[0] "{white}{0} bloc de large" -msgstr[1] "{white}{0} blocs de large" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:197 +msgid "{gray}Please wait." +msgstr "{gray}Veuillez patienter." -#. Border diameter for a circular map in the sidebar -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:322 -msgid "{gray}Diameter: {white}{0} block" -msgid_plural "{gray}Diameter: {white}{0} blocks" -msgstr[0] "{gray}Diamètre : {white}{0} bloc" -msgstr[1] "{gray}Diamètre : {white}{0} blocs" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:562 +msgid "{ce}Unable to start the game: not enough teleportation spots." +msgstr "{ce}Impossible de démarrer : pas assez de points de téléportation." -#. Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:338 -msgid "{white}{0} {1}" -msgstr "{white}{0} {1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:563 +msgid "" +"{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to " +"generate the missing spawns automatically." +msgstr "" +"{ci}Vous pouvez utiliser {cc}/uh spawns generate <random|circular|grid>{ci} " +"pour automatiquement générer les points de téléportation manquant." -#. Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:343 -msgid "{gray}X: {white}{0} {1}" -msgstr "{gray}X: {white}{0} {1}" +#. / In the sentence: "Or click here to generate the spawns randomly." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:566 +msgid "Or" +msgstr "Ou" -#. Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:345 -msgid "{gray}Z: {white}{0} {1}" -msgstr "{gray}Z: {white}{0} {1}" +#. / In the sentence: "Or click here to generate the spawns randomly." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:569 +msgid "click here" +msgstr "cliquez ici" -#. Notice displayed at the bottom of the sidebar if the game is paused (/uh freeze all). -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:386 -msgid "{darkaqua}Game frozen" -msgstr "{darkaqua}En pause" +#. / In the sentence: "Or click here to generate the spawns randomly." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:575 +msgid "to generate the spawns randomly." +msgstr "afin de générer les points de démarrage aléatoirement." -#. Default nick name when a player cannot be recognized. -#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/SidebarPlayerCache.java:133 -msgid "Unknown" -msgstr "Inconnu" +#. / Resurrection notification. {0} = raw resurrected player name. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java:790 +msgid "{gold}{0} returned from the dead!" +msgstr "{gold}{0} est revenu d'entre les morts !" -#. Title of the rules box. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/RulesManager.java:120 -msgid "{red}{bold}Rules and informations" -msgstr "{red}{bold}Règles et informations" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java:66 +msgid "{green}{bold}The game is now starting." +msgstr "{green}{bold}Le jeu démarre." -#. Rule item in the rule box. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/RulesManager.java:131 -msgid "{darkgray}- {reset}{0}" -msgstr "{darkgray}- {reset}{0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java:67 +msgid "" +"{green}Wait for the teleportation to finish; you'll then be prompted to " +"start the game." +msgstr "" +"{green}Patientez le temps que la téléportation s'achève ; il vous sera alors " +"demandé de démarrer le jeu." -#. Episode in the player list ({episodeText} replacement). {0} = current episode number. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java:115 -#, java-format -msgid "Episode {0}" -msgstr "Épisode {0}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java:81 +msgid "The starting process is not finished yet. Please be patient." +msgstr "Le processus de démarrage n'est pas achevé. Soyez patient." -#. Players in the player list ({playersText} replacement). {0} = current alive players count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java:117 -#, java-format -msgid "{0} player" -msgid_plural "{0} players" -msgstr[0] "{0} joueur" -msgstr[1] "{0} joueurs" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java:87 +msgid "" +"{ce}The game is already started! Reload or restart the server to restart the " +"game." +msgstr "" +"{ce}Le jeu est déjà démarré ! Rechargez ou redémarrez le serveur pour " +"redémarrer." -#. Teams in the player list ({teamsText} replacement). {0} = current alive teams count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/PlayerListHeaderFooterManager.java:119 -#, java-format -msgid "{0} team" -msgid_plural "{0} teams" -msgstr[0] "{0} équipe" -msgstr[1] "{0} équipes" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java:57 +msgid "You must specify the player to kill." +msgstr "" -#. MOTD when the game is not started. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:90 -msgid "Waiting for players..." -msgstr "En attente de joueurs..." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java:66 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java:67 +msgid "{ce}This player was never seen on this server." +msgstr "{ce}Cette personne n'a jamais été vue sur le serveur." -#. MOTD when the game is starting (slow TP in progress). -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:99 -msgid "Starting in progress..." -msgstr "Démarrage en cours..." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java:85 +msgid "{cs}The player {0} is now marked as dead." +msgstr "{cs}Le joueur {0} est désormais marqué comme mort." -#. Solo game running MOTD. {0} = players alive count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:114 -#, java-format -msgid "Game running! {0} player alive." -msgid_plural "Game running! {0} players alive." -msgstr[0] "Partie en cours ! {0} joueur encore en vie." -msgstr[1] "Partie en cours ! {0} joueurs encore en vie." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java:89 +msgid "{ce}{0} is not an alive player." +msgstr "{ce}{0} n'est pas un joueur vivant." -#. Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:119 -#, java-format -msgid "Game running! {0} player alive in {1} team." -msgid_plural "Game running! {0} players alive in {1} teams." -msgstr[0] "Partie en cours ! {0} joueur en vie dans {1} équipe." -msgstr[1] "Partie en cours ! {0} joueurs en vie dans {1} équipes." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java:58 +msgid "You must specify the player to resurrect." +msgstr "" -#. Game finished MOTD with solo winner ({0} = winner raw name). -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:136 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java:71 #, java-format -msgid "Game finished; congratulation to {0} for his victory!" -msgstr "Partie terminée ; félicitation à {0} pour sa victoire !" +msgid "{0} was resurrected." +msgstr "" -#. Game finished MOTD with team winner ({0} = team display name). -#: src/main/java/eu/carrade/amaury/UHCReloaded/misc/MOTDManager.java:141 -#, java-format -msgid "Game finished; the team {0} wins this match!" -msgstr "Partie terminée ; l'équipe {0} remporte la victoire !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java:75 +msgid "{ce}This player is not playing or dead!" +msgstr "{ce}Ce joueur ne joue pas ou n'est pas mort !" -#. Timer. {0} = hours; {1} = minutes; {2} = seconds. -#: src/main/java/eu/carrade/amaury/UHCReloaded/timers/UHTimer.java:404 +#. / Timer. {0} = hours; {1} = minutes; {2} = seconds. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java:393 msgid "{0}{gray}:{white}{1}{gray}:{white}{2}" msgstr "{0}{gray}:{white}{1}{gray}:{white}{2}" -#. Timer. {0} = minutes; {1} = seconds. -#: src/main/java/eu/carrade/amaury/UHCReloaded/timers/UHTimer.java:409 +#. / Timer. {0} = minutes; {1} = seconds. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java:398 msgid "{white}{0}{gray}:{white}{1}" msgstr "{white}{0}{gray}:{white}{1}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java:39 -msgid "{aqua}------ Game-related commands ------" -msgstr "{aqua}------ Commandes liées au jeu ------" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java:40 -msgid "{aqua}------ Bugs-related commands ------" -msgstr "{aqua}------ Commandes liées aux bugs ------" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java:41 -msgid "{aqua}------ Miscellaneous commands ------" -msgstr "{aqua}------ Commandes diverses ------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:108 +msgid "{blue}{bold}Command help for {cc}{bold}/uh timers" +msgstr "" -#. Usage of the /g and /t commands -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/GlobalMessageCommand.java:109 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamMessageCommand.java:108 -msgid "{ce}Usage: /{0} <message>" -msgstr "{ce}Utilisation : /{0} <message>" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:109 +msgid "{cc}/uh timers add <duration> <title ...> {ci}: adds a timer." +msgstr "" +"{cc}/uh timers add <durée> <titre ...> {ci}: ajoute un compte à rebours." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpawnsCommand.java:94 -msgid "{aqua}------ Spawns points commands ------" -msgstr "{aqua}------ Commandes de gestion des points de démarrage ------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:110 +msgid "" +"{cc}/uh timers display <title ...> [--without-name] {ci}: displays a timer " +"in the scoreboard. Automatic when a timer is started." +msgstr "" +"{cc}/uh timers display <titre ...> [--without-name] {ci}: affiche un " +"compteur dans la barre latérale. Automatique au démarrage du compteur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpawnsCommand.java:100 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:111 msgid "" -"{cc}/uh spawns {ci}: manages the spawn points. Execute /uh spawns for " -"details." +"{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. " +"Don't stops the timer." msgstr "" -"{cc}/uh spawns {ci}: gère les points de démarrage. Exécutez /uh spawns pour " -"plus de détails." +"{cc}/uh timers hide <titre ...> {ci}: retire un compteur du scoreboard. " +"N'arrête pas le compteur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:144 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:188 -msgid "{ce}The coordinates must be three valid numbers." -msgstr "{ce}Les coordonnées doivent être trois nombres." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:112 +msgid "{cc}/uh timers list {ci}: lists the registered timers." +msgstr "{cc}/uh timers list {ci}: liste les compteurs enregistrés." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:148 -msgid "{ce}This team is not registered." -msgstr "{ce}Cette équipe n'est pas enregistrée." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:113 +msgid "{cc}/uh timers pause <title ...> {ci}: pauses a timer." +msgstr "{cc}/uh timers pause <titre ...> {ci}: met en pause un comparateur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:157 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:199 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:109 -msgid "{ce}{0} is offline!" -msgstr "{ce}{0} est hors-ligne !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:114 +msgid "{cc}/uh timers resume <title ...> {ci}: resumes a timer." +msgstr "" +"{cc}/uh timers resume <title ...> {ci}: redémarre un compteur après une " +"pause." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:263 -msgid "{aqua}------ Teleportation commands ------" -msgstr "{aqua}------ Commandes de téléportation ------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:115 +msgid "{cc}/uh timers remove <title ...> {ci}: deletes a timer." +msgstr "{cc}/uh timers remove <title ...> {ci}: supprime un compteur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:264 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:116 msgid "" -"{cc}/uh tp team <x> <y> <z> | <target> <team ...> {ci}: teleports the team " -"to the given location/target." +"{cc}/uh timers set <duration> <title ...> {ci}: sets the duration of a timer." msgstr "" -"{cc}/uh tp team <x> <y> <z> | <target> <team ...> {ci}: téléporte une équipe " -"au lieu ou au joueur indiqué." +"{cc}/uh timers set <durée> <titre ...> {ci}: modifie la durée d'un compte à " +"rebours." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:117 +msgid "{cc}/uh timers start <title ...> {ci}: starts a timer." +msgstr "{cc}/uh timers start <titre ...> {ci}: démarre un compte à rebours." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:265 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:118 msgid "" -"{cc}/uh tp spectators <x> <y> <z> | <target> {ci}: teleports the spectators " -"(aka non-alive players) to the given location/target." +"{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be " +"removed from the scoreboard." msgstr "" -"{cc}/uh tp spectators <x> <y> <z> | <target> {ci}: téléporte les spectateurs " -"(i.e. les joueurs non-vivants) au lieu ou au joueur indiqué." +"{cc}/uh timers stop <title ...> {ci}: force l'arrêt d'un compteur. Il est " +"retiré du scoraboard." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPCommand.java:272 -msgid "" -"{cc}/uh tp {ci}: teleports the spectators or an entire team. See /uh tp for " -"details." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:123 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:300 +msgid "You must specify both a duration and a name." msgstr "" -"{cc}/uh tp {ci}: téléporte les spectateurs ou une équipe. Consultez /uh tp " -"pour plus de détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:79 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:208 -msgid "{yellow}{0} - version {1}" -msgstr "{yellow}{0} - version {1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:128 +msgid "{ce}A timer called {0}{ce} already exists; please choose another name." +msgstr "{ce}Un compteur nommé {0}{ce} existe déjà, choisissez un autre nom." -#. The "and" in the authors list (like "Amaury Carrade, azenet and João Roda") -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:94 -msgctxt "authors_list" -msgid "and" -msgstr "et" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:133 +msgid "{cs}The timer {0}{cs} (duration {1}) has been registered." +msgstr "{cs}Le compteur {0}{cs}, de durée {1}, a bien été enregistré." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:102 -#, java-format -msgid "Plugin made with love by {0}." -msgstr "Plugin réalisé avec amour par {0}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:143 +msgid "{cs}The timer {0}{cs} is now displayed." +msgstr "{cs}Le compteur {0}{cs} est désormais affiché." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:129 -#, java-format -msgid "Build number: {0}." -msgstr "Numéro de construction : {0}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:152 +msgid "{cs}The timer {0}{cs} is now hidden." +msgstr "{cs}Le compteur {0}{cs} est désormais masqué." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:133 -msgid "Build number not available." -msgstr "Numéro de construction indisponible." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:160 +msgid "{ci}{0} timer is registered." +msgid_plural "{ci}{0} timers are registered." +msgstr[0] "{ci}Il y a {0} compteur enregistré." +msgstr[1] "{ci}Il y a {0} compteurs enregistrés." -#. Translation -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:138 -msgid "{aqua}------ Translations ------" -msgstr "{aqua}------ Traductions ------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:171 +msgid "Paused" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:139 -#, java-format -msgid "Current language: {0} (translated by {1})." -msgstr "Langue courante : {0} (traduit par {1})." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:171 +msgid "Running" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:140 -#, java-format -msgid "Fallback language: {0} (translated by {1})." -msgstr "Langue par défaut : {0} (traduit par {1})." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:171 +msgid "Not started" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:141 -msgid "{aqua}------ License ------" -msgstr "{aqua}------ Licence ------" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:173 +msgid "{gray}(total: {0}{gray})" +msgstr "{gray}(total : {0}{gray})" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:142 -msgid "Published under the CeCILL-B License." -msgstr "Publié sous la licence CeCILL-B." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:174 +msgid "{gray}{bold}System timer" +msgstr "{gray}{bold}Compteur système" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHAboutCommand.java:170 -msgid "{cc}/uh about {ci}: informations about the plugin and the translation." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:175 +msgid "" +"{gray}This timer is a system timer, it cannot be modified (you can still " +"display or hide it to/from the sidebar)." msgstr "" -"{cc}/uh about {ci}: informations à propos du plugin et des traductions." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java:73 -msgid "{cs}Warning canceled." -msgstr "{cs}Avertissement annulé." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:183 +msgid "{white}Hide this timer from the sidebar" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java:88 -msgid "" -"{cs}Future size saved. All players outside this future border will be warned " -"every {0} second." -msgid_plural "" -"{cs}Future size saved. All players outside this future border will be warned " -"every {0} seconds." -msgstr[0] "" -"{cs}Future taille enregistrée. Les joueurs hors de la bordure vont être " -"avertis toutes les {0} seconde." -msgstr[1] "" -"{cs}Future taille enregistrée. Les joueurs hors de la bordure vont être " -"avertis toutes les {0} secondes." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:183 +msgid "{white}Show this timer in the sidebar" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java:93 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:98 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:122 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java:71 -msgid "{ce}“{0}” is not a number..." -msgstr "{ce}“{0}” n'est pas un nombre..." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:198 +msgid "{white}Start this timer" +msgstr "{white}Démarrer ce compteur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java:118 -msgid "" -"{cc}/uh border warning <futureDiameter> [minutesBeforeReduction]{ci}: warns " -"all players outside the given future diameter. It's just a notice, nothing " -"else." -msgstr "" -"{cc}/uh border warning <futurDiamètre> [minutesAvantRéduction] {ci}: avertit " -"tous les joueurs hors de la future bordure donnée. Ce n'est qu'un " -"avertissement, rien de plus." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:210 +msgid "{white}Stop this timer" +msgstr "{white}Arrêter ce compteur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderWarningCommand.java:118 -msgid "{cc}/uh border warning cancel{ci}: cancels a previously-set warning." -msgstr "{cc}/uh border warning cancel {ci}: annule un précédent avertissement." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:225 +msgid "{white}Resume this timer" +msgstr "{white}Redémarrer ce compteur" -#. Some players are outside -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:74 -msgid "" -"{ce}Some players are outside the future border, so this operation was " -"cancelled." -msgstr "" -"{ce}Certains joueurs étant hors de cette nouvelle bordure, l'opération a été " -"annulée." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:225 +msgid "{white}Pause this timer" +msgstr "{white}Mettre ce compteur en pause" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:75 -msgid "" -"{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to " -"this point." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:237 +msgid "{white}Delete this timer" +msgstr "{white}Supprimer ce compteur" + +#. / Button in /uh timers +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:249 +msgid "[ Create a new timer ]" msgstr "" -"{ci}Utilisez {cc}/uh border set {0} force{ci} pour changer la taille de la " -"carte malgré tout." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:78 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:251 msgid "" -"{ce}WARNING: {ci}because WorldBorder is not installed, players out of the " -"border will not be teleported!" +"{white}Click here to create a timer\n" +"{gray}/uh timers add mm:ss <name>" msgstr "" -"{ce}ATTENTION: {ci}WorldBorder n'étant pas installé, les joueurs hors de la " -"bordure ne seront pas téléportés !" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:88 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:113 -msgid "{lightpurple}The diameter of the map is now {0} block." -msgid_plural "{lightpurple}The diameter of the map is now {0} blocks." -msgstr[0] "{lightpurple}La carte a désormais un diamètre de {0} bloc." -msgstr[1] "{lightpurple}La carte a désormais un diamètre de {0} blocs." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:92 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:117 -msgid "{lightpurple}The size of the map is now {0}×{0}." -msgstr "{lightpurple}La taille de la carte est désormais de {0}×{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderSetCommand.java:147 -msgid "" -"{cc}/uh border set <diameter> [force]{ci}: changes the size of the map. If " -"force is not given, the operation will be canceled if there is a player " -"outside the border." +#. / Button in /uh timers +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:255 +msgid "[ Display Help ]" msgstr "" -"{cc}/uh border set <diamètre> [force] {ci}: change la taille de la carte. Si " -"le paramètre “force” n'est pas donné, l'opération sera annulée s'il existe " -"des joueurs hors de la bordure." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java:91 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:257 msgid "" -"{cc}/uh border check <diameter>{ci}: returns a list of the players outside " -"the given border size." +"{white}Get some help about the commands\n" +"{gray}/uh timers help" msgstr "" -"{cc}/uh border check <diamètre> {ci}: retourne la liste des joueurs hors de " -"la bordure." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java:60 -msgid "{ci}The current diameter of the map is {0} block." -msgid_plural "{ci}The current diameter of the map is {0} blocks." -msgstr[0] "{ci}La carte a actuellement un diamètre de {0} bloc." -msgstr[1] "{ci}La carte a actuellement un diamètre de {0} blocs." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:272 +msgid "{cs}The timer {0}{cs} is now paused." +msgstr "{cs}Le compteur {0}{cs} est désormais en pause." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java:64 -msgid "{ci}The current map size is {0}×{0}." -msgstr "{ci}La taille actuelle de la carte est {0}×{0}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:283 +msgid "{cs}The timer {0}{cs} was resumed." +msgstr "{cs}Le compteur {0}{cs} n'est plus en pause." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java:83 -msgid "{cc}/uh border get{ci}: returns the current size of the map." -msgstr "{cc}/uh border get {ci}: retourne la taille actuelle de la carte." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:295 +msgid "{cs}The timer {0}{cs} has been deleted." +msgstr "{cs}Le compteur {0}{cs} a été supprimé." -#. Header of the /uh infos command. Plural based on the players count. -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:69 -msgid "{ci}{0} player alive in {1} team." -msgid_plural "{ci}{0} players alive in {1} teams." -msgstr[0] "{ci}{0} joueur en vie, dans {1} équipe." -msgstr[1] "{ci}{0} joueurs en vie, répartis dans {1} équipes." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:307 +msgid "{cs}The duration of the timer {0}{cs} is now {1}." +msgstr "{cs}La durée du compteur {0}{cs} est désormais {1}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:73 -msgid "{ci}The game is not started." -msgstr "{ci}Le jeu n'est pas encore démarré." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:325 +msgid "{cs}The timer {0}{cs} was started." +msgstr "{cs}Le compteur {0}{cs} a démarré." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:93 -msgid "Currently online" -msgstr "Actuellement connecté(e)" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:336 +msgid "{cs}The timer {0}{cs} was stopped." +msgstr "{cs}Le compteur {0}{cs} a été arrêté." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:99 -msgid "Currently offline" -msgstr "Actuellement hors-ligne" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:360 +msgid "{ce}This timer is not registered." +msgstr "{ce}Ce compteur n'est pas enregistré." -#. Team name in tooltip in /uh infos -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:108 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:366 #, java-format -msgid "Team: {0}" -msgstr "Équipe : {0}" +msgid "A timer name is required as argument #{0}" +msgstr "" -#. Separator in /uh infos -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:115 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:160 -msgid "{gray} - " -msgstr "{gray} - " +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:379 +#, java-format +msgid "" +"A duration is required as argument #{0}. Format: “mm”, “mm:ss” or “hh:mm:ss”." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java:384 +#, java-format +msgid "" +"The duration provided as argument #{0} is invalid. Format: “mm”, “mm:ss” or " +"“hh:mm:ss”." +msgstr "" +"{ce}La syntaxe de la durée entrée en argument #{0} est invalide. Les formats " +"acceptés sont “mm”, “mm:ss” ou “hh:mm:ss”." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:109 +msgid "{blue}{bold}Command help for {cc}{bold}/uh spawns" +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:110 +msgid "{cc}/uh spawns list {ci}: lists the registered spawn points." +msgstr "{cc}/uh spawns list {ci}: liste les points de démarrage enregistrés." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:111 +msgid "" +"{cc}/uh spawns dump {ci}: displays the registered spawn points in an " +"exportable format. {gray}Use this to plot the spawn points, as example." +msgstr "" +"{cc}/uh spawns dump {ci}: affiche les points de démarrage dans un format " +"exportable. {gray}Utilisez ceci pour afficher les points sur un graph, par " +"exemple." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:112 +msgid "" +"{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the " +"current location of the sender or at the provided coordinates." +msgstr "" +"{cc}/uh spawns add [<x> <z>]{ci}: ajoute un point de démarrage à la position " +"de l'exécutant ou aux coordonnées données." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:113 +msgid "" +"{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the " +"specified coordinates, or at the current location if the sender without " +"coordinates." +msgstr "" +"{cc}/uh spawns remove [<x> <z>] {ci}: supprime les points de démarrage aux " +"coordonnées spécifiées, ou à la position de l'envoyeur sans coordonnées." -#. Alive state in /uh infos -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:122 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:164 -msgid "{green}alive" -msgstr "{green}vivant" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:114 +msgid "" +"{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh " +"spawns generate for details." +msgstr "" +"{cc}/uh spawns generate {ci}: génère automatiquement des points de " +"démarrage. Consultez /uh spawns generate pour plus de détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:125 -#, java-format -msgid "{0} half-hearts" -msgstr "{0} demi-cœurs" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:115 +msgid "{cc}/uh spawns reset {ci}: removes all registered spawn points." +msgstr "" +"{cc}/uh spawns reset {ci}: supprime tous les points de démarrage enregistrés." -#. Alive state in /uh infos -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:131 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:168 -msgid "{red}dead" -msgstr "{red}mort" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:125 +msgid "{ce}There isn't any registered spawn point." +msgstr "{ce}Il n'y a pas de point de démarrage enregistré." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHInfosCommand.java:196 -msgid "{cc}/uh infos {ci}: prints some infos about the current game." -msgstr "{cc}/uh infos {ci}: affiche des informations à propos du jeu en cours." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:136 +msgid "{ci}There are {0} registered spawn points." +msgstr "{ci}Il y a {0} points de démarrage enregistrés." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java:75 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java:88 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java:87 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java:100 -msgid "" -"{ce}Food points and saturation must be numbers (floats for the saturation)!" -msgstr "" -"{ce}Les valeurs de faim et de saturation doivent être des nombres " -"(possiblement à virgule pour la saturation) !" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:153 +msgid "{lightpurple}World {0}" +msgstr "{lightpurple}Monde {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedAllCommand.java:116 -msgid "" -"{cc}/uh feedall [foodPoints=20] [saturation=max] {ci}: feeds all players." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:231 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:314 +#, java-format +msgid "There is no world named {0}." msgstr "" -"{cc}/uh feedall [faim=20] [saturation=max] {ci}: nourrit tous les joueurs." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:97 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:118 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:244 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:268 msgid "{cs}Spawn added in the world {0}: {1};{2}" msgstr "{cs}Point de démarrage ajouté dans le monde {0} : {1};{2}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:101 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:126 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:248 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:276 msgid "{ce}You cannot add a spawn point out of the borders." msgstr "" "{ce}Vous ne pouvez pas ajouter un point de démarrage hors des bordures." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:105 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:130 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:252 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:280 msgid "{ce}Unable to add this spawn point: no safe spot found in the Nether." msgstr "" "{ce}Impossible d'ajouter ce point de démarrage : aucun endroit sûr trouvé " "dans le Nether." -#. /uh spawns add <x>: Two coordinates needed! -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:111 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java:85 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:259 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:298 msgid "{ce}You need to specify two coordinates." msgstr "{ce}Vous devez spécifier deux coordonnées." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:122 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:186 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java:106 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:272 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:331 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:477 msgid "{ce}This is not a number!" msgstr "{ce}Ceci n'est pas un nombre !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsAddCommand.java:152 -msgid "" -"{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the " -"current location of the sender or at the provided coordinates." -msgstr "" -"{cc}/uh spawns add [<x> <z>]{ci}: ajoute un point de démarrage à la position " -"de l'exécutant ou aux coordonnées données." - -#. Solo mode? -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:119 -msgid "{ci}No team found: assuming the game is a solo game." -msgstr "{ci}Aucune équipe trouvée : le jeu est considéré comme solo." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:136 -msgid "" -"{ci}Some players are not in a team; their number was added to the spawn " -"count." -msgstr "" -"{ci}Certains joueurs ne sont pas dans une équipe ; leur nombre a été ajoutés " -"aux points de démarrage à générer." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:174 -msgid "{ce}The world {0} doesn't exists." -msgstr "{ce}Le monde {0} n'existe pas." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:193 -msgid "{ci}You asked for a void generation. Thus, the generation is empty." -msgstr "{ci}Vous avez demandé de ne rien générer. Rien ne sera généré." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:205 -msgid "{ce}The generation method “{0}” is not (yet?) supported." -msgstr "{ce}La méthode de génération « {0} » n'est actuellement pas supportée." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:211 -msgid "" -"{ce}You asked for the impossible: there are too many spawn points on a too " -"small surface. Decrease the spawn count or the minimal distance between two " -"points." -msgstr "" -"{ce}Vous avez demandé l'impossible : il y a trop de points sur une trop " -"petite surface. Diminuez le nombre de points à générer ou la distance " -"minimale entre deux points." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:291 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:327 +msgid "{cs}The spawn point {1};{2} in the world {0} was removed." +msgstr "{cs}Le point de démarrage {1};{2} du monde {0} a été supprimé." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:215 -msgid "{cs}Successfully generated the asked spawn points." -msgstr "{cs}Génération des points de démarrage effectuée avec succès." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:339 +msgid "{cs}All the spawn points were removed." +msgstr "{cs}Tous les points de démarrage ont été supprimés." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:277 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:349 msgid "{aqua}Command" msgstr "{aqua}Commande" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:278 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:350 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:478 msgid "" "{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] " "[xCenter] [zCenter] [world]" @@ -1332,11 +1618,11 @@ msgstr "" "{cc}/uh spawns generate <circular|grid|random> [taille] [distanceMin] " "[nombre] [xCentre] [zCentre] [monde]" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:279 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:352 msgid "{aqua}Shapes" msgstr "{aqua}Formes" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:280 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:353 msgid "" " - {cc}random{ci}: generates random spawn points on the map, with a minimal " "distance between them." @@ -1344,7 +1630,7 @@ msgstr "" " - {cc}random{ci} : génère des points aléatoirement sur la carte, avec une " "distance minimale entre eux." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:281 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:354 msgid "" " - {cc}grid{ci}: generates the spawn points on concentric squares, with a " "constant distance between two generated points." @@ -1352,7 +1638,7 @@ msgstr "" " - {cc}grid{ci} : génère les points sur des carrés concentriques, en " "commençant par le plus grand. La distance entre deux points est constante." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:282 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:355 msgid "" " - {cc}circular{ci}: generates the spawn points on concentric circles, with " "a minimal distance between two generated points. In each circle, the angle " @@ -1362,11 +1648,11 @@ msgstr "" "une distance minimale entre deux points. Sur chaque cercle, l'angle (et donc " "la distance) entre deux points est constant." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:283 -msgid "{aqua}Arguments" -msgstr "{aqua}Arguments" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:357 +msgid "{aqua} Arguments " +msgstr "{aqua}Arguments " -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:284 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:358 msgid "" " - {cc}size{ci}: the size of the region where the spawn points will be " "generated. Squared or circular, following the shape of the map. Default: " @@ -1376,7 +1662,7 @@ msgstr "" "être générés. La région est carrée ou circulaire, selon la configuration. " "Par défaut : la taille de la carte." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:285 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:359 msgid "" " - {cc}distanceMin{ci}: the minimal distance between two spawn points. " "Default: 250 blocks." @@ -1384,7 +1670,7 @@ msgstr "" " - {cc}distanceMin{ci} : la distance minimale entre deux points. Par " "défaut : 250 blocs." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:286 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:360 msgid "" " - {cc}count{ci}: the number of spawn points to generate. Default: the " "number of players or teams." @@ -1392,7 +1678,7 @@ msgstr "" " - {cc}nombre{ci} : le nombre de points à générer. Par défaut : le nombre de " "joueurs ou d'équipes." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:287 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:361 msgid "" " - {cc}xCenter{ci}, {cc}zCenter{ci}: the center of the region where the " "points are generated. Default: world' spawn point." @@ -1400,1086 +1686,1071 @@ msgstr "" " - {cc}xCentre{ci}, {cc}zCentre{ci} : le centre de la région dans laquelle " "les points sont générés. Par défaut : le point d'apparition du monde." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:288 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:362 msgid " - {cc}world{ci}: the world where the spawn points will be generated." msgstr " - {cc}monde{ci} : le monde dans lequel les points seront générés." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsGenerateCommand.java:295 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:406 +msgid "{ci}No team found: assuming the game is a solo game." +msgstr "{ci}Aucune équipe trouvée : le jeu est considéré comme solo." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:423 msgid "" -"{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh " -"spawns generate for details." +"{ci}Some players are not in a team; their number was added to the spawn " +"count." msgstr "" -"{cc}/uh spawns generate {ci}: génère automatiquement des points de " -"démarrage. Consultez /uh spawns generate pour plus de détails." +"{ci}Certains joueurs ne sont pas dans une équipe ; leur nombre a été ajoutés " +"aux points de démarrage à générer." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:466 +msgid "{ce}The world {0} doesn't exists." +msgstr "{ce}Le monde {0} n'existe pas." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsDumpCommand.java:126 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:485 +msgid "{ci}You asked for a void generation. Thus, the generation is empty." +msgstr "{ci}Vous avez demandé de ne rien générer. Rien ne sera généré." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:497 +msgid "{ce}The generation method “{0}” is not (yet?) supported." +msgstr "{ce}La méthode de génération « {0} » n'est actuellement pas supportée." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:502 msgid "" -"{cc}/uh spawns dump {ci}: displays the registered spawn points in an " -"exportable format. {gray}Use this to plot the spawn points, as example." +"{ce}You asked for the impossible: there are too many spawn points on a too " +"small surface. Decrease the spawn count or the minimal distance between two " +"points." msgstr "" -"{cc}/uh spawns dump {ci}: affiche les points de démarrage dans un format " -"exportable. {gray}Utilisez ceci pour afficher les points sur un graph, par " -"exemple." +"{ce}Vous avez demandé l'impossible : il y a trop de points sur une trop " +"petite surface. Diminuez le nombre de points à générer ou la distance " +"minimale entre deux points." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:75 -msgid "{ce}There isn't any registered spawn point." -msgstr "{ce}Il n'y a pas de point de démarrage enregistré." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:506 +msgid "{cs}Successfully generated the asked spawn points." +msgstr "{cs}Génération des points de démarrage effectuée avec succès." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:79 -msgid "{ci}There are {0} registered spawn points." -msgstr "{ci}Il y a {0} points de démarrage enregistrés." +#. / A spawn point in the /uh spawns list command (in the overworld) +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:542 +msgid "{green}{0}{darkgreen};{green}{1}" +msgstr "{green}{0}{darkgreen};{green}{1}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:100 -msgid "{lightpurple}World {0}" -msgstr "{lightpurple}Monde {0}" +#. / A spawn point in the /uh spawns list command (in the Nether) +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:546 +msgid "{red}{0}{darkred};{red}{1}" +msgstr "{red}{0}{darkred};{red}{1}" + +#. / A spawn point in the /uh spawns list command (in the End) +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:550 +msgid "{yellow}{0}{gold};{yellow}{1}" +msgstr "{yellow}{0}{gold};{yellow}{1}" + +#. / A spawn point in the /uh spawns list command (in a custom world) +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java:554 +msgid "{gray}{0}{darkgray};{gray}{1}" +msgstr "{gray}{0}{darkgray};{gray}{1}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:68 +msgid "{ce}There isn't any spectator to list." +msgstr "{ce}Il n'y a pas de spectateur à lister." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:73 +msgid "{ci}{0} registered spectator." +msgid_plural "{ci}{0} registered spectators." +msgstr[0] "{ci}{0} spectateur enregistré." +msgstr[1] "{ci}{0} spectateurs enregistrés." + +#. / A list item in the startup spectators list +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:76 +msgctxt "startup_specs" +msgid "{lightpurple} - {0}" +msgstr "{lightpurple} - {0}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:89 +msgid "Please add the player you want to register as spectator." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:98 +msgid "{ce}Unable to retrieve the player {0}." +msgstr "{ce]Impossible de trouver le joueur {0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:101 +msgid "" +"{ce}In offline mode, you cannot add players if they never came to this " +"server." +msgstr "" +"{ce}En mode hors-ligne, vous ne pouvez pas ajouter de joueurs qui ne se sont " +"jamais connectés." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:107 +msgid "{cs}The player {0} is now a spectator." +msgstr "{cs}Le joueur {0} est désormais un spectateur." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:118 +msgid "Please add the player you want to unregister from spectators." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:127 +msgid "{ce}The player {0} was not found." +msgstr "{ce}Le joueur {0} n'a pas été trouvé." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java:132 +msgid "{cs}The player {0} is now a player." +msgstr "{cs}Le joueur {0} est désormais un joueur." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java:222 +msgid "Spectators are not allowed for this game." +msgstr "Les spectateurs ne sont pas autorisés à rejoindre cette partie." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java:228 +msgid "External spectators are not allowed for this game." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java:235 +msgid "" +"{gray}The unknown player {0} just tried to join. To allow him to spectate, " +"execute {cc}{1} or click here." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java:236 +#, java-format +msgid "" +"Click here to execute\n" +"{0}" +msgstr "" +"Cliquez ici pour exécuter\n" +"{0}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:60 +msgid "{ci}The current diameter of the map is {0} block." +msgid_plural "{ci}The current diameter of the map is {0} blocks." +msgstr[0] "{ci}La carte a actuellement un diamètre de {0} bloc." +msgstr[1] "{ci}La carte a actuellement un diamètre de {0} blocs." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:64 +msgid "{ci}The current map size is {0}×{0}." +msgstr "{ci}La taille actuelle de la carte est {0}×{0}." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:80 +msgid "" +"{ce}Some players are outside the future border, so this operation was " +"cancelled." +msgstr "" +"{ce}Certains joueurs étant hors de cette nouvelle bordure, l'opération a été " +"annulée." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:81 +msgid "" +"{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to " +"this point." +msgstr "" +"{ci}Utilisez {cc}/uh border set {0} force{ci} pour changer la taille de la " +"carte malgré tout." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:97 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:122 +msgid "{lightpurple}The diameter of the map is now {0} block." +msgid_plural "{lightpurple}The diameter of the map is now {0} blocks." +msgstr[0] "{lightpurple}La carte a désormais un diamètre de {0} bloc." +msgstr[1] "{lightpurple}La carte a désormais un diamètre de {0} blocs." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:101 +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:126 +msgid "{lightpurple}The size of the map is now {0}×{0}." +msgstr "{lightpurple}La taille de la carte est désormais de {0}×{0}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:140 +#, java-format +msgid "The border motor ({0}) does not supports progressive resizes." +msgstr "" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:162 +msgid "" +"{ce}“{0}” is not a valid time delta... Accepted formats are mm, mm:ss or hh:" +"mm:ss." +msgstr "" +"{ce}La syntaxe de la durée « {0} » est invalide : les formats acceptés sont " +"mm, mm:ss ou hh:mm:ss." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:170 +#, fuzzy +#| msgid "{lightpurple}The diameter of the map is now {0} block." +#| msgid_plural "{lightpurple}The diameter of the map is now {0} blocks." +msgid "{lightpurple}The diameter of the map will be set to {0} block over {1}." +msgid_plural "" +"{lightpurple}The diameter of the map will be set to {0} blocks over {1}." +msgstr[0] "{lightpurple}La carte a désormais un diamètre de {0} bloc." +msgstr[1] "{lightpurple}La carte a désormais un diamètre de {0} blocs." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java:174 +#, fuzzy +#| msgid "{lightpurple}The size of the map is now {0}×{0}." +msgid "{lightpurple}The size of the map will be set to {0}×{0} over {1}." +msgstr "{lightpurple}La taille de la carte est désormais de {0}×{0}" + +#. / Title of the border section in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:116 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:312 +msgid "{blue}{bold}Border" +msgstr "{blue}{bold}Bordure" + +#. / Border diameter for a squared map in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:124 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:320 +msgid "{white}{0} block wide" +msgid_plural "{white}{0} blocks wide" +msgstr[0] "{white}{0} bloc de large" +msgstr[1] "{white}{0} blocs de large" + +#. / Border diameter for a circular map in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:127 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:323 +msgid "{gray}Diameter: {white}{0} block" +msgid_plural "{gray}Diameter: {white}{0} blocks" +msgstr[0] "{gray}Diamètre : {white}{0} bloc" +msgstr[1] "{gray}Diamètre : {white}{0} blocs" + +#. / Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:143 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:339 +msgid "{white}{0} {1}" +msgstr "{white}{0} {1}" + +#. / Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:148 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:344 +msgid "{gray}X: {white}{0} {1}" +msgstr "{gray}X: {white}{0} {1}" + +#. / Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:150 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:346 +msgid "{gray}Z: {white}{0} {1}" +msgstr "{gray}Z: {white}{0} {1}" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:285 +msgid "{cs}All players are inside the given border." +msgstr "{cs}Tous les joueurs sont à l'intérieur de cette bordure." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:289 +msgid "{ci}There are {0} players outside the given border." +msgstr "{ci}Il y a {0} joueurs hors de cette bordure." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:295 +msgid "{lightpurple} - {red}{0}{ci} (far away from the border)" +msgstr "{lightpurple} - {red}{0}{ci} (loin de la bordure)" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:299 +msgid "{lightpurple} - {yellow}{0}{ci} (close to the border)" +msgstr "{lightpurple} - {yellow}{0}{ci} (proche de la bordure)" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:303 +msgid "{lightpurple} - {green}{0}{ci} (very close to the border)" +msgstr "{lightpurple} - {green}{0}{ci} (très proche de la bordure)" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:323 +msgid "{red}Warning!" +msgstr "{red}Attention !" + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:323 +msgid "{white}The border begins to shrink..." +msgstr "{white}La bordure commence à se réduire..." + +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:325 +msgid "{red}{bold}The border begins to shrink..." +msgstr "{red}{bold}La bordure commence à se réduire..." -#. A spawn point in the /uh spawns list command (in the overworld) -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:130 -msgid "{green}{0}{darkgreen};{green}{1}" -msgstr "{green}{0}{darkgreen};{green}{1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:326 +msgid "" +"{gray}It will shrink by one block every {0} second(s) until {1} blocks in " +"diameter." +msgstr "" +"{gray}Elle réduira d'un bloc toutes les {0} seconde(s) jusqu'à atteindre {1} " +"blocs de diamètre." -#. A spawn point in the /uh spawns list command (in the Nether) -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:134 -msgid "{red}{0}{darkred};{red}{1}" -msgstr "{red}{0}{darkred};{red}{1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java:343 +msgid "{red}The border will start to shrink in {0} minute..." +msgid_plural "{red}The border will start to shrink in {0} minutes..." +msgstr[0] "{red}La bordure va commencer à se réduire dans {0} minute..." +msgstr[1] "{red}La bordure va commencer à se réduire dans {0} minutes..." -#. A spawn point in the /uh spawns list command (in the End) -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:138 -msgid "{yellow}{0}{gold};{yellow}{1}" -msgstr "{yellow}{0}{gold};{yellow}{1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java:79 +msgid "{gold}To configure the game," +msgstr "{gold}Pour configurer le jeu," -#. A spawn point in the /uh spawns list command (in a custom world) -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:142 -msgid "{gray}{0}{darkgray};{gray}{1}" -msgstr "{gray}{0}{darkgray};{gray}{1}" +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java:80 +msgid "{gold}use {bold}/config" +msgstr "{gold}utilisez {bold}/config" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsListCommand.java:185 -msgid "{cc}/uh spawns list {ci}: lists the registered spawn points." -msgstr "{cc}/uh spawns list {ci}: liste les points de démarrage enregistrés." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:70 +msgid "{0} module registered {gray}(hover for details)" +msgid_plural "{0} modules registered {gray}(hover for details)" +msgstr[0] "" +msgstr[1] "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java:67 -msgid "{cs}All the spawn points were removed." -msgstr "{cs}Tous les points de démarrage ont été supprimés." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:98 +msgid "Enabled" +msgstr "" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java:93 -msgid "{cc}/uh spawns reset {ci}: removes all registered spawn points." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:98 +msgid "Disabled" msgstr "" -"{cc}/uh spawns reset {ci}: supprime tous les points de démarrage enregistrés." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java:80 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java:102 -msgid "{cs}The spawn point {1};{2} in the world {0} was removed." -msgstr "{cs}Le point de démarrage {1};{2} du monde {0} a été supprimé." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:100 +msgid "Load time" +msgstr "Période de chargement" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsRemoveCommand.java:134 -msgid "" -"{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the " -"specified coordinates, or at the current location if the sender without " -"coordinates." -msgstr "" -"{cc}/uh spawns remove [<x> <z>] {ci}: supprime les points de démarrage aux " -"coordonnées spécifiées, ou à la position de l'envoyeur sans coordonnées." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:104 +msgid "Provided commands" +msgstr "Commandes fournies" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:70 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:79 -msgid "{ce}The player {0} is not online." -msgstr "{ce}Le joueur {0} n'est pas connecté." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:110 +msgid "External dependencies" +msgstr "Dépendances externes" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:75 -msgid "{ce}No death location available for the player {0}." -msgstr "{ce}Pas de localisation de mort enregistrée pour le joueur {0}." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:116 +msgid "Internal module" +msgstr "Module interne" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:85 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:90 -msgid "{cs}The player {0} was teleported back." -msgstr "{cs}Le joueur {0} a été téléporté là où il est mort." +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java:120 +msgid "Cannot be disabled" +msgstr "Non désactivable" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:95 -msgid "" -"{ce}The player {0} was NOT teleported back because no safe spot was found." -msgstr "" -"{ce}Le joueur {0} n'a PAS été téléporté car aucun point de téléportation sûr " -"n'a été trouvé." +#. / Title of the team section in the sidebar +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java:167 +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:207 +msgid "{bold}Your team" +msgstr "{bold}Votre équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:96 -msgid "" -"{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this " -"point." -msgstr "" -"{ci}Utilisez {cc}/uh tpback {0} force{ci} pour le téléporter malgré tout." +#. / Default nick name when a player cannot be recognized. +#: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java:133 +msgid "Unknown" +msgstr "Inconnu" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPBackCommand.java:135 -msgid "" -"{cc}/uh tpback <player> [force] {ci}: safely teleports back a player to his " -"death location." -msgstr "" -"{cc}/uh tpback <joueur> [force] {ci}: téléporte un joueur au lieu de sa mort " -"en toute sécurité." +#. / Notice displayed at the bottom of the sidebar if the game is paused (/uh freeze all). +#: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:383 +msgid "{darkaqua}Game frozen" +msgstr "{darkaqua}En pause" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java:76 -msgid "{ce}The game is not started!" -msgstr "{ce}Le jeu n'est pas encore démarré !" +#. *** Ready *** +#: src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java:196 +msgid "Ultra Hardcore plugin loaded." +msgstr "Plugin Ultra Hardcore chargé." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java:80 -msgid "{ce}There's not one team alive!" -msgstr "{ce}Il n'y a pas qu'une équipe encore en vie !" +#~ msgid "{red}Team deleted" +#~ msgstr "{red}Équipe supprimée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java:104 -msgid "" -"{cc}/uh finish {ci}: displays the name of the winner(s) and launches some " -"fireworks." -msgstr "" -"{cc}/uh finish {ci}: affiche le nom du/des vainqueurs et lance des feux " -"d'artifices." +#~ msgid "{gray}Press {white}Escape{gray} to go back to the teams list." +#~ msgstr "" +#~ "{gray}Appuyez sur {white}Échap{gray} pour retourner à la liste des " +#~ "équipes." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:66 -msgid "" -"{ce}The spawn points are not already assigned to the player, because the " -"game is not started." -msgstr "" -"{ce}Les points de démarrage n'ont pas encore été assignés aux joueurs, car " -"le jeu n'a pas encore démarré." +#~ msgid "{0} » {darkred}Delete" +#~ msgstr "{0} » {darkred}Supprimer" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:87 -msgid "{ce}No spawn location available for the player {0}." -msgstr "{ce}Pas de localisation de démarrage enregistrée pour le joueur {0}." +#~ msgid "{green}Keep this team alive" +#~ msgstr "{green}Garder cette équipe en vie" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:95 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:99 -msgid "{cs}The player {0} was teleported to his spawn location." -msgstr "{cs}Le joueur {0} a été téléporté à son point de démarrage attribué." +#~ msgid "{red}Delete this team {italic}forever" +#~ msgstr "{red}Supprimer cette équipe {italic}pour l'éternité" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:103 -msgid "" -"{ce}The player {0} was NOT teleported to his spawn because no safe spot was " -"found." -msgstr "" -"{ce}Le joueur {0} n'a PAS été téléporté car aucun point de téléportation sûr " -"n'a été trouvé." +#~ msgid "{0} » {black}Members" +#~ msgstr "{0} » {black}Membres" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:104 -msgid "" -"{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this " -"point." -msgstr "" -"{ci}Utilisez {cc}/uh tpspawn {0} force{ci} pour le téléporter malgré tout." +#~ msgid "{green}« Go back" +#~ msgstr "{green}« Retour" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTPSpawnCommand.java:148 -msgid "" -"{cc}/uh tpspawn <player> [force] {ci}: safely teleports back a player to his " -"spawn location." -msgstr "" -"{cc}/uh tpspawn <joueur> [force] {ci}: téléporte un joueur à son point de " -"démarrage attribué en toute sécurité." +#~ msgid "{reset}{0}" +#~ msgstr "{reset}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java:78 -msgid "{ce}This player is not playing or dead!" -msgstr "{ce}Ce joueur ne joue pas ou n'est pas mort !" +#~ msgid "{gray}Online" +#~ msgstr "{gray}En ligne" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java:82 -msgid "" -"{cs}Because {0} is offline, he will be resurrected when he logins. If he " -"was, he is no longer banned." -msgstr "" -"{cs}Comme {0} est déconnecté, il sera ressuscité dés qu'il se connectera. " -"S'il l'était, il n'est plus banni." +#~ msgid "{gray}Offline" +#~ msgstr "{gray}Hors ligne" -#. Trying to resurrect an alive player -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java:90 -msgid "{ce}{0} is not dead!" -msgstr "{ce}{0} n'est pas mort !" +#~ msgid "{gray}Current team: {0}" +#~ msgstr "{gray}Équipe : {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHResurrectCommand.java:127 -msgid "{cc}/uh resurrect <player> {ci}: resurrects a player." -msgstr "{cc}/uh resurrect <joueur> {ci}: fait revivre un joueur." +#~ msgid "{gray}Current team: none" +#~ msgstr "{gray}Équipe : aucune" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java:117 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java:76 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java:100 -msgid "{ce}This team does not exists." -msgstr "{ce}Cette équipe n'existe pas." +#~ msgid "{darkgray}» {white}Click {gray}to remove this player" +#~ msgstr "{darkgray}» {white}Cliquez {gray}pour retirer ce joueur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java:131 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:100 -msgid "{ce}Unable to retrieve the player {0}." -msgstr "{ce]Impossible de trouver le joueur {0}." +#~ msgid "{darkgray}» {white}Click {gray}to add this player" +#~ msgstr "{darkgray}» {white}Cliquez {gray}pour ajouter ce joueur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java:134 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:103 -msgid "" -"{ce}In offline mode, you cannot add players if they never came to this " -"server." -msgstr "" -"{ce}En mode hors-ligne, vous ne pouvez pas ajouter de joueurs qui ne se sont " -"jamais connectés." +#~ msgid "{0} » {black}Color" +#~ msgstr "{0} » {black}Couleur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java:143 -msgid "{cs}The player {0} was successfully added to the team {1}" -msgstr "{cs}Le joueur {0} a été ajouté à l'équipe {1}{cs} avec succès." +#~ msgid "Teams » {black}{0}" +#~ msgstr "Équipes » {black}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamJoinCommand.java:190 -msgid "" -"{cc}/uh team join <player> <teamName ...> {ci}: adds a player inside the " -"given team. The name of the team is it color, or the explicit name given." -msgstr "" -"{cc}/uh team join <joueur> <nomÉquipe ...> {ci}: ajoute un joueur dans " -"l'équipe donnée. Le nom de l'équipe est sa couleur, ou le nom explicite " -"donné." +#~ msgid "{white}{0} {gray}member" +#~ msgid_plural "{white}{0} {gray}members" +#~ msgstr[0] "{white}{0} {gray}membre" +#~ msgstr[1] "{white}{0} {gray}membres" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java:67 -msgid "{cs}All teams where removed." -msgstr "{cs}Toutes les équipes ont été supprimées." +#~ msgid "{white}Click with a banner {gray}to update this team's banner" +#~ msgstr "" +#~ "{white}Cliquez avec une bannière {gray}pour changer la bannière de " +#~ "l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java:93 -msgid "{cc}/uh team reset {ci}: removes all teams." -msgstr "{cc}/uh team reset {ci}: supprime toutes les équipes." +#~ msgid "{green}Update the color" +#~ msgstr "{green}Changer la couleur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:79 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:105 -msgid "" -"{ce}Unable to add the team, check the color name. Tip: use Tab to " -"autocomplete." -msgstr "" -"{ce}Impossible d'ajouter l'équipe ; vérifiez le nom de la couleur. Conseil : " -"utilisez l'autocomplétion." +#~ msgctxt "current_team_color" +#~ msgid "{gray}Current: {white}{0}" +#~ msgstr "{gray}Actuelle : {white}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:93 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:121 -msgid "{cs}Team {0}{cs} added." -msgstr "{cs}Équipe {0}{cs} ajoutée." +#~ msgid "{green}Rename the team" +#~ msgstr "{green}Renommer l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamAddCommand.java:163 -msgid "" -"{cc}/uh team add <color> [<name ...>] {ci}: adds a team with the provided " -"color." -msgstr "" -"{cc}/uh team add <couleur> [<nom ...>]{ci}: ajoute une équipe de la couleur " -"donnée." +#~ msgctxt "current_team_name" +#~ msgid "{gray}Current: {white}{0}" +#~ msgstr "{gray}Actuel : {white}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java:92 -msgid "{ce}The player {0} is disconnected and never logged in before!" -msgstr "" -"{ce}Le joueur {0} est déconnecté et ne s'est jamais connecté au serveur " -"auparavant !" +#~ msgid "{green}Add or remove players" +#~ msgstr "{green}Modifier les membres" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java:109 -msgid "{cs}The player {0} was successfully removed from his team." -msgstr "{cs}Le joueur {0} a été retiré de son équipe avec succès." +#~ msgid "{black}Select a team {reset}({0})" +#~ msgstr "{black}Sélectionnez votre équipe {reset}({0})" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamLeaveCommand.java:143 -msgid "{cc}/uh team leave <player> {ci}: removes a player from his team." -msgstr "{cc}/uh team leave <joueur> {ci}: retire un joueur de son équipe." +#~ msgid "{white}Rename your team" +#~ msgstr "{white}Renommer votre équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java:80 -msgid "{cs}Team {0} deleted." -msgstr "{cs}Équipe {0} supprimée." +#~ msgid "{gray}You have to be in a team" +#~ msgstr "{gray}Vous devez être dans une équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamRemoveCommand.java:119 -msgid "{cc}/uh team remove <name ...> {ci}: removes a team" -msgstr "{cc}/uh team remove <nom ...> {ci}: supprime une équipe." +#~ msgid "{white}New team" +#~ msgstr "{white}Nouvelle équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:70 -msgid "{ce}There isn't any team to show." -msgstr "{ce}Il n'y a pas d'équipe à lister." +#~ msgid "{blue}Players" +#~ msgstr "{blue}Joueurs" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:76 -#, java-format -msgid "{0} ({1} player)" -msgid_plural "{0} ({1} players)" -msgstr[0] "{0} ({1} joueur)" -msgstr[1] "{0} ({1} joueurs)" +#~ msgid "{darkgray}- {white}{0}" +#~ msgstr "{darkgray}- {white}{0}" -#. Player name after the online status dot in /uh teams list -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:92 -#, java-format -msgctxt "teams_list" -msgid "{0}" -msgstr "{0}" +#~ msgid "{darkgray}» {white}Click {gray}to join this team" +#~ msgstr "{darkgray}» {white}Cliquez {gray}pour rejoindre l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamListCommand.java:120 -msgid "{cc}/uh team list {ci}: lists the teams and their players." -msgstr "{cc}/uh team list {ci}: liste toutes les équipes et leurs membres." +#~ msgid "{darkgray}» {red}This team is full" +#~ msgstr "{darkgray}» {red}Cette équipe est pleine" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java:74 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java:77 -msgid "{ce}Either this team does not exists, or you are not in a team." -msgstr "{ce}Cette équipe n'existe pas, ou vous n'êtes pas dans une équipe." +#~ msgid "{darkgray}» {white}Click {gray}to leave this team" +#~ msgstr "{darkgray}» {white}Cliquez {gray}pour quitter l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java:78 -msgid "{ce}You must run this command with a banner in your main hand." -msgstr "" -"{ce}Vous devez avoir une bannière dans votre main principale pour lancer " -"cette commande." +#~ msgid "{darkgray}» {white}Right-click {gray}to manage this team" +#~ msgstr "{darkgray}» {white}Cliquez droit {gray}pour gérer cette équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java:83 -msgid "{cs}The banner of the team {0}{cs} was successfully updated." -msgstr "{cs}La bannière de l'équipe {0}{cs} a été mise à jour avec succès." +#~ msgid "{white}Team {0} {gray}({1}/{2})" +#~ msgstr "{white}Équipe {0} {gray}({1}/{2})" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerCommand.java:109 -msgid "" -"{cc}/uh team banner [team name ...] {ci}: updates the team's banner using " -"the banner in the sender hand. If the team name is not provided, uses the " -"sender's team." -msgstr "" -"{cc}/uh team banner [nom de l'équipe ...] {ci}: change la bannière de " -"l'équipe en utilisant la bannière dans la main de l'exécuteur. Si le nom de " -"l'équipe n'est pas spécifié, celle de l'exécuteur est utilisée." +#~ msgid "{white}Team {0} {gray}({1} player)" +#~ msgid_plural "{white}Team {0} {gray}({1} players)" +#~ msgstr[0] "{white}Équipe {0} {gray}({1} joueur)" +#~ msgstr[1] "{white}Équipe {0} {gray}({1} joueurs)" -#. Error message of /uh team bannerreset from the console without name -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java:71 -msgid "{ce}From the console, you must provide a team name." -msgstr "{ce}Depuis la console, vous devez préciser le nom d'une équipe." +#~ msgid "{red}No team created" +#~ msgstr "{cs}Aucune équipe créée" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java:82 -msgid "" -"{cs}The banner of the team {0}{cs} was successfully reset to the default one." -msgstr "{cs}La bannière de l'équipe {0}{cs} a été réinitialisée avec succès." +#~ msgid "{gray}Click the emerald button below to create one." +#~ msgstr "" +#~ "{gray}Cliquez sur le bouton d'émeraude ci-dessous pour en créer une." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamBannerResetCommand.java:108 -msgid "" -"{cc}/uh team bannerreset [team name ...] {ci}: resets the banner of the team " -"to the default. If the team name is not provided, uses the sender's team." -msgstr "" -"{cc}/uh team bannerreset [nom de l'équipe ...] {ci}: réinitialise la " -"bannière de l'équipe à celle générée par défaut. Si le nom de l'équipe n'est " -"pas spécifié, celle de l'exécuteur est utilisée." +#~ msgid "{gray}Wait for an administrator to create one." +#~ msgstr "{gray}Patientez le temps qu'un administrateur en ajoute une." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamGUICommand.java:80 -msgid "{cc}/uh team gui {ci}: opens a GUI to join and manage the teams." -msgstr "" -"{cc}/uh team gui {ci}: ouvre une interface graphique pour gérer et rejoindre " -"les équipes." +#~ msgid "{gray}1. {white}{bold}Team color" +#~ msgstr "{gray}1. {white}{bold}Couleur de l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java:70 -msgid "{ce}Cannot toggle the spy mode of {0} because he/she is offline." -msgstr "" -"{ce}Impossible d'inverser le mode d'espoinnage de {0} car il (ou elle) n'est " -"pas connecté(e)." +#~ msgid "{gray}2. {white}{bold}Team name" +#~ msgstr "{gray}2. {white}{bold}Nom de l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java:95 -msgid "{cs}Spy mode {darkred}disabled{cs} for {0}." -msgstr "{cs}Espoinnage {darkred}désactivé{cs} pour {0}." +#~ msgid "New team » {black}Name" +#~ msgstr "Nouvelle équipe » {black}Nom" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java:100 -msgid "{cs}Spy mode {darkgreen}enabled{cs} for {0}." -msgstr "{cs}Espionnage {darkgreen}activé{cs} pour {0}." +#~ msgid "" +#~ "{gray}When clicked, a sign will open; write the name of the team inside." +#~ msgstr "" +#~ "{gray}Cliquez ici pour ouvrir un panneau, et écrivez le nom de l'équipe " +#~ "dedans." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamSpyCommand.java:123 -msgid "" -"{cc}/uh team spy [player] {ci}: allows yourself (or the target player) to " -"receive all the team chats (read-only). Execute again to stop." -msgstr "" -"{cc}/uh team spy [joueur] {ci}: permet de recevoir (soit-même ou le joueur " -"ciblé) tous les chats d'équipe (en lecture seule). Exécutez une autre fois " -"pour interrompre." +#~ msgid "New team » {black}Color" +#~ msgstr "Nouvelle équipe » {black}Couleur" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTimersCommand.java:92 -msgid "{aqua}------ Timers commands ------" -msgstr "{aqua}------ Commandes liées aux comptes à rebours ------" +#~ msgid "{lightpurple}Random color" +#~ msgstr "{lightpurple}Couleur aléatoire" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTimersCommand.java:98 -msgid "{cc}/uh timers {ci}: manages the timers. See /uh timers for details." -msgstr "" -"{cc}/uh timers {ci}: gère les comptes à rebours. Consultez /uh timers pour " -"plus de détails." +#~ msgid "New team » {black}Members" +#~ msgstr "Nouvelle équipe » {black}Membres" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java:110 -msgid "{aqua}------ Team commands ------" -msgstr "{aqua}------ Commandes liées aux équipes ------" +#~ msgid "{blue}{bold}Summary" +#~ msgstr "{blue}{bold}Récapitulatif" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java:111 -msgid "" -"{cc}/join [player] <team ...> {ci}: adds “player” (or the sender) inside the " -"given team. Without arguments, displays the chat-based team selector." -msgstr "" -"{cc}/join [joueur] <équipe ...> {ci}: ajoute “joueur” (ou l'envoyeur) dans " -"l'équipe donnée. Sans argument, affiche le sélecteur d'équipe." +#~ msgid "{gray}Team name: {white}{0}" +#~ msgstr "{gray}Nom : {white}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java:112 -msgid "" -"{cc}/leave [player] {ci}: removes “player” (or the sender) from his team." -msgstr "" -"{cc}/leave [joueur] {ci}: retire “joueur” (ou l'envoyeur) de son équipe." +#~ msgid "{gray}Color: {0}" +#~ msgstr "{gray}Couleur : {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHTeamCommand.java:119 -msgid "{cc}/uh team {ci}: manages the teams. Execute /uh team for details." -msgstr "" -"{cc}/uh team {ci}: gère les équipes. Exécutez /uh team pour plus de détails." +#~ msgid "{gray}Members: {white}{0}" +#~ msgstr "{gray}Membres : {white}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java:83 -msgid "{aqua}------ Border commands ------" -msgstr "{aqua}------ Commandes liées aux bordures ------" +#~ msgid "{green}Create the team" +#~ msgstr "{green}Créer l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java:89 -msgid "{cc}/uh border {ci}: manages borders. Execute /uh border for details." -msgstr "" -"{cc}/uh border {ci}: gère la bordure. Exécutez /uh border pour plus de " -"détails." +#~ msgid "{lightpurple}Selected!" +#~ msgstr "{lightpurple}Ajouté !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java:94 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java:107 -msgid "{ce}Hey, this is not a number of half-hearts. It's a text. Pfff." -msgstr "" -"{ce}Hey, ce n'est pas un nombre de demi-coeurs... C'est un texte... Pfff." +#~ msgid "{darkgray}» {white}Click {gray}to add to the team" +#~ msgstr "{darkgray}» {white}Cliquez {gray}pour l'ajouter à l'équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java:101 -msgid "{ce}Serial killer!" -msgstr "{ce}S'pèce de tueur en série !" +#~ msgid "{cs}Team created." +#~ msgstr "{cs}Équipe créée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java:112 -msgid "{ce}The health of {0} was not updated to avoid a kill." -msgstr "{ce}La vie de {0} n'a pas été changée, pour ne pas le/la tuer." +#~ msgid "{ce}This team already exists." +#~ msgstr "{ce}Cette équipe existe déjà." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealAllCommand.java:140 -msgid "" -"{cc}/uh healall [half-hearts=20|±diff] {ci}: heals all players instead of " -"only one." -msgstr "" -"{cc}/uh healall [demi-coeurs=20|±diff] {ci}: change la vie de tous les " -"joueurs, et non d'un seul." +#~ msgid "{cs}Your team is now called {0}{cs}." +#~ msgstr "{cs}Votre équipe s'appelle désormais {0}{cs}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java:67 -msgid "the console" -msgstr "la console" +#~ msgid "{aqua}You are now in the {0}{aqua} team." +#~ msgstr "{aqua}Vous faites désormais partie de l'équipe {0}{aqua}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java:72 -msgid "" -"{ce}You can't shift the current episode because the game is not started." -msgstr "" -"{ce}Vous ne pouvez pas passer l'épisode actuel car le jeu n'a pas démarré." +#~ msgid "{darkaqua}You are no longer part of the {0}{darkaqua} team." +#~ msgstr "{darkaqua}Vous ne faites plus partie de l'équipe {0}{darkaqua}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java:91 -msgid "{cc}/uh shift {ci}: shifts an episode." -msgstr "{cc}/uh shift {ci}: passe un épisode." +#~ msgid "{ce}You are not allowed to send a private message to your team." +#~ msgstr "" +#~ "{ce}Vous n'avez pas le droit d'envoyer des messages privés à votre équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:75 -msgid "{cst}Generating the walls..." -msgstr "{cst}Génération des murs en cours..." +#~ msgid "" +#~ "{ce}You are not allowed to enter in the private chat of another team." +#~ msgstr "" +#~ "{ce}Vous n'avez pas le droit d'entrer dans le chat privé d'une autre " +#~ "équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:90 -msgid "{ci}From the console, generating the walls of the default world, {0}" -msgstr "{ci}Depuis la console, génération du mur du monde par défaut, {0}" +#~ msgid "{gold}[{0}{gold} -> his team] {reset}{1}" +#~ msgstr "{gold}[{0}{gold} -> son équipe] {reset}{1}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:100 -msgid "" -"{ce}Unable to generate the wall: see logs for details. The blocks set in the " -"config are probably invalid." -msgstr "" -"{ce}Impossible de générer le mur: voir logs pour plus de détails. Les blocs " -"configurés sont probablement invalide." +#~ msgid "{ce}You are not in a team!" +#~ msgstr "{ce}Vous n'êtes pas dans une équipe !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:106 -msgid "{ce}An error occurred, see console for details." -msgstr "" -"{ce}Une erreur s'est produite, consultez la console pour plus de détails." +#~ msgid "{gold}[{0}{gold} -> team {1}{gold}] {reset}{2}" +#~ msgstr "{gold}[{0}{gold} -> équipe {1}{gold}] {reset}{2}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:111 -msgid "{cst}Generation done." -msgstr "{cst}Génération terminée." +#~ msgid "{gold}Click on the names below to join a team" +#~ msgstr "{gold}Cliquez ci-dessous pour rejoindre une équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHGenerateWallsCommand.java:137 -msgid "" -"{cc}/uh generatewalls {ci}: generates the walls according to the " -"configuration." -msgstr "{cc}/uh generatewalls {ci}: génère les murs suivant la configuration." +#~ msgid "{0} ({red}dead{reset})" +#~ msgstr "{0} ({red}mort{reset})" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java:72 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java:81 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java:72 -msgid "{ce}This timer is not registered." -msgstr "{ce}Ce compteur n'est pas enregistré." +#~ msgid "{0} ({green}alive{reset})" +#~ msgstr "{0} ({green}en vie{reset})" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java:77 -msgid "{cs}The timer {0}{cs} was stopped." -msgstr "{cs}Le compteur {0}{cs} a été arrêté." +#~ msgid "{gray}[{white}{0}{gray}/{white}{1}{gray}]" +#~ msgstr "{gray}[{white}{0}{gray}/{white}{1}{gray}]" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java:102 -msgid "" -"{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be " -"removed from the scoreboard." -msgstr "" -"{cc}/uh timers stop <title ...> {ci}: force l'arrêt d'un compteur. Il est " -"retiré du scoraboard." +#~ msgid "{0} player in this team" +#~ msgid_plural "{0} players in this team" +#~ msgstr[0] "{0} joueur dans cette équipe" +#~ msgstr[1] "{0} joueurs dans cette équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java:82 -msgid "{cs}The timer {0}{cs} was started." -msgstr "{cs}Le compteur {0}{cs} a démarré." +#~ msgid "You are in the team {0}" +#~ msgstr "Vous êtes dans l'équipe {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java:107 -msgid "{cc}/uh timers start <title ...> {ci}: starts a timer." -msgstr "{cc}/uh timers start <titre ...> {ci}: démarre un compte à rebours." +#~ msgid "{darkred}[×] {red}Click here to leave your team" +#~ msgstr "{darkred}[×] {red}Cliquez ici pour quitter votre équipe" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java:76 -msgid "{cs}The timer {0}{cs} is now hidden." -msgstr "{cs}Le compteur {0}{cs} est désormais masqué." +#~ msgid "{gray}Run /join to display this again" +#~ msgstr "{gray}Exécutez /join pour réafficher ceci" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java:101 -msgid "" -"{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. " -"Don't stops the timer." -msgstr "" -"{cc}/uh timers hide <titre ...> {ci}: retire un compteur du scoreboard. " -"N'arrête pas le compteur." +#~ msgid "{ce}There isn't any team available." +#~ msgstr "{ce}Il n'y a aucune équipe disponible." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java:65 -msgid "{ci}{0} timer is registered." -msgid_plural "{ci}{0} timers are registered." -msgstr[0] "{ci}Il y a {0} compteur enregistré." -msgstr[1] "{ci}Il y a {0} compteurs enregistrés." +#~ msgid "" +#~ "{darkpurple}{obfuscated}----{lightpurple}{italic} YOU CAN " +#~ "RESPAWN{lightpurple}, just click {italic}Respawn {lightpurple}on the next " +#~ "screen." +#~ msgstr "" +#~ "{darkpurple}{obfuscated}----{lightpurple}{italic} VOUS POUVEZ " +#~ "REVENIR{lightpurple}, cliquez sur {italic}Ressusciter {lightpurple}sur " +#~ "l'écran suivant." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java:73 -msgid "{yellow} • {{ci}{0}{ci} - total {1} second - {2}" -msgid_plural "{yellow} • {{ci}{0}{ci} - total {1} seconds - {2}" -msgstr[0] "{yellow} • {ci}{0}{ci} - {1} seconde au total - {2}" -msgstr[1] "{yellow} • {ci}{0}{ci} - {1} secondes au total - {2}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java:82 -msgid "{green} • {ci}{0}{ci} - total {1} second - {2}" -msgid_plural "{green} • {ci}{0}{ci} - total {1} seconds - {2}" -msgstr[0] "{green} • {ci}{0}{ci} - {1} seconde au total - {2}" -msgstr[1] "{green} • {ci}{0}{ci} - {1} secondes au total - {2}" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java:92 -msgid "{red} • {ci}{0}{ci} - total {1} second" -msgid_plural "{red} • {ci}{0}{ci} - total {1} seconds" -msgstr[0] "{red} • {ci}{0}{ci} - {1} seconde au total" -msgstr[1] "{red} • {ci}{0}{ci} - {1} secondes au total" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersListCommand.java:123 -msgid "{cc}/uh timers list {ci}: lists the registered timers." -msgstr "{cc}/uh timers list {ci}: liste les compteurs enregistrés." +#~ msgid "{darkred}[UHC] {ce}WorldBorder is not installed: no borders' check!" +#~ msgstr "" +#~ "{darkred}[UHC] {ce}WorldBorder pas installé : bordures non surveillées !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java:76 -msgid "{cs}The timer {0}{cs} is now displayed." -msgstr "{cs}Le compteur {0}{cs} est désormais affiché." +#~ msgid "" +#~ "{gray}Also, without WorldBorder, the border can't be reduced during the " +#~ "game (warnings excluded)." +#~ msgstr "" +#~ "{gray}Aussi, sans WorldBorder, impossible de réduire la bordure pendant " +#~ "le jeu (sauf avertissements)." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java:101 -msgid "" -"{cc}/uh timers display <title ...> {ci}: displays a timer in the scoreboard. " -"Automatic when a timer is started." -msgstr "" -"{cc}/uh timers display <titre ...> {ci}: affiche un compteur dans le " -"scoreboard. Automatique au démarrage du compteur." +#~ msgid "" +#~ "{gray}Just install the plugin; UHPlugin will automatically configure it." +#~ msgstr "" +#~ "{gray}Installez le plugin ; UHPlugin va automatiquement le configurer." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java:79 -msgid "{cs}The timer {0}{cs} has been deleted." -msgstr "{cs}Le compteur {0}{cs} a été supprimé." +#~ msgid "{darkred}[UHC] {ce}ProtocolLib is needed but not installed!" +#~ msgstr "{darkred}[UHC] {ce}ProtocolLib est requis mais non installé !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java:104 -msgid "{cc}/uh timers remove <title ...> {ci}: deletes a timer." -msgstr "{cc}/uh timers remove <title ...> {ci}: supprime un compteur." +#~ msgid "{gray}The following options require the presence of ProtocolLib:" +#~ msgstr "{gray}Les options suivantes requièrent la présence de ProtocolLib :" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java:77 -msgid "{cs}The timer {0}{cs} was resumed." -msgstr "{cs}Le compteur {0}{cs} n'est plus en pause." +#~ msgctxt "protocollib_option" +#~ msgid "{darkgray} - {gray}{0}" +#~ msgstr "{darkgray} - {gray}{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java:102 -msgid "{cc}/uh timers resume <title ...> {ci}: resumes a timer." -msgstr "" -"{cc}/uh timers resume <title ...> {ci}: redémarre un compteur après une " -"pause." +#~ msgid "{gray}ProtocolLib is available here: {0}" +#~ msgstr "{gray}ProtocolLib est disponible ici : {0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java:86 -msgid "{cs}The duration of the timer {0}{cs} is now {1}." -msgstr "{cs}La durée du compteur {0}{cs} est désormais {1}." +#~ msgid "{cs}The timer before the new border is up!" +#~ msgstr "{cs}Le temps imparti avant la nouvelle bordure est écoulé !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java:91 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java:91 -msgid "" -"{ce}The duration' syntax is invalid; accepted formats are mm, mm:ss or hh:mm:" -"ss." -msgstr "" -"{ce}La syntaxe de la durée entrée est invalide, les formats acceptés sont " -"mm, mm:ss ou hh:mm:ss." +#~ msgid "{white}{0}{gray} player killed" +#~ msgid_plural "{white}{0}{gray} players killed" +#~ msgstr[0] "{white}{0}{gray} joueur tué" +#~ msgstr[1] "{white}{0}{gray} joueurs tués" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersSetCommand.java:124 -msgid "" -"{cc}/uh timers set <duration> <title ...> {ci}: sets the duration of a timer." -msgstr "" -"{cc}/uh timers set <durée> <titre ...> {ci}: modifie la durée d'un compte à " -"rebours." +#~ msgid "{aqua}------ Spawns points commands ------" +#~ msgstr "{aqua}------ Commandes de gestion des points de démarrage ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java:78 -msgid "{ce}A timer called {0}{ce} already exists; please choose another name." -msgstr "{ce}Un compteur nommé {0}{ce} existe déjà, choisissez un autre nom." +#~ msgid "" +#~ "{cc}/uh spawns {ci}: manages the spawn points. Execute /uh spawns for " +#~ "details." +#~ msgstr "" +#~ "{cc}/uh spawns {ci}: gère les points de démarrage. Exécutez /uh spawns " +#~ "pour plus de détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java:86 -msgid "{cs}The timer {0}{cs} (duration {1}) has been registered." -msgstr "{cs}Le compteur {0}{cs}, de durée {1}, a bien été enregistré." +#~ msgid "{aqua}------ Teleportation commands ------" +#~ msgstr "{aqua}------ Commandes de téléportation ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersAddCommand.java:111 -msgid "{cc}/uh timers add <duration> <title ...> {ci}: adds a timer." -msgstr "" -"{cc}/uh timers add <durée> <titre ...> {ci}: ajoute un compte à rebours." +#~ msgid "" +#~ "{cc}/uh tp team <x> <y> <z> | <target> <team ...> {ci}: teleports the " +#~ "team to the given location/target." +#~ msgstr "" +#~ "{cc}/uh tp team <x> <y> <z> | <target> <team ...> {ci}: téléporte une " +#~ "équipe au lieu ou au joueur indiqué." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java:77 -msgid "{cs}The timer {0}{cs} is now paused." -msgstr "{cs}Le compteur {0}{cs} est désormais en pause." +#~ msgid "" +#~ "{cc}/uh tp spectators <x> <y> <z> | <target> {ci}: teleports the " +#~ "spectators (aka non-alive players) to the given location/target." +#~ msgstr "" +#~ "{cc}/uh tp spectators <x> <y> <z> | <target> {ci}: téléporte les " +#~ "spectateurs (i.e. les joueurs non-vivants) au lieu ou au joueur indiqué." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java:102 -msgid "{cc}/uh timers pause <title ...> {ci}: pauses a timer." -msgstr "{cc}/uh timers pause <titre ...> {ci}: met en pause un comparateur." +#~ msgid "" +#~ "{cc}/uh tp {ci}: teleports the spectators or an entire team. See /uh tp " +#~ "for details." +#~ msgstr "" +#~ "{cc}/uh tp {ci}: téléporte les spectateurs ou une équipe. Consultez /uh " +#~ "tp pour plus de détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:61 -msgid "{ce}You cannot load unknown players in offline mode, sorry." -msgstr "" -"{ce}Vous ne pouvez pas charger des joueurs inconnus en mode hors-ligne, " -"désolé." +#~ msgid "" +#~ "{cc}/uh about {ci}: informations about the plugin and the translation." +#~ msgstr "" +#~ "{cc}/uh about {ci}: informations à propos du plugin et des traductions." -#. Error returned if one calls /uh loadplayers without arguments. -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:68 -msgid "{ce}You need to provide at least one player name." -msgstr "{ce}Vous devez spécifier au moins un nom de joueur." +#~ msgid "" +#~ "{cc}/uh border warning <futureDiameter> [minutesBeforeReduction]{ci}: " +#~ "warns all players outside the given future diameter. It's just a notice, " +#~ "nothing else." +#~ msgstr "" +#~ "{cc}/uh border warning <futurDiamètre> [minutesAvantRéduction] {ci}: " +#~ "avertit tous les joueurs hors de la future bordure donnée. Ce n'est qu'un " +#~ "avertissement, rien de plus." -#. Message displayed when the /uh loadplayers command is used, as the execution may take some time. -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:73 -msgid "{cst}Loading players..." -msgstr "{cst}Chargement des joueurs..." +#~ msgid "{cc}/uh border warning cancel{ci}: cancels a previously-set warning." +#~ msgstr "" +#~ "{cc}/uh border warning cancel {ci}: annule un précédent avertissement." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:80 -msgid "{cs}Loaded {0} player successfully." -msgid_plural "{cs}Loaded {0} players successfully." -msgstr[0] "{cs}{0} joueur a été chargé." -msgstr[1] "{cs}{0} joueurs ont été chargés." +#~ msgid "" +#~ "{ce}WARNING: {ci}because WorldBorder is not installed, players out of the " +#~ "border will not be teleported!" +#~ msgstr "" +#~ "{ce}ATTENTION: {ci}WorldBorder n'étant pas installé, les joueurs hors de " +#~ "la bordure ne seront pas téléportés !" -#. Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:88 -msgid "{ce}{0} player is missing: {1}." -msgid_plural "{ce}{0} players are missing: {1}." -msgstr[0] "{ce}Il manque {0} joueur : {1}." -msgstr[1] "{ce}Il manque {0} joueurs : {1}." +#~ msgid "" +#~ "{cc}/uh border set <diameter> [force]{ci}: changes the size of the map. " +#~ "If force is not given, the operation will be canceled if there is a " +#~ "player outside the border." +#~ msgstr "" +#~ "{cc}/uh border set <diamètre> [force] {ci}: change la taille de la carte. " +#~ "Si le paramètre “force” n'est pas donné, l'opération sera annulée s'il " +#~ "existe des joueurs hors de la bordure." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHLoadPlayersCommand.java:108 -msgid "" -"{cc}/uh loadplayers <pseudo> [pseudo] ... {ci}: loads the given players in " -"the server so they can be added to teams even if they never logged in." -msgstr "" -"{cc}/uh loadplayers <pseudo> [pseudo] ... {ci}: charges les joueurs " -"spécifiés afin qu'il puissent être ajoutés dans une équipe même s'ils ne se " -"sont jamais connectés au serveur." +#~ msgid "" +#~ "{cc}/uh border check <diameter>{ci}: returns a list of the players " +#~ "outside the given border size." +#~ msgstr "" +#~ "{cc}/uh border check <diamètre> {ci}: retourne la liste des joueurs hors " +#~ "de la bordure." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:92 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:116 -msgid "{cst}You where frozen by {0}." -msgstr "{cst}Vous avez été immobilisé(e) par {0}." +#~ msgid "{cc}/uh border get{ci}: returns the current size of the map." +#~ msgstr "{cc}/uh border get {ci}: retourne la taille actuelle de la carte." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:96 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:121 -msgid "{cst}You where unfrozen by {0}." -msgstr "{cst}Vous avez été libéré(e) par {0}." +#~ msgid "" +#~ "{cc}/uh feedall [foodPoints=20] [saturation=max] {ci}: feeds all players." +#~ msgstr "" +#~ "{cc}/uh feedall [faim=20] [saturation=max] {ci}: nourrit tous les joueurs." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:117 -msgid "{cs}{0} is now frozen." -msgstr "{cs}{0} est désormais immobilisé(e)." +#~ msgid "{ce}The player {0} is not online." +#~ msgstr "{ce}Le joueur {0} n'est pas connecté." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:122 -msgid "{cs}{0} is now unfrozen." -msgstr "{cs}{0} est désormais libéré(e)." +#~ msgid "" +#~ "{cc}/uh tpback <player> [force] {ci}: safely teleports back a player to " +#~ "his death location." +#~ msgstr "" +#~ "{cc}/uh tpback <joueur> [force] {ci}: téléporte un joueur au lieu de sa " +#~ "mort en toute sécurité." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:137 -msgid "{darkaqua}The entire game is now frozen." -msgstr "{darkaqua}Le jeu est désormais en pause." +#~ msgid "" +#~ "{cc}/uh tpspawn <player> [force] {ci}: safely teleports back a player to " +#~ "his spawn location." +#~ msgstr "" +#~ "{cc}/uh tpspawn <joueur> [force] {ci}: téléporte un joueur à son point de " +#~ "démarrage attribué en toute sécurité." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:141 -msgid "{darkaqua}The game is now unfrozen." -msgstr "{darkaqua}Le jeu n'est plus en pause." +#~ msgid "" +#~ "{cs}Because {0} is offline, he will be resurrected when he logins. If he " +#~ "was, he is no longer banned." +#~ msgstr "" +#~ "{cs}Comme {0} est déconnecté, il sera ressuscité dés qu'il se connectera. " +#~ "S'il l'était, il n'est plus banni." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:181 -msgid "{aqua}------ Freeze commands ------" -msgstr "{aqua}------ Commandes liées à l'immobilisation ------" +#~ msgid "{ce}{0} is not dead!" +#~ msgstr "{ce}{0} n'est pas mort !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:182 -msgid "" -"{cc}/uh freeze on [player]{ci}: freezes a player, or the sender without a " -"specified player." -msgstr "" -"{cc}/uh freeze on [joueur] {ci}: immobilise un joueur, ou l'exécuteur sans " -"joueur spécifié." +#~ msgid "{cc}/uh resurrect <player> {ci}: resurrects a player." +#~ msgstr "{cc}/uh resurrect <joueur> {ci}: fait revivre un joueur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:183 -msgid "" -"{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if " -"the entire game is frozen." -msgstr "" -"{cc}/uh freeze off [player] {ci}: libère un joueur (ou l'envoyeur), même si " -"le jeu est en pause." +#~ msgid "{ce}This team does not exists." +#~ msgstr "{ce}Cette équipe n'existe pas." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:184 -msgid "{cc}/uh freeze all{ci}: freezes the entire game (players, mobs, timer)." -msgstr "" -"{cc}/uh freeze all {ci}: met le jeu en pause (immobilise les joueurs, mobs, " -"et le compteur)." +#~ msgid "{cs}The player {0} was successfully added to the team {1}" +#~ msgstr "{cs}Le joueur {0} a été ajouté à l'équipe {1}{cs} avec succès." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:185 -msgid "" -"{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this " -"in order to relaunch the timer." -msgstr "" -"{cc}/uh freeze none {ci}: relance le jeu. Vous DEVEZ exécuter ceci pour " -"relancer le compteur." +#~ msgid "" +#~ "{cc}/uh team join <player> <teamName ...> {ci}: adds a player inside the " +#~ "given team. The name of the team is it color, or the explicit name given." +#~ msgstr "" +#~ "{cc}/uh team join <joueur> <nomÉquipe ...> {ci}: ajoute un joueur dans " +#~ "l'équipe donnée. Le nom de l'équipe est sa couleur, ou le nom explicite " +#~ "donné." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFreezeCommand.java:192 -msgid "" -"{cc}/uh freeze {ci}: (un)freezes the entire game, or a player. See /uh " -"freeze for details." -msgstr "" -"{cc}/uh freeze {ci}: (dés)immobilise l'ensemble du jeu, ou un joueur. " -"Consultez /uh freeze pour plus de détails." +#~ msgid "{cs}All teams where removed." +#~ msgstr "{cs}Toutes les équipes ont été supprimées." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java:73 -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java:72 -msgid "{ce}This player is offline." -msgstr "{ce}Ce joueur n'est pas connecté." +#~ msgid "{cc}/uh team reset {ci}: removes all teams." +#~ msgstr "{cc}/uh team reset {ci}: supprime toutes les équipes." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java:115 -msgid "{ce}You can't kill a player with this command, to avoid typo fails." -msgstr "" -"{ce}Vous ne pouvez pas tuer un joueur avec cette commande, pour éviter toute " -"faute de frappe." +#~ msgid "" +#~ "{ce}Unable to add the team, check the color name. Tip: use Tab to " +#~ "autocomplete." +#~ msgstr "" +#~ "{ce}Impossible d'ajouter l'équipe ; vérifiez le nom de la couleur. " +#~ "Conseil : utilisez l'autocomplétion." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHHealCommand.java:143 -msgid "" -"{cc}/uh heal <player> [half-hearts=20|±diff] {ci}: heals a player to the " -"number of half-hearts provided (default 20)." -msgstr "" -"{cc}/uh heal <joueur> [demi-coeurs=20|±diff] {ci}: change la vie d'un joueur " -"avec le nombre de demi-coeurs donné (par défaut, 20)." +#~ msgid "{cs}Team {0}{cs} added." +#~ msgstr "{cs}Équipe {0}{cs} ajoutée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFeedCommand.java:125 -msgid "" -"{cc}/uh feed <player> [foodPoints=20] [saturation=max] {ci}: feeds a player." -msgstr "" -"{cc}/uh feed <joueur> [faim=20] [saturation=max] {ci}: nourrit un joueur." +#~ msgid "" +#~ "{cc}/uh team add <color> [<name ...>] {ci}: adds a team with the provided " +#~ "color." +#~ msgstr "" +#~ "{cc}/uh team add <couleur> [<nom ...>]{ci}: ajoute une équipe de la " +#~ "couleur donnée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java:77 -msgid "{ce}This player was never seen on this server." -msgstr "{ce}Cette personne n'a jamais été vue sur le serveur." +#~ msgid "{ce}The player {0} is disconnected and never logged in before!" +#~ msgstr "" +#~ "{ce}Le joueur {0} est déconnecté et ne s'est jamais connecté au serveur " +#~ "auparavant !" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java:92 -msgid "{cs}The player {0} is now marked as dead." -msgstr "{cs}Le joueur {0} est désormais marqué comme mort." +#~ msgid "{cs}The player {0} was successfully removed from his team." +#~ msgstr "{cs}Le joueur {0} a été retiré de son équipe avec succès." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java:96 -msgid "{ce}{0} is not an alive player." -msgstr "{ce}{0} n'est pas un joueur vivant." +#~ msgid "{cc}/uh team leave <player> {ci}: removes a player from his team." +#~ msgstr "{cc}/uh team leave <joueur> {ci}: retire un joueur de son équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHKillCommand.java:127 -msgid "" -"{cc}/uh kill <player> {ci}: mark a player as dead, even if he is offline." -msgstr "" -"{cc}/uh kill <joueur> {ci}: marque un joueur comme mort, même s'il est hors-" -"ligne." +#~ msgid "{cs}Team {0} deleted." +#~ msgstr "{cs}Équipe {0} supprimée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:99 -msgid "" -"{ce}The game is already started! Reload or restart the server to restart the " -"game." -msgstr "" -"{ce}Le jeu est déjà démarré ! Rechargez ou redémarrez le serveur pour " -"redémarrer." +#~ msgid "{cc}/uh team remove <name ...> {ci}: removes a team" +#~ msgstr "{cc}/uh team remove <nom ...> {ci}: supprime une équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:133 -msgid "{aqua}------ Beginning of the game ------" -msgstr "{aqua}------ Démarrage du jeu ------" +#~ msgid "{ce}There isn't any team to show." +#~ msgstr "{ce}Il n'y a pas d'équipe à lister." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:134 -msgid "{cc}/uh start {ci}: starts the game. Period." -msgstr "{cc}/uh start {ci}: démarre le jeu, tout simplement." +#~ msgid "{0} ({1} player)" +#~ msgid_plural "{0} ({1} players)" +#~ msgstr[0] "{0} ({1} joueur)" +#~ msgstr[1] "{0} ({1} joueurs)" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:135 -msgid "{aqua}Startup options" -msgstr "{aqua}Options de démarrage" +#~ msgctxt "teams_list" +#~ msgid "{0}" +#~ msgstr "{0}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:136 -msgid "" -"{ci}You can add some tags to change the way the game is started, just append " -"them to the command with spaces." -msgstr "" -"{ci}Vous pouvez ajouter des options pour changer la manière dont le jeu est " -"démarré. Pour ce faire, ajoutez les tags suivant après la commande (séparés " -"par des espaces)." +#~ msgid "{cc}/uh team list {ci}: lists the teams and their players." +#~ msgstr "{cc}/uh team list {ci}: liste toutes les équipes et leurs membres." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:137 -msgid "" -"{cc}slow:true {ci}: launches the game slowly, in two steps (teleportation " -"then beginning of the game), for smaller servers." -msgstr "" -"{cc}slow:true {ci}: lance le jeu doucement, en deux étapes (téléportation " -"puis commencement), pour les plus petits serveurs." +#~ msgid "{ce}Either this team does not exists, or you are not in a team." +#~ msgstr "{ce}Cette équipe n'existe pas, ou vous n'êtes pas dans une équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:138 -msgid "" -"{cc}ignoreTeams:true {ci}: even with teams, teleports the players like in a " -"solo game (only one player per spawn point, not a spawn point per team)." -msgstr "" -"{cc}ignoreTeams:true {ci}: même avec des équipes, téléporte les joueurs " -"comme pour un jeu solo (uniquement un joueur par point de démarrage, et non " -"un point par équipe)." +#~ msgid "{ce}You must run this command with a banner in your main hand." +#~ msgstr "" +#~ "{ce}Vous devez avoir une bannière dans votre main principale pour lancer " +#~ "cette commande." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHStartCommand.java:145 -msgid "" -"{cc}/uh start {ci}: launches the game. See /uh start help for options (slow " -"and ignoreTeams)." -msgstr "" -"{cc}/uh start {ci}: lance le jeu. Consultez /uh start help pour les options " -"de démarrage (lent, en ignorant les équipes)." +#~ msgid "{cs}The banner of the team {0}{cs} was successfully updated." +#~ msgstr "{cs}La bannière de l'équipe {0}{cs} a été mise à jour avec succès." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:109 -msgid "{cs}The player {0} is now a spectator." -msgstr "{cs}Le joueur {0} est désormais un spectateur." +#~ msgid "" +#~ "{cc}/uh team banner [team name ...] {ci}: updates the team's banner using " +#~ "the banner in the sender hand. If the team name is not provided, uses the " +#~ "sender's team." +#~ msgstr "" +#~ "{cc}/uh team banner [nom de l'équipe ...] {ci}: change la bannière de " +#~ "l'équipe en utilisant la bannière dans la main de l'exécuteur. Si le nom " +#~ "de l'équipe n'est pas spécifié, celle de l'exécuteur est utilisée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:129 -msgid "{ce}The player {0} was not found." -msgstr "{ce}Le joueur {0} n'a pas été trouvé." +#~ msgid "{ce}From the console, you must provide a team name." +#~ msgstr "{ce}Depuis la console, vous devez préciser le nom d'une équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:134 -msgid "{cs}The player {0} is now a player." -msgstr "{cs}Le joueur {0} est désormais un joueur." +#~ msgid "" +#~ "{cs}The banner of the team {0}{cs} was successfully reset to the default " +#~ "one." +#~ msgstr "" +#~ "{cs}La bannière de l'équipe {0}{cs} a été réinitialisée avec succès." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:144 -msgid "{ce}There isn't any spectator to list." -msgstr "{ce}Il n'y a pas de spectateur à lister." +#~ msgid "" +#~ "{cc}/uh team bannerreset [team name ...] {ci}: resets the banner of the " +#~ "team to the default. If the team name is not provided, uses the sender's " +#~ "team." +#~ msgstr "" +#~ "{cc}/uh team bannerreset [nom de l'équipe ...] {ci}: réinitialise la " +#~ "bannière de l'équipe à celle générée par défaut. Si le nom de l'équipe " +#~ "n'est pas spécifié, celle de l'exécuteur est utilisée." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:148 -msgid "{ci}{0} registered spectator." -msgid_plural "{ci}{0} registered spectators." -msgstr[0] "{ci}{0} spectateur enregistré." -msgstr[1] "{ci}{0} spectateurs enregistrés." +#~ msgid "{cc}/uh team gui {ci}: opens a GUI to join and manage the teams." +#~ msgstr "" +#~ "{cc}/uh team gui {ci}: ouvre une interface graphique pour gérer et " +#~ "rejoindre les équipes." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:149 -msgid "{ci}This count includes only the initial spectators." -msgstr "{ci}Ce compte inclue uniquement les spectateurs initiaux." +#~ msgid "{ce}Cannot toggle the spy mode of {0} because he/she is offline." +#~ msgstr "" +#~ "{ce}Impossible d'inverser le mode d'espoinnage de {0} car il (ou elle) " +#~ "n'est pas connecté(e)." -#. A list item in the startup spectators list -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:154 -msgctxt "startup_specs" -msgid "{lightpurple} - {0}" -msgstr "{lightpurple} - {0}" +#~ msgid "{cs}Spy mode {darkred}disabled{cs} for {0}." +#~ msgstr "{cs}Espoinnage {darkred}désactivé{cs} pour {0}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:191 -msgid "{aqua}------ Startup spectators commands ------" -msgstr "{aqua}------ Commandes liées aux spectateurs initiaux ------" +#~ msgid "{cs}Spy mode {darkgreen}enabled{cs} for {0}." +#~ msgstr "{cs}Espionnage {darkgreen}activé{cs} pour {0}." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:193 -msgid "{cc}/uh spec add <player>{ci}: adds a startup spectator." -msgstr "{cc}/uh spec add <joueur> {ci}: ajoute un spectateur initial." +#~ msgid "" +#~ "{cc}/uh team spy [player] {ci}: allows yourself (or the target player) to " +#~ "receive all the team chats (read-only). Execute again to stop." +#~ msgstr "" +#~ "{cc}/uh team spy [joueur] {ci}: permet de recevoir (soit-même ou le " +#~ "joueur ciblé) tous les chats d'équipe (en lecture seule). Exécutez une " +#~ "autre fois pour interrompre." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:194 -msgid "{cc}/uh spec remove <player>{ci}: removes a startup spectator." -msgstr "{cc}/uh spec remove <joueur> {ci}: supprime un spectateur initial." +#~ msgid "{aqua}------ Timers commands ------" +#~ msgstr "{aqua}------ Commandes liées aux comptes à rebours ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:195 -msgid "{cc}/uh spec list{ci}: lists the startup spectators." -msgstr "{cc}/uh spec list {ci}: liste les spectateurs initiaux." +#~ msgid "{cc}/uh timers {ci}: manages the timers. See /uh timers for details." +#~ msgstr "" +#~ "{cc}/uh timers {ci}: gère les comptes à rebours. Consultez /uh timers " +#~ "pour plus de détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHSpectatorsCommand.java:203 -msgid "" -"{cc}/uh spec {ci}: manages the spectators. Execute /uh spec for details." -msgstr "" -"{cc}/uh spec {ci}: gère les spectateurs. Exécutez /uh spec pour plus de " -"détails." +#~ msgid "{aqua}------ Team commands ------" +#~ msgstr "{aqua}------ Commandes liées aux équipes ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java:63 -msgid "{ce}No rules are set in the config file." -msgstr "{ce}Aucune règle n'est enregistrée dans le fichier de configuration." +#~ msgid "" +#~ "{cc}/join [player] <team ...> {ci}: adds “player” (or the sender) inside " +#~ "the given team. Without arguments, displays the chat-based team selector." +#~ msgstr "" +#~ "{cc}/join [joueur] <équipe ...> {ci}: ajoute “joueur” (ou l'envoyeur) " +#~ "dans l'équipe donnée. Sans argument, affiche le sélecteur d'équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java:75 -msgid "{cs}Rules sent to {0}." -msgstr "{cs}Les règles ont été envoyées à {0}." +#~ msgid "" +#~ "{cc}/leave [player] {ci}: removes “player” (or the sender) from his team." +#~ msgstr "" +#~ "{cc}/leave [joueur] {ci}: retire “joueur” (ou l'envoyeur) de son équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java:79 -msgid "{ce}Cannot display the rules to {0} because he (or she) is offline." -msgstr "" -"{ce}Impossible d'afficher les règles à {0} car il ou elle est hors-ligne." +#~ msgid "{cc}/uh team {ci}: manages the teams. Execute /uh team for details." +#~ msgstr "" +#~ "{cc}/uh team {ci}: gère les équipes. Exécutez /uh team pour plus de " +#~ "détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java:103 -msgid "" -"{cc}/uh rules [player] {ci}: sends the server rules to the server or the " -"given player." -msgstr "" -"{cc}/uh rules [joueur] {ci}: envoie les règles du jeu au serveur ou au " -"joueur spécifié." +#~ msgid "{aqua}------ Border commands ------" +#~ msgstr "{aqua}------ Commandes liées aux bordures ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java:77 -msgid "{cs}You are now chatting with your team only." -msgstr "{cs}Vous discutez désormais avec votre équipe." +#~ msgid "" +#~ "{cc}/uh border {ci}: manages borders. Execute /uh border for details." +#~ msgstr "" +#~ "{cc}/uh border {ci}: gère la bordure. Exécutez /uh border pour plus de " +#~ "détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java:81 -msgid "{cs}You are now chatting with everyone." -msgstr "{cs}Vous discutez désormais avec tous le monde." +#~ msgid "" +#~ "{cc}/uh healall [half-hearts=20|±diff] {ci}: heals all players instead of " +#~ "only one." +#~ msgstr "" +#~ "{cc}/uh healall [demi-coeurs=20|±diff] {ci}: change la vie de tous les " +#~ "joueurs, et non d'un seul." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/ToggleChatCommand.java:95 -msgid "{cs}You are now chatting with the team {0}{cs}." -msgstr "{cs}Vous discutez désormais avec l'équipe {0}{cs}." +#~ msgid "{cc}/uh shift {ci}: shifts an episode." +#~ msgstr "{cc}/uh shift {ci}: passe un épisode." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:209 -msgid "" -"{ci}Legend: {cc}/uh command <required> [optional=default] <spaces allowed ..." -">{ci}." -msgstr "" -"{ci}Légende: {cc}/uh command <requis> [optionnel=valeur par défaut] <espaces " -"autorisées ...>{ci}." +#~ msgid "" +#~ "{cc}/uh generatewalls {ci}: generates the walls according to the " +#~ "configuration." +#~ msgstr "" +#~ "{cc}/uh generatewalls {ci}: génère les murs suivant la configuration." -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:225 -msgid "{ce}{bold}You cannot execute this command this way." -msgstr "{ce}{bold}Vous ne pouvez exécuter cette commande ainsi." +#~ msgid "{yellow} • {{ci}{0}{ci} - total {1} second - {2}" +#~ msgid_plural "{yellow} • {{ci}{0}{ci} - total {1} seconds - {2}" +#~ msgstr[0] "{yellow} • {ci}{0}{ci} - {1} seconde au total - {2}" +#~ msgstr[1] "{yellow} • {ci}{0}{ci} - {1} secondes au total - {2}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:226 -msgid "{ce}The help is displayed above." -msgstr "{ce}L'aide est rappelée ci-dessus." +#~ msgid "{green} • {ci}{0}{ci} - total {1} second - {2}" +#~ msgid_plural "{green} • {ci}{0}{ci} - total {1} seconds - {2}" +#~ msgstr[0] "{green} • {ci}{0}{ci} - {1} seconde au total - {2}" +#~ msgstr[1] "{green} • {ci}{0}{ci} - {1} secondes au total - {2}" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:257 -msgid "{ce}You are not allowed to execute this command." -msgstr "{ce}Vous n'avez pas le droit d'exécuter cette commande." +#~ msgid "{red} • {ci}{0}{ci} - total {1} second" +#~ msgid_plural "{red} • {ci}{0}{ci} - total {1} seconds" +#~ msgstr[0] "{red} • {ci}{0}{ci} - {1} seconde au total" +#~ msgstr[1] "{red} • {ci}{0}{ci} - {1} secondes au total" -#: src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/AbstractCommandExecutor.java:261 -msgid "{ce}This can only be executed as a player." -msgstr "{ce}Vous ne pouvez exécuter cela qu'en étant un joueur." +#~ msgid "" +#~ "{cc}/uh loadplayers <pseudo> [pseudo] ... {ci}: loads the given players " +#~ "in the server so they can be added to teams even if they never logged in." +#~ msgstr "" +#~ "{cc}/uh loadplayers <pseudo> [pseudo] ... {ci}: charges les joueurs " +#~ "spécifiés afin qu'il puissent être ajoutés dans une équipe même s'ils ne " +#~ "se sont jamais connectés au serveur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java:65 -msgid "{ce}You are currently out of the future border (diameter of {0} block)." -msgid_plural "" -"{ce}You are currently out of the future border (diameter of {0} blocks)." -msgstr[0] "{ce}Vous êtes hors de la future bordure de {0} bloc de diamètre." -msgstr[1] "{ce}Vous êtes hors de la future bordure de {0} blocs de diamètre." +#~ msgid "{ce}This player is offline." +#~ msgstr "{ce}Ce joueur n'est pas connecté." -#: src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java:69 -msgid "{ce}You are currently out of the future border of {0}×{0} blocks." -msgstr "{ce}Vous êtes hors de la future bordure de {0}×{0} blocs." +#~ msgid "" +#~ "{cc}/uh heal <player> [half-hearts=20|±diff] {ci}: heals a player to the " +#~ "number of half-hearts provided (default 20)." +#~ msgstr "" +#~ "{cc}/uh heal <joueur> [demi-coeurs=20|±diff] {ci}: change la vie d'un " +#~ "joueur avec le nombre de demi-coeurs donné (par défaut, 20)." -#: src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java:72 -msgid "{ci}You have {0} block to go before being inside." -msgid_plural "{ci}You have {0} blocks to go before being inside." -msgstr[0] "{ci}Il vous reste {0} blocs à parcourir avant d'y être." -msgstr[1] "{ci}Il vous reste {0} bloc à parcourir avant d'y être." +#~ msgid "" +#~ "{cc}/uh feed <player> [foodPoints=20] [saturation=max] {ci}: feeds a " +#~ "player." +#~ msgstr "" +#~ "{cc}/uh feed <joueur> [faim=20] [saturation=max] {ci}: nourrit un joueur." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:334 -msgid "{ce}Unable to start the game: not enough teleportation spots." -msgstr "{ce}Impossible de démarrer : pas assez de points de téléportation." +#~ msgid "" +#~ "{cc}/uh kill <player> {ci}: mark a player as dead, even if he is offline." +#~ msgstr "" +#~ "{cc}/uh kill <joueur> {ci}: marque un joueur comme mort, même s'il est " +#~ "hors-ligne." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:335 -msgid "" -"{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to " -"generate the missing spawns automatically." -msgstr "" -"{ci}Vous pouvez utiliser {cc}/uh spawns generate <random|circular|grid>{ci} " -"pour automatiquement générer les points de téléportation manquant." +#~ msgid "{aqua}------ Beginning of the game ------" +#~ msgstr "{aqua}------ Démarrage du jeu ------" -#. In the sentence: "Or click here to generate the spawns randomly." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:338 -msgid "Or" -msgstr "Ou" +#~ msgid "{cc}/uh start {ci}: starts the game. Period." +#~ msgstr "{cc}/uh start {ci}: démarre le jeu, tout simplement." -#. In the sentence: "Or click here to generate the spawns randomly." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:341 -msgid "click here" -msgstr "cliquez ici" +#~ msgid "{aqua}Startup options" +#~ msgstr "{aqua}Options de démarrage" -#. In the sentence: "Or click here to generate the spawns randomly." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:347 -msgid "to generate the spawns randomly." -msgstr "afin de générer les points de démarrage aléatoirement." +#~ msgid "" +#~ "{ci}You can add some tags to change the way the game is started, just " +#~ "append them to the command with spaces." +#~ msgstr "" +#~ "{ci}Vous pouvez ajouter des options pour changer la manière dont le jeu " +#~ "est démarré. Pour ce faire, ajoutez les tags suivant après la commande " +#~ "(séparés par des espaces)." -#. A simple information, because this start is slower (yeah, Captain Obvious here) -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:479 -msgid "{lightpurple}Teleportation in progress... Please wait." -msgstr "{lightpurple}Téléportation en cours... Merci de patienter." +#~ msgid "" +#~ "{cc}slow:true {ci}: launches the game slowly, in two steps (teleportation " +#~ "then beginning of the game), for smaller servers." +#~ msgstr "" +#~ "{cc}slow:true {ci}: lance le jeu doucement, en deux étapes (téléportation " +#~ "puis commencement), pour les plus petits serveurs." -#. Displayed in the action bar while the slow teleportation occurs. -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:494 -msgid "{lightpurple}Teleporting... {gray}({0}/{1})" -msgstr "{lightpurple}Téléportation... {gray}({0}/{1})" +#~ msgid "" +#~ "{cc}ignoreTeams:true {ci}: even with teams, teleports the players like in " +#~ "a solo game (only one player per spawn point, not a spawn point per team)." +#~ msgstr "" +#~ "{cc}ignoreTeams:true {ci}: même avec des équipes, téléporte les joueurs " +#~ "comme pour un jeu solo (uniquement un joueur par point de démarrage, et " +#~ "non un point par équipe)." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:514 -msgid "{gray}Player {0}{gray} teleported." -msgstr "{gray}Joueur {0}{gray} téléporté." +#~ msgid "" +#~ "{cc}/uh start {ci}: launches the game. See /uh start help for options " +#~ "(slow and ignoreTeams)." +#~ msgstr "" +#~ "{cc}/uh start {ci}: lance le jeu. Consultez /uh start help pour les " +#~ "options de démarrage (lent, en ignorant les équipes)." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:573 -msgid "{cs}All teams are teleported." -msgstr "{cs}Toutes les équipes ont été téléportées." +#~ msgid "{ci}This count includes only the initial spectators." +#~ msgstr "{ci}Ce compte inclue uniquement les spectateurs initiaux." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:574 -msgid "{gray}Use {cc}/uh start{gray} or click here to start the game." -msgstr "" -"{gray}Utilisez {cc}/uh start{gray} ou cliquez ici pour démarrer le jeu." +#~ msgid "{aqua}------ Startup spectators commands ------" +#~ msgstr "{aqua}------ Commandes liées aux spectateurs initiaux ------" -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:575 -msgid "Click here to start the game" -msgstr "Cliquez ici pour démarrer la partie" +#~ msgid "{cc}/uh spec add <player>{ci}: adds a startup spectator." +#~ msgstr "{cc}/uh spec add <joueur> {ci}: ajoute un spectateur initial." -#. Displayed in the action bar when the slow teleportation is finished but the game not started. -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:584 -msgid "{lightpurple}Teleportation complete. {gray}The game will start soon..." -msgstr "{lightpurple}Téléportation terminée. {gray}Ça ne devrait pas tarder..." +#~ msgid "{cc}/uh spec remove <player>{ci}: removes a startup spectator." +#~ msgstr "{cc}/uh spec remove <joueur> {ci}: supprime un spectateur initial." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:615 -msgid "{ce}Please execute {cc}/uh start slow:true{ce} before." -msgstr "{ce}Veuillez exécuter {cc}/uh start slow:true{ce} avant." +#~ msgid "{cc}/uh spec list{ci}: lists the startup spectators." +#~ msgstr "{cc}/uh spec list {ci}: liste les spectateurs initiaux." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:621 -msgid "{ce}Please wait while the players are teleported." -msgstr "{ce}Veuillez patienter, les équipes sont en train d'être téléportées." +#~ msgid "" +#~ "{cc}/uh spec {ci}: manages the spectators. Execute /uh spec for details." +#~ msgstr "" +#~ "{cc}/uh spec {ci}: gère les spectateurs. Exécutez /uh spec pour plus de " +#~ "détails." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:717 -msgid "" -"{red}{bold}Warning!{white} The grace period ended, you are now vulnerable." -msgstr "" -"{red}{bold}Attention !{white} La période de grâce est terminée ; vous êtes " -"désormais vulnérable." +#~ msgid "{cs}You are now chatting with your team only." +#~ msgstr "{cs}Vous discutez désormais avec votre équipe." -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:736 -msgid "{red}{bold}Warning!{white} PvP is now enabled." -msgstr "{red}{bold}Attention !{white} Le PvP est désormais actif." +#~ msgid "{cs}You are now chatting with everyone." +#~ msgstr "{cs}Vous discutez désormais avec tous le monde." -#. Spectators list item if the nick cannot be found -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1073 -#, java-format -msgid "Unknown player with UUID {0}" -msgstr "Joueur inconnu ayant l'UUID {0}" +#~ msgid "{cs}You are now chatting with the team {0}{cs}." +#~ msgstr "{cs}Vous discutez désormais avec l'équipe {0}{cs}." -#. The "and" in the winners players list (like "player1, player2 and player3"). -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1219 -msgctxt "winners_list" -msgid "and" -msgstr "et" +#~ msgctxt "winners_list" +#~ msgid "and" +#~ msgstr "et" -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1231 -msgid "" -"{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) " -"for their victory! {darkgreen}{obfuscated}--" -msgstr "" -"{darkgreen}{obfuscated}--{green} Félicitations à {0} (équipe {1}{green}) " -"pour leur victoire ! {darkgreen}{obfuscated}--" +#~ msgid "" +#~ "{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) " +#~ "for their victory! {darkgreen}{obfuscated}--" +#~ msgstr "" +#~ "{darkgreen}{obfuscated}--{green} Félicitations à {0} (équipe {1}{green}) " +#~ "pour leur victoire ! {darkgreen}{obfuscated}--" -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1235 -msgid "" -"{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! " -"{darkgreen}{obfuscated}--" -msgstr "" -"{darkgreen}{obfuscated}--{green} Félicitation à {0} pour sa victoire ! " -"{darkgreen}{obfuscated}--" +#~ msgid "" +#~ "{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! " +#~ "{darkgreen}{obfuscated}--" +#~ msgstr "" +#~ "{darkgreen}{obfuscated}--{green} Félicitation à {0} pour sa victoire ! " +#~ "{darkgreen}{obfuscated}--" -#. The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). -#. The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1247 -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1254 -msgid "{darkgreen}{0}" -msgstr "{darkgreen}{0}" +#~ msgid "{darkgreen}{0}" +#~ msgstr "{darkgreen}{0}" -#. The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1249 -msgid "{green}This team wins the game!" -msgstr "{green}Cette équipe remporte la victoire !" +#~ msgid "{green}This team wins the game!" +#~ msgstr "{green}Cette équipe remporte la victoire !" -#. The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). -#: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:1256 -msgid "{green}wins the game!" -msgstr "{green}remporte la partie !" +#~ msgid "{green}wins the game!" +#~ msgstr "{green}remporte la partie !" #~ msgid "" #~ "{ce}Unable to add the player {0} to the team {1}. This player is unknown " From b3b30716d7ad45a4033207fb798fc81fb9780711 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 15 Dec 2018 18:54:04 +0100 Subject: [PATCH 37/91] Dynmap module --- .../amaury/UHCReloaded/UHCReloaded.java | 10 - .../modules/core/modules/ModulesCommand.java | 3 +- .../modules/cosmetics/dynmap/Config.java | 52 +++ .../cosmetics/dynmap/DynmapModule.java | 354 +++++++++++++++ .../old/integration/UHDynmapIntegration.java | 407 ------------------ src/main/resources/config.yml | 3 +- 6 files changed, 410 insertions(+), 419 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 28828ee..39e3dec 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -47,7 +47,6 @@ import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.old.integration.UHDynmapIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; import eu.carrade.amaury.UHCReloaded.old.misc.*; @@ -114,7 +113,6 @@ public class UHCReloaded extends ZPlugin implements Listener private UHWorldBorderIntegration wbintegration = null; private UHSpectatorPlusIntegration spintegration = null; - private UHDynmapIntegration dynmapintegration = null; @Override @@ -653,14 +651,6 @@ public UHSpectatorPlusIntegration getSpectatorPlusIntegration() return spintegration; } - /** - * Returns the representation of the dynmap integration in the plugin. - */ - public UHDynmapIntegration getDynmapIntegration() - { - return dynmapintegration; - } - /** * Returns the plugin's instance. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java index dd545e0..e1adb02 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -40,6 +40,7 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.components.rawtext.RawTextPart; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import java.util.*; @@ -108,7 +109,7 @@ protected void run() throws CommandException if (module.getDependencies().length != 0) { tooltip.then("\n\n").then(I.t("External dependencies")).style(ChatColor.BLUE); - Stream.of(module.getDependencies()).forEach(dep -> tooltip.then("\n- ").style(ChatColor.GRAY).then(dep).color(ChatColor.WHITE)); + Stream.of(module.getDependencies()).forEach(dep -> tooltip.then("\n- ").style(ChatColor.GRAY).then(dep).color(Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED)); } if (module.isInternal()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java new file mode 100644 index 0000000..382c0d3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.dynmap; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + static public final ConfigurationItem<Boolean> SHOW_SPAWN_LOCATIONS = item("show-spawn-locations", true); + static public final ConfigurationItem<Boolean> SHOW_DEATH_LOCATIONS = item("show-death-locations", true); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java new file mode 100644 index 0000000..19caa2d --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java @@ -0,0 +1,354 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.dynmap; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.colors.TeamColor; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.dynmap.DynmapAPI; +import org.dynmap.markers.Marker; +import org.dynmap.markers.MarkerAPI; +import org.dynmap.markers.MarkerIcon; +import org.dynmap.markers.MarkerSet; + + +@ModuleInfo ( + name = "Dynmap", + description = "Displays the spawn & death points on the dynmap.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, + settings = Config.class, + depends = "dynmap" +) +/* + * TODO: add the world border to the map. + */ +public class DynmapModule extends UHModule +{ + private final DynmapAPI dynmapAPI = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"); + private final MarkerAPI markerAPI = dynmapAPI.getMarkerAPI(); + + private MarkerSet markerSet = null; + + @Override + protected void onEnable() + { + if (markerAPI == null) + { + log().warning("Dynmap is available, but the markers API is not. The integration was disabled."); + ZLib.unregisterEvents(this); + return; + } + + markerSet = markerAPI.getMarkerSet("uhplugin.markerset"); + + if (markerSet == null) + { + markerSet = markerAPI.createMarkerSet("uhplugin.markerset", "UHCReloaded", null, false); + } + else + { + markerSet.setMarkerSetLabel("UHCReloaded"); + } + } + + @Override + protected void onDisable() + { + if (markerSet != null) + { + markerSet.deleteMarkerSet(); + } + } + + + + /* *** DEATH LOCATIONS *** */ + + + /** + * Displays the death location of the given player. + * + * @param player The player. + */ + public void showDeathLocation(final Player player) + { + if (!Config.SHOW_DEATH_LOCATIONS.get()) + { + return; + } + + final String markerID = getDeathMarkerName(player); + /// Dynmap marker label of a death point + final String markerLabel = I.t("Death point of {0}", player.getName()); + final MarkerIcon icon = markerAPI.getMarkerIcon("skull"); + + final Marker marker = markerSet.createMarker( + markerID, markerLabel, true, + player.getLocation().getWorld().getName(), + player.getLocation().getX(), + player.getLocation().getY(), + player.getLocation().getZ(), + icon, false + ); + + if (marker == null) + { + log().warning("Unable to create marker " + markerID); + } + } + + /** + * Hides the death location of the given player. + * + * @param player The player. + */ + public void hideDeathLocation(final OfflinePlayer player) + { + if (!Config.SHOW_DEATH_LOCATIONS.get()) + { + return; + } + + final Marker marker = markerSet.findMarker(getDeathMarkerName(player)); + if (marker != null) marker.deleteMarker(); + } + + /** + * Returns the internal ID of the marker of the death point of the given player. + * + * @param player The player. + * @return The ID. + */ + private String getDeathMarkerName(final OfflinePlayer player) + { + return "uhplugin.death." + player.getName(); + } + + + + /* *** SPAWNS LOCATIONS *** */ + + + /** + * Displays the spawn point of the given player. + * + * <p> + * Used when the teleportation ignores the teams. + * </p> + * + * @param player The player. + * @param spawnPoint The location of the spawn point. + */ + public void showSpawnLocation(final OfflinePlayer player, final Location spawnPoint) + { + if (!Config.SHOW_SPAWN_LOCATIONS.get()) return; + if (player == null) return; + + final ZTeam team = ZTeams.get().getTeamForPlayer(player); + if (team == null) return; + + final String markerLabel; + if (UR.module(GameModule.class).isTeamsGame() && team.size() > 1) + { + /// Dynmap marker label of a spawn point of a team. + markerLabel = I.t("Spawn point of the team {0}", team.getName()); + } + else + { + /// Dynmap marker label of a spawn point of a player, in solo. + markerLabel = I.t("Spawn point of {0}", team.getName()); + } + + showSpawnLocation( + spawnPoint, + team.getColor() == null ? TeamColor.GREEN : team.getColor(), + markerLabel, + getSpawnMarkerName(player) + ); + } + + /** + * Displays a spawn-point marker. + * + * @param spawnPoint The location of the spawn. + * @param color The color of the team (for the flag). + * @param label The label of the marker. + * @param markerID The ID of the marker. + */ + private void showSpawnLocation(final Location spawnPoint, final TeamColor color, final String label, final String markerID) + { + /* *** Icon *** */ + + final MarkerIcon icon; + + // Let's try to find the best icon + // Available flags: + // redflag, orangeflag, yellowflag, greenflag, blueflag, purpleflag, pinkflag, pirateflag (black) + // Ref. https://github.com/webbukkit/dynmap/wiki/Using-markers + + switch (color) + { + case BLUE: + case DARK_BLUE: + case AQUA: + case DARK_AQUA: + icon = markerAPI.getMarkerIcon("blueflag"); + break; + + case GREEN: + case DARK_GREEN: + icon = markerAPI.getMarkerIcon("greenflag"); + break; + + case GOLD: + icon = markerAPI.getMarkerIcon("orangeflag"); + break; + + case YELLOW: + icon = markerAPI.getMarkerIcon("yellowflag"); + break; + + case RED: + case DARK_RED: + icon = markerAPI.getMarkerIcon("redflag"); + break; + + case DARK_PURPLE: + icon = markerAPI.getMarkerIcon("purpleflag"); + break; + + case LIGHT_PURPLE: + icon = markerAPI.getMarkerIcon("pinkflag"); + break; + + case BLACK: + case DARK_GRAY: + case GRAY: + icon = markerAPI.getMarkerIcon("pirateflag"); + break; + + case WHITE: // There is nothing better than pink I think... + default: + icon = markerAPI.getMarkerIcon("pinkflag"); + break; + } + + + /* *** Duplicate check *** */ + + // We check if there is already a spawn point with the same name + // at the same location. For teams games, with all players teleported + // to the same spot, this could occur. + + final Marker similarMarker = markerSet.findMarkerByLabel(label); + if (similarMarker != null + && similarMarker.getMarkerIcon().equals(icon) + && similarMarker.getX() == spawnPoint.getX() + && similarMarker.getY() == spawnPoint.getY() + && similarMarker.getZ() == spawnPoint.getZ()) + { + return; + } + + + /* *** Registration *** */ + + final Marker marker = markerSet.createMarker( + markerID, + label, + true, + spawnPoint.getWorld().getName(), + spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), + icon, + false + ); + + if (marker == null) + { + log().warning("Unable to create marker {0}", markerID); + } + } + + /** + * Returns the internal ID of the marker of the spawn point of the given player. + * + * @param player The player. + * @return The ID. + */ + private String getSpawnMarkerName(final OfflinePlayer player) + { + return "uhplugin.spawn." + player.getName(); + } + + + + /* *** EVENTS INTEGRATION *** */ + + + @EventHandler (priority = EventPriority.MONITOR) + public void onSpawnPointSelected(final PlayerSpawnPointSelectedEvent ev) + { + showSpawnLocation(ev.getPlayer(), ev.getSpawnPoint()); + } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (ev.getPlayer().isOnline()) + { + showDeathLocation(ev.getPlayer().getPlayer()); + } + } + + @EventHandler + public void onPlayerResurrected(final PlayerResurrectedEvent ev) + { + hideDeathLocation(ev.getPlayer()); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java deleted file mode 100644 index 47a8d14..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.integration; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.colors.TeamColor; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.dynmap.DynmapAPI; -import org.dynmap.markers.Marker; -import org.dynmap.markers.MarkerAPI; -import org.dynmap.markers.MarkerIcon; -import org.dynmap.markers.MarkerSet; - - -public class UHDynmapIntegration -{ - private DynmapAPI api = null; - private MarkerAPI markerAPI = null; - private MarkerSet markerSet = null; - - public UHDynmapIntegration() - { - Plugin apiTest = Bukkit.getServer().getPluginManager().getPlugin("dynmap"); - if (apiTest == null || !apiTest.isEnabled()) - { - PluginLogger.warning("Dynmap is not present, so the integration was disabled."); - return; - } - - this.api = (DynmapAPI) apiTest; - - markerAPI = api.getMarkerAPI(); - if (markerAPI == null) - { - PluginLogger.warning("Dynmap is available, but the markers API is not. The integration was disabled."); - return; - } - - - // All is good, let's integrate. - initDynmapIntegration(); - - PluginLogger.info("Successfully hooked into Dynmap."); - } - - private void initDynmapIntegration() - { - - markerSet = markerAPI.getMarkerSet("uhplugin.markerset"); - - if (markerSet == null) - { - markerSet = markerAPI.createMarkerSet("uhplugin.markerset", "UltraHardcore", null, false); - } - else - { - markerSet.setMarkerSetLabel("UltraHardcore"); - } - } - - public void shutdownDynmapIntegration() - { - if (isDynmapIntegrationEnabled()) - { - markerSet.deleteMarkerSet(); - } - } - - public boolean isDynmapIntegrationEnabled() - { - return !(this.api == null); - } - - public DynmapAPI getDynmapAPI() - { - return api; - } - - public MarkerAPI getDynmapMarkerAPI() - { - return markerAPI; - } - - /** Death locations **/ - - /** - * Displays the death location of the given player. - * - * @param player The player. - */ - public void showDeathLocation(Player player) - { - if (!isDynmapIntegrationEnabled()) - { - return; - } - - if (!UHConfig.DYNMAP.SHOW_DEATH_LOCATIONS.get()) - { - return; - } - - if (!UHCReloaded.get().getGameManager().hasDeathLocation(player)) - { - return; - } - - Location deathPoint = UHCReloaded.get().getGameManager().getDeathLocation(player); - - String markerID = getDeathMarkerName(player); - /// Dynmap marker label of a death point - String markerLabel = I.t("Death point of {0}", player.getName()); - MarkerIcon icon = markerAPI.getMarkerIcon("skull"); - - Marker marker = markerSet.createMarker(markerID, markerLabel, true, deathPoint.getWorld().getName(), deathPoint.getX(), deathPoint.getY(), deathPoint.getZ(), icon, false); - if (marker == null) - { - UHCReloaded.get().getLogger().warning("Unable to create marker " + markerID); - } - } - - /** - * Hides the death location of the given player. - * - * @param player The player. - */ - public void hideDeathLocation(Player player) - { - if (!isDynmapIntegrationEnabled()) - { - return; - } - - if (!UHCReloaded.get().getConfig().getBoolean("dynmap.showDeathLocations")) - { - return; - } - - Marker marker = markerSet.findMarker(getDeathMarkerName(player)); - if (marker != null) - { - marker.deleteMarker(); - } - } - - /** - * Returns the internal ID of the marker of the death point of the given player. - * - * @param player The player. - * @return The ID. - */ - private String getDeathMarkerName(Player player) - { - return "uhplugin.death." + player.getName(); - } - - - /** Spawn locations **/ - - /** - * Displays the spawn point of the given team. - * - * @param team The team. - * @param spawnPoint The location of the spawn point. - */ - public void showSpawnLocation(ZTeam team, Location spawnPoint) - { - if (!isDynmapIntegrationEnabled()) - { - return; - } - - if (!UHConfig.DYNMAP.SHOW_SPAWN_LOCATIONS.get()) - { - return; - } - - - TeamColor teamColor = team.getColor(); - if (teamColor == null) - { - teamColor = TeamColor.GREEN; // green flags for solo games without colors - } - - String markerID = getSpawnMarkerName(team); - - String markerLabel; - if (UHCReloaded.get().getGameManager().isGameWithTeams()) - { - /// Dynmap marker label of a spawn point of a team. - markerLabel = I.t("Spawn point of the team {0}", team.getName()); - } - else - { - /// Dynmap marker label of a spawn point of a player, in solo. - markerLabel = I.t("Spawn point of {0}", team.getName()); - } - - showSpawnLocation(spawnPoint, teamColor, markerLabel, markerID); - } - - /** - * Displays the spawn point of the given player. - * - * <p> - * Used when the teleportation ignores the teams. - * </p> - * - * @param player The player. - * @param spawnPoint The location of the spawn point. - */ - public void showSpawnLocation(OfflinePlayer player, Location spawnPoint) - { - if (player == null) return; - - ZTeam team = ZTeams.get().getTeamForPlayer(player); - - showSpawnLocation(player, team != null && team.getColor() != null ? team.getColor() : null, spawnPoint); - } - - /** - * Displays the spawn point of the given player. - * - * <p> - * Used when the teleportation ignores the teams. - * </p> - * - * @param player The player. - * @param color The color of the spawn point (i.e. of the team). - * @param spawnPoint The location of the spawn point. - */ - public void showSpawnLocation(OfflinePlayer player, TeamColor color, Location spawnPoint) - { - if (!isDynmapIntegrationEnabled()) - { - return; - } - - if (!UHConfig.DYNMAP.SHOW_SPAWN_LOCATIONS.get()) - { - return; - } - - - if (color == null) - { - color = TeamColor.GREEN; - } - - String markerID = getSpawnMarkerName(player); - - /// Dynmap marker label of a spawn point of a player, when the teleportation ignores the teams. - String markerLabel = I.t("Spawn point of {0}", player.getName()); - - showSpawnLocation(spawnPoint, color, markerLabel, markerID); - } - - /** - * Displays a spawn-point marker. - * - * @param spawnPoint The location of the spawn. - * @param color The color of the team (for the flag). - * @param label The label of the marker. - * @param markerID The ID of the marker. - */ - private void showSpawnLocation(Location spawnPoint, TeamColor color, String label, String markerID) - { - /* *** Icon *** */ - - MarkerIcon icon; - - // Let's try to find the best icon - // Available flags: - // redflag, orangeflag, yellowflag, greenflag, blueflag, purpleflag, pinkflag, pirateflag (black) - // Ref. https://github.com/webbukkit/dynmap/wiki/Using-markers - - switch (color) - { - case BLUE: - case DARK_BLUE: - case AQUA: - case DARK_AQUA: - icon = markerAPI.getMarkerIcon("blueflag"); - break; - - case GREEN: - case DARK_GREEN: - icon = markerAPI.getMarkerIcon("greenflag"); - break; - - case GOLD: - icon = markerAPI.getMarkerIcon("orangeflag"); - break; - - case YELLOW: - icon = markerAPI.getMarkerIcon("yellowflag"); - break; - - case RED: - case DARK_RED: - icon = markerAPI.getMarkerIcon("redflag"); - break; - - case DARK_PURPLE: - icon = markerAPI.getMarkerIcon("purpleflag"); - break; - - case LIGHT_PURPLE: - icon = markerAPI.getMarkerIcon("pinkflag"); - break; - - case BLACK: - case DARK_GRAY: - case GRAY: - icon = markerAPI.getMarkerIcon("pirateflag"); - break; - - case WHITE: // There is nothing better than pink I think... - default: - icon = markerAPI.getMarkerIcon("pinkflag"); - break; - } - - - /* *** Registration *** */ - - Marker marker = markerSet.createMarker( - markerID, - label, - true, - spawnPoint.getWorld().getName(), - spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ(), - icon, - false - ); - - if (marker == null) - { - PluginLogger.warning("Unable to create marker {0}", markerID); - } - } - - /** - * Returns the internal ID of the marker of the spawn point of the given team. - * - * @param team The team. - * @return The ID. - */ - private String getSpawnMarkerName(ZTeam team) - { - return "uhplugin.spawn." + team.getName(); - } - - /** - * Returns the internal ID of the marker of the spawn point of the given team. - * - * <p> - * Used if the teleportation ignores the teams. - * </p> - * - * @param player The player. - * @return The ID. - */ - private String getSpawnMarkerName(OfflinePlayer player) - { - return "uhplugin.spawn." + player.getName(); - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b37c764..39a5c42 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -41,11 +41,12 @@ modules: "cosmetics-hardcoreHearts": true "cosmetics-motd": true + "cosmetics-dynmap": true "other-playersLoader": true "other-about": true - "scenarii-alliances": true +# "scenarii-alliances": true # The worlds to use as main worlds. From 4d2414a165c0fa539bf7c48adb05b410bb6b331d Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 15 Dec 2018 19:33:48 +0100 Subject: [PATCH 38/91] Kills count --- .../ingame/killsCount/KillsCountModule.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java new file mode 100644 index 0000000..4e2eca0 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java @@ -0,0 +1,85 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.killsCount; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.*; + + +@ModuleInfo ( + name = "Kills Count", + description = "Displays the player's kills count in the sidebar.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START +) +public class KillsCountModule extends UHModule +{ + private final Map<UUID, Set<UUID>> kills = new HashMap<>(); + + @Override + public void injectIntoSidebar(final Player player, final SidebarInjector injector) + { + injector.injectLines( + SidebarInjector.SidebarPriority.BOTTOM, true, + I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", getKillsFor(player.getUniqueId()).size()) + ); + } + + private Set<UUID> getKillsFor(final UUID playerID) + { + return kills.computeIfAbsent(playerID, uuid -> new HashSet<>()); + } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (ev.getPlayer().isOnline() && ev.getPlayer().getPlayer().getKiller() != null) + { + getKillsFor(ev.getPlayer().getUniqueId()).add(ev.getPlayer().getPlayer().getKiller().getUniqueId()); + } + } + + @EventHandler + public void onPlayerResurrect(final PlayerResurrectedEvent ev) + { + kills.values().forEach(playerKills -> playerKills.remove(ev.getPlayer().getUniqueId())); + } +} From 27c592c38c145950c8665dd3ff42ec8fabd075fb Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 13 Jan 2019 01:32:25 +0100 Subject: [PATCH 39/91] Added new DamagesLogger reports integration. --- pom.xml | 10 + .../modules/other/reports/Config.java | 160 ++++++ .../modules/other/reports/ReportsModule.java | 532 ++++++++++++++++++ .../old/commands/core/utils/CommandUtils.java | 3 +- .../old/listeners/GameListener.java | 2 +- .../utils/OfflinePlayersLoader.java | 2 + src/main/resources/config.yml | 5 +- .../modules-config/other/reports.yml | 53 ++ src/main/resources/plugin.yml | 1 + 9 files changed, 764 insertions(+), 4 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java create mode 100644 src/main/resources/modules-config/other/reports.yml diff --git a/pom.xml b/pom.xml index d056f6f..5cb654a 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,7 @@ <includes> <include>fr.zcraft:zlib</include> <include>fr.zcraft:zteams</include> + <include>me.cassayre.florian:DamagesLogger</include> </includes> </artifactSet> <relocations> @@ -111,6 +112,10 @@ <pattern>fr.zcraft.zteams</pattern> <shadedPattern>eu.carrade.amaury.UHCReloaded.zteams</shadedPattern> </relocation> + <relocation> + <pattern>me.cassayre.florian.damageslogger</pattern> + <shadedPattern>eu.carrade.amaury.UHCReloaded.damageslogger</shadedPattern> + </relocation> </relocations> </configuration> <executions> @@ -169,6 +174,11 @@ <artifactId>zteams</artifactId> <version>1.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>me.cassayre.florian</groupId> + <artifactId>DamagesLogger</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>com.wimbli.WorldBorder</groupId> <artifactId>WorldBorder</artifactId> diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java new file mode 100644 index 0000000..81e64f3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java @@ -0,0 +1,160 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.reports; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import org.bukkit.Material; +import org.bukkit.Statistic; + +import java.io.File; +import java.util.Arrays; +import java.util.List; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<String> REPORTS_API_BASE_URL = item("reports-api-base-url", ""); + + public static final ConfigurationItem<Boolean> PUBLISH_REPORT = item("publish-report", true); + public static final ConfigurationItem<ReportBroadcastedTo> BROADCAST_REPORT_TO = item("broadcast-report-to", ReportBroadcastedTo.ALL); + + static public final ConfigurationItem<Boolean> DATE = item("date", true); + static public final ConfigurationItem<Boolean> PLAYERS_COUNT = item("players-count", true); + static public final ConfigurationItem<Boolean> WINNERS = item("winners", true); + + static public final SummarySection SUMMARY = section("summary", SummarySection.class); + static public class SummarySection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> HISTORY = item("history", true); + public final ConfigurationItem<Boolean> PLAYERS = item("players", true); + public final ConfigurationItem<Boolean> TEAMS = item("teams", true); + } + + + static public final DamagesSection DAMAGES = section("damages", DamagesSection.class); + static public class DamagesSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> DAMAGES_PER_PLAYERS = item("damages-per-players", true); + public final ConfigurationItem<Boolean> DAMAGES_PER_TEAMS = item("damages-per-teams", true); + public final ConfigurationItem<Boolean> DAMAGES_FROM_ENVIRONMENT = item("damages-from-environment", true); + public final ConfigurationItem<Boolean> DISPLAY_KILLER = item("display-killer", true); + } + + + static public final PlayersSection PLAYERS = section("players", PlayersSection.class); + static public class PlayersSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> PLAY_TIME = item("play-time", true); + + public final ConfigurationItem<Boolean> GLOBAL_STATISTICS = item("global-statistics", true); + public final ConfigurationList<Statistic> STATISTICS_WHITELIST = list("statistics-whitelist", Statistic.class); + public final ConfigurationList<Statistic> STATISTICS_HIGHLIGHT = list("statistics-highlight", Statistic.class); + + public final ConfigurationItem<Boolean> USED = item("used", false); + public final ConfigurationList<Material> USED_WHITELIST = list("used-whitelist", Material.class); + public final ConfigurationList<Material> USED_HIGHLIGHT = list("used-highlight", Material.class); + + public final ConfigurationItem<Boolean> MINED = item("mined", true); + public final ConfigurationList<Material> MINED_WHITELIST = list("mined-whitelist", Material.class); + public final ConfigurationList<Material> MINED_HIGHLIGHT = list("mined-highlight", Material.class); + + public final ConfigurationItem<Boolean> PICKED_UP = item("picked-up", true); + public final ConfigurationList<Material> PICKED_UP_WHITELIST = list("picked-up-whitelist", Material.class); + public final ConfigurationList<Material> PICKED_UP_HIGHLIGHT = list("picked-up-highlight", Material.class); + } + + static public List<Statistic> defaultStatsHighlight() + { + return Arrays.asList( + Statistic.DAMAGE_DEALT, + Statistic.CRAFT_ITEM, + Statistic.ITEM_ENCHANTED, + Statistic.BREWINGSTAND_INTERACTION, + Statistic.SPRINT_ONE_CM + ); + } + + static public List<Material> defaultUsedHighlight() + { + return Arrays.asList( + Material.DIAMOND_SWORD, Material.DIAMOND_AXE, Material.DIAMOND_PICKAXE, Material.DIAMOND_HOE, + Material.IRON_SWORD, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_HOE, + Material.CAKE, Material.SADDLE, Material.GOLDEN_APPLE, Material.POTION, + Material.GOLD_RECORD, Material.GREEN_RECORD, Material.RECORD_3, Material.RECORD_4, + Material.RECORD_5, Material.RECORD_6, Material.RECORD_7, Material.RECORD_8, + Material.RECORD_9, Material.RECORD_10, Material.RECORD_11, Material.RECORD_12 + ); + } + + static public List<Material> defaultMinedHighlight() + { + return Arrays.asList( + Material.DIAMOND, Material.DIAMOND_ORE, + Material.GOLD_INGOT, Material.GOLD_ORE, + Material.IRON_INGOT, Material.IRON_ORE, + Material.EMERALD, Material.EMERALD_ORE, + Material.OBSIDIAN, Material.NETHER_WARTS, + Material.MOB_SPAWNER, Material.STONE + ); + } + + static public List<Material> defaultPickedUpHighlight() + { + return Arrays.asList( + Material.APPLE, + Material.BOW, Material.ENDER_PEARL, Material.GOLD_INGOT, + Material.SKULL_ITEM + ); + } + + static public enum ReportBroadcastedTo + { + ALL, + ADMINISTRATORS, + CONSOLE + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java new file mode 100644 index 0000000..9f2ef36 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -0,0 +1,532 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.reports; + +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.events.FutureEventHandler; +import fr.zcraft.zlib.components.events.WrappedEvent; +import fr.zcraft.zlib.components.gui.GuiUtils; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.events.*; +import me.cassayre.florian.damageslogger.ReportsManager; +import me.cassayre.florian.damageslogger.report.InvalidReportException; +import me.cassayre.florian.damageslogger.report.Report; +import me.cassayre.florian.damageslogger.report.ReportEvent; +import me.cassayre.florian.damageslogger.report.ReportTeam; +import org.bukkit.*; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.inventory.BrewEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.scheduler.BukkitTask; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + + +@ModuleInfo ( + name = "Reports", + description = "Generates reports of the game, including history, damages, " + + "heals, statistics, etc., displayed on a web page, and gives the URL " + + "when the match ends.\n\n" + + "Using DamagesLogger by Florian Cassayre & Amaury Carrade.", + when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + settings = Config.class +) +public class ReportsModule extends UHModule +{ + private GameModule game; + + private Report report; + + /* + * Switches for some timeline's events. + */ + private boolean firstGold = false; + private boolean firstDiamond = false; + private boolean firstEnchant = false; + private boolean firstBrew = false; + private boolean firstNether = false; + private boolean firstEnd = false; + private boolean firstGoldenApple = false; + private boolean firstGoldenHead = false; // FIXME not implemented + + /* + * Used to know who used the brewing stands last to know to who the “first + * brew” event should be attributed. + */ + private Map<Location, UUID> lastBrewingStandUsers = new HashMap<>(); + + /* + * After the end of the game, we wait a bit to handle late events + * (like final cross-kill, or fire-kill from fire aspect…). + */ + private BukkitTask waitAfterEndTask = null; + private TimeDelta waitAfterEndDelay = new TimeDelta(30); + + + @Override + protected void onEnable() + { + game = UR.module(GameModule.class); + + ReportsManager.init(UR.get()); + + if (!Config.REPORTS_API_BASE_URL.get().isEmpty()) + { + ReportsManager.get().setRemoteInstanceURL(Config.REPORTS_API_BASE_URL.get()); + } + + report = new Report() + .selfRegister() + .autoTrack(true) + .stopTrackOnDisconnection(false) + + // We'll manage theses ourselves. + .stopTrackOnDeath(false) + .autoTrackNewPlayers(false) + .addDefaultEvents(false) + + .autoCollectPreviousStatistics(true) + .registerPlayers(game.getAlivePlayers()) + + .title(eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get()) + + .settings() + .displayDate(Config.DATE.get()) + .displayPlayersCount(Config.PLAYERS_COUNT.get()) + .displayWinners(Config.WINNERS.get()) + .enableSummary( + Config.SUMMARY.HISTORY.get(), + Config.SUMMARY.PLAYERS.get(), + Config.SUMMARY.TEAMS.get() + ) + .enableDamages( + Config.DAMAGES.DAMAGES_PER_PLAYERS.get(), + Config.DAMAGES.DAMAGES_PER_TEAMS.get(), + Config.DAMAGES.DAMAGES_FROM_ENVIRONMENT.get(), + Config.DAMAGES.DISPLAY_KILLER.get() + ) + .enablePlayers( + Config.PLAYERS.PLAY_TIME.get(), + Config.PLAYERS.GLOBAL_STATISTICS.get(), + Config.PLAYERS.USED.get(), + Config.PLAYERS.MINED.get(), + Config.PLAYERS.PICKED_UP.get() + ) + .highlightingTheseStatistics( + Config.PLAYERS.STATISTICS_HIGHLIGHT.isDefined() + ? Config.PLAYERS.STATISTICS_HIGHLIGHT + : Config.defaultStatsHighlight() + ) + .highlightingTheseUsedItems( + Config.PLAYERS.USED_HIGHLIGHT.isDefined() + ? Config.PLAYERS.USED_HIGHLIGHT + : Config.defaultUsedHighlight() + ) + .highlightingTheseMinedBlocks( + Config.PLAYERS.MINED_HIGHLIGHT.isDefined() + ? Config.PLAYERS.MINED_HIGHLIGHT + : Config.defaultMinedHighlight() + ) + .highlightingThesePickedUpItems( + Config.PLAYERS.PICKED_UP_HIGHLIGHT.isDefined() + ? Config.PLAYERS.PICKED_UP_HIGHLIGHT + : Config.defaultPickedUpHighlight() + ) + .withTheseInGlobalStatisticsWhitelist(Config.PLAYERS.STATISTICS_WHITELIST) + .withTheseInUsedStatisticsWhitelist(Config.PLAYERS.USED_WHITELIST) + .withTheseInMinedStatisticsWhitelist(Config.PLAYERS.MINED_WHITELIST) + .withTheseInPickedUpStatisticsWhitelist(Config.PLAYERS.PICKED_UP_WHITELIST) + .withGenerator( + "UHC Reloaded", + "https://www.spigotmc.org/resources/ultrahardcore-reloaded.1622/" + ) + .done(); + + if (!Config.SUMMARY.ENABLED.get()) report.settings().disableSummary(); + if (!Config.DAMAGES.ENABLED.get()) report.settings().disableDamages(); + if (!Config.PLAYERS.ENABLED.get()) report.settings().disablePlayers(); + + updateReportTeams(); + + RunTask.nextTick(() -> log().info("The reports tracker started successfully.")); + } + + public Report getReport() + { + return report; + } + + private void updateReportTeams() + { + report.resetTeams(); + + if (game.isTeamsGame()) + { + ZTeams.get().getTeams().stream() + .map(team -> new ReportTeam(team.getName(), team.getColorOrWhite().toChatColor(), team.getPlayers())) + .forEach(report::registerTeam); + } + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onGamePhaseChanged(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() == GamePhase.END) + { + final ZTeam winner = game.getWinner(); + if (winner != null) report.setWinners(winner.getPlayers()); + + waitAfterEndTask = RunTask.later(() -> + { + report.autoTrack(false); + + report.save( + saved -> + PluginLogger.info("The JSON report for this game has been written to {0}.", saved.getAbsolutePath()), + error -> + PluginLogger.error("Unable to save the JSON report for this game to the disk. There were backups, you may be lucky and find something there. If configured to do so, the report will still be published.", error) + ); + + if (!Config.PUBLISH_REPORT.get()) return; + + report.publish( + uri -> { + switch (Config.BROADCAST_REPORT_TO.get()) + { + case ALL: + Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); + + Bukkit.broadcastMessage("\n " + GuiUtils.generatePrefixedFixedLengthString( + " ", + I.t("{aqua}{bold}Want a summary?") + ChatColor.RESET + "\n" + + I.t("{darkaqua}Click the link below to see (and share, if you want) the game timeline, events, damages summary, and other statistics!") + )); + + Bukkit.broadcastMessage(""); + + RawMessage.broadcast( + new RawText(" ").hover(I.t("Open {aqua}{0}", uri.toString())) + .then("»").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) + .then(" ").uri(uri) + .then(uri.toString()).style(ChatColor.AQUA).uri(uri) + .then(" ").uri(uri) + .then("«").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) + .build() + ); + + Bukkit.broadcastMessage(""); + Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); + + break; + + case ADMINISTRATORS: + log().broadcastAdministrative(""); + log().broadcastAdministrative(I.t("{darkaqua}{bold}A game report was generated")); + log().broadcastAdministrative(I.t("{darkaqua}You can share it using the following URL. It was not broadcast to other players.")); + log().broadcastAdministrative(""); + + RawMessage.broadcast( + new RawText().uri(uri).hover(I.t("Open {aqua}{0}", uri.toString())) + .then("» ").style(ChatColor.DARK_AQUA, ChatColor.BOLD) + .then(uri.toString()).style(ChatColor.AQUA) + .build() + ); + + break; + + case CONSOLE: + log().info("A game report was generated. You can share it using the following URL: {0} .", uri); + break; + } + }, + error -> { + final String message; + + if (error instanceof IOException) + { + message = I.t("I/O Error: {0}", error.getLocalizedMessage()); + } + else if (error instanceof InvalidReportException) + { + message = I.t("Invalid Report: {0} ({1})", error.getMessage(), ((InvalidReportException) error).getCode()); + } + else message = error.getMessage(); + + log().broadcastAdministrative(""); + log().broadcastAdministrative(I.t("{red}{bold}Unable to publish the game report")); + log().broadcastAdministrative(ChatColor.RED + message); + log().broadcastAdministrative(""); + } + ); + + }, waitAfterEndDelay.getSeconds() * 20L); + } + else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) + { + report.resetWinners(); + report.autoTrack(true); + + if (waitAfterEndTask != null) + { + waitAfterEndTask.cancel(); + waitAfterEndTask = null; + } + } + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + report + .untrackPlayer(ev.getPlayer()) + .record(ReportEvent.withPlayer( + ReportEvent.EventType.GOLD, + /// Title of the death event on the game report's timeline. + I.t("Death of {0}", ev.getPlayer().getName()), + ev.getPlayerDeathEvent() != null + && ev.getPlayerDeathEvent().getDeathMessage() != null + && !ev.getPlayerDeathEvent().getDeathMessage().isEmpty() + ? ev.getPlayerDeathEvent().getDeathMessage() + : null, + ev.getPlayer() + )); + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerResurrected(final PlayerResurrectedEvent ev) + { + report + .trackPlayer(ev.getPlayer()) + .record(ReportEvent.withPlayer( + ReportEvent.EventType.GREEN, + /// Title of the resurrection event on the game report's timeline. + I.t("{0} was resurrected", ev.getPlayer().getName()), + ev.getPlayer() + )); + updateReportTeams(); + } + + @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamUpdatedEvent ev) { updateReportTeams(); } + @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamRegisteredEvent ev) { updateReportTeams(); } + @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamUnregisteredEvent ev) { updateReportTeams(); } + @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final PlayerJoinedTeamEvent ev) { updateReportTeams(); } + @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final PlayerLeftTeamEvent ev) { updateReportTeams(); } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFirstEnchant(final EnchantItemEvent ev) + { + if (firstEnchant || !game.isAlive(ev.getEnchanter())) return; + + report.record(ReportEvent.withIcon( + I.t("{0} enchants the first tool", ev.getEnchanter().getName()), + "item-book-enchanted" + )); + + firstEnchant = true; + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBrewingStandUsed(final PlayerInteractEvent ev) + { + if (firstBrew + || !game.isAlive(ev.getPlayer()) + || !ev.hasBlock() + || ev.getAction() != Action.RIGHT_CLICK_BLOCK + || ev.getClickedBlock().getType() != Material.BREWING_STAND) + { + return; + } + + lastBrewingStandUsers.put(ev.getClickedBlock().getLocation(), ev.getPlayer().getUniqueId()); + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFirstBrew(final BrewEvent ev) + { + if (firstBrew) return; + + final UUID player = lastBrewingStandUsers.get(ev.getBlock().getLocation()); + if (player == null) return; + + report.record(ReportEvent.withIcon( + I.t("{0} brewed the first potion", Bukkit.getOfflinePlayer(player).getName()), + "item-brewing-stand" + )); + + firstBrew = true; + + lastBrewingStandUsers.clear(); + lastBrewingStandUsers = null; + } + + private void onFirstItemCollected(final Material item, final OfflinePlayer player) + { + if (!game.isAlive(player)) return; + + if (!firstDiamond && (item == Material.DIAMOND || item == Material.DIAMOND_ORE)) + { + report.record(ReportEvent.withIcon( + I.t("{0} finds the first diamond", player.getName()), + "item-diamond" + )); + + firstDiamond = true; + } + + else if (!firstGold && (item == Material.GOLD_INGOT || item == Material.GOLD_ORE)) + { + report.record(ReportEvent.withIcon( + I.t("{0} finds the first gold ingot", player.getName()), + "item-gold-ingot" + )); + + firstGold = true; + } + } + + /* + * This event is deprecated. We load it as a future event, so when it will be removed, + * the plugin will not break. We conjointly listen for the new event below, also + * as a future event so the plugin can run in older Minecraft versions where the new + * event isn't there yet. + * + * The event will be called twice on intermediate versions, but the flag will ensure only + * one event will be recorded for each item. + */ + @FutureEventHandler (event = "entity.PlayerPickupItemEvent", priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onOldFirstItemCollected(final WrappedEvent ev) + { + try + { + onFirstItemCollected( + ((Item) Reflection.call(ev.getEvent(), "getItem")).getItemStack().getType(), + ((Player) Reflection.call(ev.getEvent(), "getPlayer")) + ); + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) + { + PluginLogger.error("Unable to retrieve picked-up item to build the report. Will be ignored.", e); + } + } + + @FutureEventHandler(event = "entity.EntityPickupItemEvent", priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFirstItemCollected(final WrappedEvent ev) + { + try + { + LivingEntity entity = (LivingEntity) Reflection.call(ev.getEvent(), "getEntity"); + + if (entity instanceof Player) + { + onFirstItemCollected( + ((Item) Reflection.call(ev.getEvent(), "getItem")).getItemStack().getType(), + (Player) entity + ); + } + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) + { + PluginLogger.error("Unable to retrieve picked-up item to build the report. Will be ignored.", e); + } + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onWorldChange(final PlayerChangedWorldEvent ev) + { + if (!game.isAlive(ev.getPlayer())) return; + + if (!firstNether && ev.getPlayer().getWorld().getName().equals(UR.get().getWorld(World.Environment.NETHER).getName())) + { + report.record(ReportEvent.withIcon( + ReportEvent.EventType.RED, + I.t("{0} enters first the Nether", ev.getPlayer().getName()), + "block-portal" + )); + + firstNether = true; + } + + else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(UR.get().getWorld(World.Environment.THE_END).getName())) + { + report.record(ReportEvent.withIcon( + I.t("{0} enters first The End", ev.getPlayer().getName()), + "block-endframe" + )); + + firstEnd = true; + } + } + + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onItemConsumed(final PlayerItemConsumeEvent ev) + { + if (firstGoldenApple || !game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) + return; + + report.record(ReportEvent.withIcon( + I.t("{0} used the first golden apple", ev.getPlayer().getName()), + "item-apple-golden" + )); + + firstGoldenApple = true; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java index 1934872..db8c2d0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java @@ -49,6 +49,7 @@ public class CommandUtils { + public final static String CHAT_SEPARATOR = ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"; /** * Returns {@code true} if the sender is allowed to execute the given command. @@ -232,6 +233,6 @@ public static void displaySeparator(CommandSender sender) return; } - sender.sendMessage(ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"); + sender.sendMessage(CHAT_SEPARATOR); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index 51dcc4e..dfb6b6b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -219,7 +219,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) p.getGameManager().addDeathLocation(ev.getEntity(), ev.getEntity().getLocation()); // Shows the death location on the dynmap - p.getDynmapIntegration().showDeathLocation(ev.getEntity()); + // p.getDynmapIntegration().showDeathLocation(ev.getEntity()); // Is the game ended? If so, we need to call an event. if (p.getGameManager().isGameRunning() && p.getGameManager().getAliveTeamsCount() == 1) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java index 9730d3d..54d85dc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.utils; import fr.zcraft.zlib.components.worker.Worker; +import fr.zcraft.zlib.components.worker.WorkerAttributes; import fr.zcraft.zlib.components.worker.WorkerCallback; import fr.zcraft.zlib.components.worker.WorkerRunnable; import fr.zcraft.zlib.tools.Callback; @@ -55,6 +56,7 @@ import java.util.stream.Collectors; +@WorkerAttributes (name = "Offline Players Loader") public class OfflinePlayersLoader extends Worker { private static Map<UUID, OfflinePlayer> offlinePlayers = new HashMap<>(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 39a5c42..0b49262 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,7 +13,7 @@ # Available languages: en_US, fr_FR, pt_PT, pt_BR, cs_CZ, zh_CN. # Empty value: system language. -lang: +lang: fr # The modules to load & enable. You can add modules provided by other plugins. @@ -43,10 +43,11 @@ modules: "cosmetics-motd": true "cosmetics-dynmap": true + "other-reports": true "other-playersLoader": true "other-about": true -# "scenarii-alliances": true +# "scenarii-alliances": true # The worlds to use as main worlds. diff --git a/src/main/resources/modules-config/other/reports.yml b/src/main/resources/modules-config/other/reports.yml new file mode 100644 index 0000000..8b6a038 --- /dev/null +++ b/src/main/resources/modules-config/other/reports.yml @@ -0,0 +1,53 @@ + +# The reports API base website URL. If empty, defaults to the instance +# managed by DamagesLogger's authors. +# Change this if you want to use your own instance. +reports-api-base-url: "" + +# If false, the report will not be published at the end of the game. +# It will still be saved in the plugin directory (under plugins/UHPlugin/reports). +publish-report: true + +# If published, the URL can be automatically broadcasted to: +# - ALL: all players in the server (plus the console); +# - ADMINISTRATORS: only administrators (currently operators) +# - CONSOLE: only the console (absolutely nothing in-game). +broadcast-report-to: ALL + + +# The settings below configure the reports web page. +# Empty lists implies sensible default values. +# TODO add documentation for each. + +date: true +players-count: true +winners: true + +summary: + enabled: true + history: true + players: true + teams: true + +damages: + enabled: true + damages-per-players: true + damages-per-teams: true + damages-from-environment: true + display-killer: true + +players: + enabled: true + play-time: true + global-statistics: true + statistics-whitelist: [] + statistics-highlight: [] + used: false + used-whitelist: [] + used-highlight: [] + mined: true + mined-whitelist: [] + mined-highlight: [] + picked-up: true + picked-up-whitelist: [] + picked-up-highlight: [] diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9606056..ee66354 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -14,6 +14,7 @@ softdepend: - SpectatorPlus - dynmap - ProtocolLib + - DamagesLogger commands: uh: From c47190548afb5fe55f7e6d8c06d9eacd04ca0330 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 13 Jan 2019 03:02:54 +0100 Subject: [PATCH 40/91] Improved countdowns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Startup countdown (grace/peace period) are now dynamic in the action bar, displaying a live countdown during the last few seconds. → Peace period is now 15 minutes by default (was disabled by default, before). --- .../UHCReloaded/modules/core/game/Config.java | 3 +- .../core/game/submanagers/GameBeginning.java | 49 ++-- .../carrade/amaury/UHCReloaded/utils/Run.java | 220 ++++++++++++++++++ 3 files changed, 250 insertions(+), 22 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index e16c911..e2634f8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -68,10 +68,9 @@ public static final class SlowSection extends ConfigurationSection public static final class BeginningSection extends ConfigurationSection { public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); - public final ConfigurationItem<Boolean> DISPLAY_GRACE_PERIOD = item("display-grace-period", true); public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); - public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0)); + public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0, 15, 0)); public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 20, 0)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 6a399b2..4955284 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -40,10 +40,10 @@ import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; +import eu.carrade.amaury.UHCReloaded.utils.Run; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLibComponent; import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ActionBar; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -82,24 +82,24 @@ public void onGameStarts(GamePhaseChangedEvent ev) grace = new TimeDelta(15); } - if (Config.BEGINNING.DISPLAY_GRACE_PERIOD.get()) - { - UR.module(GameModule.class).getAliveConnectedPlayers().forEach(player -> - ActionBar.sendPermanentMessage(player, I.t("{green}Grace period {gray}-{green} All damages are disabled"))); - } - inGracePeriod = true; - RunTask.later(() -> { - inGracePeriod = false; - - UR.module(GameModule.class).getAliveConnectedPlayers().forEach(ActionBar::removeMessage); + Run.withCountdown( + I.t("{green}{bold}Grace period"), + I.t("{green}All damages are disabled"), + second -> I.tn("{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", (int) second), + I.t("{yellow}{bold}Ended! {yellow}You are now vulnerable..."), + () -> UR.module(GameModule.class).getAliveConnectedPlayers(), + () -> { + inGracePeriod = false; - if (Config.BEGINNING.BROADCAST_GRACE_END.get()) - { - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); - } - }, grace.getSeconds() * 20L); + if (Config.BEGINNING.BROADCAST_GRACE_END.get()) + { + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); + } + }, + grace + ); /* *** Peace period (PVP disabled) *** */ @@ -108,10 +108,19 @@ public void onGameStarts(GamePhaseChangedEvent ev) { setPVP(false); - RunTask.later(() -> { - setPVP(true); - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); - }, Config.BEGINNING.PEACE_PERIOD.get().getSeconds() * 20L); + Run.withCountdown( + I.t("{red}{bold}Combats between players"), + null, + second -> I.tn("{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", (int) second), + I.t("{yellow}{bold}Now allowed! {yellow}Beware..."), + (short) 10, + () -> UR.module(GameModule.class).getAliveConnectedPlayers(), + () -> { + setPVP(true); + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); + }, + Config.BEGINNING.PEACE_PERIOD.get() + ); } else setPVP(true); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java new file mode 100644 index 0000000..17e98ef --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java @@ -0,0 +1,220 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.utils; + +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.ActionBar; +import fr.zcraft.zlib.tools.text.MessageSender; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.function.Function; +import java.util.function.Supplier; + +public class Run +{ + private final static String ACTION_BAR_SEPARATOR = " " + ChatColor.GRAY + "\u2758" + ChatColor.RESET + " "; + + /** + * Executes a task after a delay, displaying a countdown in the players' + * action bar at the end. + * + * @param title A title displayed in the left of the action bar. + * @param subtitle A subtitle displayed during the whole countdown in + * the right of the action bar. If {@code null}, the + * action bar will only display something when the + * countdown will be about to end. + * @param subtitleDuringCountdown A subtitle displayed during the last + * seconds of the cooldown. Receives the + * current second (will be decreasing) and + * returns a subtitle. + * @param subtitleAfter A subtitle displayed a few seconds after the task + * has been run, e.g. to display a message stating that + * the task is done. If {@code null}, the last countdown + * message wil simply fade out. + * @param receivers The players who will receive the countdown in their + * action bar. + * @param task The task to execute after the delay. + * @param delay The delay. + */ + public static void withCountdown( + final String title, + final String subtitle, + final Function<Short, String> subtitleDuringCountdown, + final String subtitleAfter, + final Supplier<Iterable<Player>> receivers, + final Runnable task, + final TimeDelta delay) + { + withCountdown(title, subtitle, subtitleDuringCountdown, subtitleAfter, (short) 5, receivers, task, delay); + } + + /** + * Executes a task after a delay, displaying a countdown in the players' + * action bar at the end. + * + * @param title A title displayed in the left of the action bar. + * @param subtitle A subtitle displayed during the whole countdown in + * the right of the action bar. If {@code null}, the + * action bar will only display something when the + * countdown will be about to end. + * @param subtitleDuringCountdown A subtitle displayed during the last + * seconds of the cooldown. Receives the + * current second (will be decreasing) and + * returns a subtitle. + * @param visibleCountdownBefore When there will be less than this number of + * seconds before the end of the countdown, + * the subtitle will switch from the defined + * static subtitle to the visible countdown. + * @param receivers The players who will receive the countdown in their + * action bar. + * @param task The task to execute after the delay. + * @param delay The delay. + */ + public static void withCountdown( + final String title, + final String subtitle, + final Function<Short, String> subtitleDuringCountdown, + final String subtitleAfter, + final short visibleCountdownBefore, + final Supplier<Iterable<Player>> receivers, + final Runnable task, + final TimeDelta delay) + { + // The countdown is not visible at the beginning + if (visibleCountdownBefore < delay.getSeconds()) + { + if (subtitle != null) + { + final Iterable<Player> initialReceivers = receivers.get(); + initialReceivers.forEach(receiver -> ActionBar.sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitle)); + + // As the receivers list is recalculated each time (to allow for new players), this ensures + // players who received the initial message will not have it kept during the whole game + // if they were disconnected at the end. + RunTask.later(() -> initialReceivers.forEach(ActionBar::removeMessage), (delay.getSeconds() - visibleCountdownBefore) * 20L); + } + + RunTask.timer( + new CountdownRunnable( + title, + subtitleDuringCountdown, subtitleAfter, + receivers, + visibleCountdownBefore, + task + ), + (delay.getSeconds() - visibleCountdownBefore) * 20L, 20L + ); + } + + // The countdown is immediately visible. + else + { + RunTask.timer( + new CountdownRunnable( + title, + subtitleDuringCountdown, subtitleAfter, + receivers, + (short) delay.getSeconds(), + task + ), + 0L, 20L + ); + } + } + + private static class CountdownRunnable extends BukkitRunnable + { + private final String title; + private final Function<Short, String> subtitleDuringCountdown; + private final String subtitleAfter; + private final Supplier<Iterable<Player>> receivers; + private short secondsLeft; + private final Runnable task; + + private CountdownRunnable( + final String title, + final Function<Short, String> subtitleDuringCountdown, + final String subtitleAfter, + final Supplier<Iterable<Player>> receivers, + final short secondsLeft, + final Runnable task) + { + this.title = title; + this.subtitleDuringCountdown = subtitleDuringCountdown; + this.subtitleAfter = subtitleAfter; + this.receivers = receivers; + this.secondsLeft = secondsLeft; + this.task = task; + } + + @Override + public void run() + { + if (secondsLeft == 0) + { + if (subtitleAfter != null) + { + final Iterable<Player> finalReceivers = receivers.get(); + finalReceivers.forEach(receiver -> ActionBar.sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitleAfter)); + + RunTask.later(() -> finalReceivers.forEach(ActionBar::removeMessage), 60L); + } + else + { + receivers.get() + .forEach(receiver -> MessageSender.sendActionBarMessage( + receiver, + title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) + )); + } + + task.run(); + cancel(); + } + else + { + receivers.get() + .forEach(receiver -> MessageSender.sendActionBarMessage( + receiver, + title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) + )); + + secondsLeft--; + } + } + } +} From 6fbe5d0513319e15b346787bcd5c92a0147af615 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 14 Jan 2019 16:37:21 +0100 Subject: [PATCH 41/91] Modules can be hot disabled/enabled and have metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added commands and adapted loader to allow modules to be hot-disabled and (re)enabled during the game. Flags are available for modules which do not support that. → Added metadata for modules: category, icon. --- .../amaury/UHCReloaded/UHCReloaded.java | 88 ++++----- .../UHCReloaded/core/ModuleCategory.java | 181 ++++++++++++++++++ .../amaury/UHCReloaded/core/ModuleInfo.java | 61 +++--- .../UHCReloaded/core/ModuleLoadTime.java | 68 +++++++ .../UHCReloaded/core/ModuleWrapper.java | 128 ++++++++++--- .../amaury/UHCReloaded/core/UHModule.java | 11 ++ .../core/events/AllModulesLoadedEvent.java | 8 +- .../core/events/ModuleDisabledEvent.java | 76 ++++++++ .../core/events/ModuleEnabledEvent.java | 74 +++++++ .../core/events/ModuleLoadedEvent.java | 15 ++ .../core/events/ModuleUnloadedEvent.java | 12 +- .../modules/beginning/cages/CagesModule.java | 10 +- .../modules/beginning/wait/WaitModule.java | 3 + .../modules/border/check/CheckModule.java | 7 +- .../modules/border/walls/WallsModule.java | 6 +- .../modules/border/warning/WarningModule.java | 13 +- .../modules/core/border/BorderModule.java | 6 +- .../UHCReloaded/modules/core/game/Config.java | 2 +- .../modules/core/game/GameModule.java | 5 +- .../modules/core/modules/ModuleCommand.java | 151 +++++++++++++++ .../modules/core/modules/ModulesCommand.java | 32 +++- .../core/modules/ModulesManagerModule.java | 13 +- .../modules/core/sidebar/GameSidebar.java | 4 +- .../modules/core/sidebar/SidebarModule.java | 6 +- .../modules/core/spawns/SpawnsModule.java | 6 +- .../core/spectators/SpectatorsModule.java | 9 +- .../modules/core/teams/TeamsModule.java | 5 +- .../modules/core/timers/TimersModule.java | 13 +- .../cosmetics/dynmap/DynmapModule.java | 7 +- .../hardcoreHearts/HardcoreHeartsModule.java | 4 + .../modules/cosmetics/motd/MotdModule.java | 4 + .../daylightCycle/DaylightCycleModule.java | 39 +++- .../DeathAnnouncementModule.java | 7 +- .../ingame/episodes/EpisodesModule.java | 10 +- .../modules/ingame/food/FoodModule.java | 7 +- .../ingame/hardcore/HardcoreModule.java | 33 +++- .../modules/ingame/health/HealthModule.java | 7 +- .../modules/ingame/kick/KickModule.java | 7 +- .../ingame/killsCount/KillsCountModule.java | 7 +- .../ingame/listHealth/ListHealthModule.java | 14 +- .../teleportation/TeleportationModule.java | 6 +- .../modules/ingame/weather/WeatherModule.java | 14 +- .../modules/other/about/AboutCommand.java | 3 + .../modules/other/about/AboutModule.java | 6 +- .../playersLoader/PlayersLoaderModule.java | 6 +- .../modules/other/pomf/PomfModule.java | 7 +- .../modules/other/reports/ReportsModule.java | 9 +- .../scenarii/alliances/AlliancesModule.java | 9 +- src/main/resources/config.yml | 7 +- 49 files changed, 1040 insertions(+), 186 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 39e3dec..5bfecf7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -31,11 +31,12 @@ */ package eu.carrade.amaury.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -89,7 +90,7 @@ public class UHCReloaded extends ZPlugin implements Listener private static UHCReloaded instance; private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); - private Set<ModuleInfo.ModuleLoadTime> loadedPriorities = new HashSet<>(); + private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); private Scoreboard scoreboard = null; @@ -173,7 +174,7 @@ public void onEnable() /* *** Loads modules from startup time *** */ - loadModules(ModuleInfo.ModuleLoadTime.STARTUP); + loadModules(ModuleLoadTime.STARTUP); /* *** Loads modules from post-world time if worlds are loaded (server reloaded) *** */ @@ -206,7 +207,7 @@ private void onEnableWhenWorldsAvailable() worldNether = setDefaultWorld(World.Environment.NETHER, UHConfig.WORLDS.NETHER.get()); worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get()); - loadModules(ModuleInfo.ModuleLoadTime.POST_WORLD); + loadModules(ModuleLoadTime.POST_WORLD); }); worldsLoaded = true; @@ -233,7 +234,7 @@ public final void registerModules(final Class<? extends UHModule>... modules) */ private void registerModule(final Class<? extends UHModule> module, final boolean enableAtStartup) { - this.modules.put(module, new ModuleWrapper(module)); + this.modules.put(module, new ModuleWrapper(module, enableAtStartup)); } /** @@ -276,9 +277,10 @@ public void registerModule(final String module) * - [name] * * @param module the module's class name; the class must accept a zero-arguments constructor. - * @param enabledAtStartup {@code true} if this module, according to the configuration file, should be loaded at startup. + * @param initiallyEnabled {@code true} if this module, according to the configuration file, + * should be enabled at startup. */ - private void registerModule(final String module, boolean enabledAtStartup) + private void registerModule(final String module, boolean initiallyEnabled) { final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( module.replace('-', '.'), @@ -289,7 +291,7 @@ private void registerModule(final String module, boolean enabledAtStartup) if (moduleClass != null) { - registerModules(moduleClass); + registerModule(moduleClass, initiallyEnabled); } else { @@ -304,23 +306,25 @@ private void registerModule(final String module, boolean enabledAtStartup) * * @param loadTime Loads the modules registered to be loaded at that given time. */ - private void loadModules(final ModuleInfo.ModuleLoadTime loadTime) + private void loadModules(final ModuleLoadTime loadTime) { if (loadedPriorities.contains(loadTime)) return; // Loads all internal modules first modules.values().stream() .filter(module -> module.getWhen() == loadTime) - .filter(module -> module.get() == null || !module.get().isEnabled()) + .filter(ModuleWrapper::isEnabled) + .filter(module -> !module.isLoaded()) .filter(ModuleWrapper::isInternal) - .forEach(ModuleWrapper::enable); + .forEach(module -> module.load(false)); // Then loads other modules modules.values().stream() .filter(module -> module.getWhen() == loadTime) - .filter(module -> module.get() == null || !module.get().isEnabled()) + .filter(ModuleWrapper::isEnabled) + .filter(module -> !module.isLoaded()) .filter(module -> !module.isInternal()) - .forEach(ModuleWrapper::enable); + .forEach(module -> module.load(false)); loadedPriorities.add(loadTime); @@ -330,37 +334,14 @@ private void loadModules(final ModuleInfo.ModuleLoadTime loadTime) } /** - * Loads a module from its class. - * - * @param moduleClass The module's class. - * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or - * {@link #registerModule(String)} before. - */ - public void loadModule(final Class<? extends UHModule> moduleClass) - { - final ModuleWrapper module = modules.get(moduleClass); - - if (module == null) - throw new IllegalArgumentException("The module " + moduleClass.getName() + " was not registered."); - - module.enable(); - } - - /** - * Unloads a module from its class. + * Checks if the given load time was already loaded. * - * @param moduleClass The module's class. - * @throws IllegalArgumentException if the module was not registered using {@link #registerModules(Class[])} or - * {@link #registerModule(String)} before. + * @param loadTime The load time. + * @return {@code true} if loaded. */ - public void unloadModule(final Class<? extends UHModule> moduleClass) + public boolean isLoaded(final ModuleLoadTime loadTime) { - final ModuleWrapper module = modules.get(moduleClass); - - if (module == null) - throw new IllegalArgumentException("The module " + moduleClass.getName() + " was not registered."); - - module.disable(); + return loadedPriorities.contains(loadTime); } /** @@ -433,15 +414,15 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) switch (ev.getNewPhase()) { case STARTING: - loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_STARTING); + loadModules(ModuleLoadTime.ON_GAME_STARTING); break; case IN_GAME: - loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_START); + loadModules(ModuleLoadTime.ON_GAME_START); break; case END: - loadModules(ModuleInfo.ModuleLoadTime.ON_GAME_END); + loadModules(ModuleLoadTime.ON_GAME_END); break; } } @@ -450,6 +431,21 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) public void onModuleLoaded(final ModuleLoadedEvent e) { PluginLogger.info("Module {0} loaded.", e.getModule().getName()); + + if (e.isLoadedLate()) + { + // If loaded late, we may have to re-register the module's commands. + collectCommandsFromModules(); + } + } + + @EventHandler + public void onModuleUnloaded(final ModuleUnloadedEvent ev) + { + // We remove commands if needed when a module is unloaded, + // as it will be unable to handle them properly (the module + // instance being null). + collectCommandsFromModules(); } @EventHandler (priority = EventPriority.LOWEST) @@ -464,14 +460,14 @@ public final void onPlayerJoin(final PlayerJoinEvent ev) private void collectCommandsFromModules() { Commands.register("uh", modules.values().stream() - .filter(ModuleWrapper::isEnabled) + .filter(ModuleWrapper::isLoaded) .map(module -> module.get().getCommands()) .filter(Objects::nonNull) .flatMap(Collection::stream) .toArray(Class[]::new)); final Map<String, Class<? extends Command>> commandAliases = modules.values().stream() - .filter(ModuleWrapper::isEnabled) + .filter(ModuleWrapper::isLoaded) .map(module -> module.get().getCommandsAliases()) .filter(Objects::nonNull) .flatMap(commandsAliases -> commandsAliases.entrySet().stream()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java new file mode 100644 index 0000000..35b92f3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java @@ -0,0 +1,181 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import java.util.function.Supplier; + +public enum ModuleCategory +{ + CORE ( + I.t("Core Modules"), + I.t("These modules are the core of UHCReloaded, required by other modules."), + Material.BEDROCK, + DyeColor.WHITE + ), + + WORLD_GENERATION ( + I.t("World Generation"), + I.t("These modules alter the world generation. To use them, the server must be started without world."), + Material.REDSTONE_COMPARATOR, + DyeColor.WHITE + ), + + WAITING_PHASE ( + I.t("Waiting Phase"), + I.t("These modules manage the waiting phase, when the game is not yet started."), + Material.WATCH, + DyeColor.WHITE + ), + + STARTING ( + I.t("Game Beginning"), + I.t("These modules enhance the starting phase of the game."), + Material.FEATHER, + DyeColor.WHITE + ), + + END ( + I.t("Game End"), + I.t("These modules alter the game end (either player deaths or whole game end)."), + Material.SKULL_ITEM, + DyeColor.WHITE + ), + + GAMEPLAY ( + I.t("Gameplay"), + I.t("These modules alter the world or gameplay during the game, e.g. adding or nerfing creatures, effects... This category does not contains scenarii, which are in a dedicated one."), + Material.SADDLE, + DyeColor.WHITE + ), + + SCENARII ( + I.t("Scenarii"), + I.t("These modules adds scenarii to the game, i.e. global set of changes that changes the gameplay in a deeper way, and possibly the whole game experience."), + Material.BEACON, + DyeColor.WHITE + ), + + UTILITIES ( + I.t("Utilities"), + I.t("These modules provides tools and utilities to manage the game and offer useful commands."), + Material.COMMAND, + DyeColor.WHITE + ), + + COSMETICS ( + I.t("Cosmetics"), + I.t("These modules adds cosmetics things to the game, like effects or visual enhancements that can be useful but does not change the gameplay."), + new ItemStackBuilder(Material.RED_ROSE).data((short) 1), // FIXME 1.13 + DyeColor.WHITE + ), + + EXTERNAL ( + I.t("External"), + I.t("These modules adds features alongside the game, like web maps, external summaries..."), + Material.ENDER_CHEST, + DyeColor.WHITE + ), + + OTHER ( + I.t("Others"), + I.t("All uncategorized modules goes there."), + () -> { + final ItemStack icon = new ItemStackBuilder(Material.SKULL_ITEM).data((short) 3).item(); + final SkullMeta meta = (SkullMeta) icon.getItemMeta(); + meta.setOwner("MHF_Question"); + icon.setItemMeta(meta); + return icon; + }, + DyeColor.WHITE + ) + + ; + + + private final String displayName; + private final String description; + private final ItemStack icon; + private final DyeColor color; + + ModuleCategory(final String displayName, final String description, final ItemStack icon, DyeColor color) + { + + this.displayName = displayName; + this.description = description; + this.icon = icon; + this.color = color; + } + + ModuleCategory(final String displayName, final String description, final ItemStackBuilder icon, DyeColor color) + { + this(displayName, description, icon.item(), color); + } + + ModuleCategory(final String displayName, final String description, final Supplier<ItemStack> icon, DyeColor color) + { + this(displayName, description, icon.get(), color); + } + + ModuleCategory(final String displayName, final String description, final Material icon, DyeColor color) + { + this(displayName, description, new ItemStack(icon), color); + } + + public String getDisplayName() + { + return displayName; + } + + public String getDescription() + { + return description; + } + + public ItemStack getIcon() + { + return icon.clone(); + } + + public DyeColor getColor() + { + return color; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index 275176d..d10e201 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.core; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import org.bukkit.Material; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -58,6 +59,17 @@ */ ModuleLoadTime when() default ModuleLoadTime.POST_WORLD; + /** + * @return The category under which this module should be classed. + */ + ModuleCategory category() default ModuleCategory.OTHER; + + /** + * @return The icon we should use for this module. If not provide (or {@link Material#AIR air}), + * we'll use the category's icon. + */ + Material icon() default Material.AIR; + /** * @return The configuration class to initialize (if any). * ConfigurationInstance.class is used as a default value to represent no settings as null values are @@ -83,49 +95,22 @@ boolean internal() default false; /** - * @return {@code true} if the module can be disabled and re-enabled. This reflects the status change + * @return {@code true} if the module can be unloaded and re-loaded. This reflects the status change * from inside the game, as all modules can always be disabled on the configuration file (or not loaded * at all). * - * If this is {@code true}, when disabled, a module will have its {@link UHModule#onDisable() onDisable()} + * If this is {@code true}, when disabled, a module will have its {@link UHModule#onDisable()} onDisable()} * method called, and after that, its listener will be unregistered and the module instance removed from the system. * - * When re-enabled, a whole new instance will be created. + * When re-loaded, a whole new instance will be created. */ - boolean can_be_disabled() default true; - + boolean can_be_unloaded() default true; - enum ModuleLoadTime - { - /** - * Loads the module at startup, before the worlds are loaded. - * - * Please note that most core modules (and localization) are not loaded at this point. Use that - * for modules altering the world generation. - */ - STARTUP, - - /** - * Loads the module after the world(s), or immediately if the plugin is reloaded. - * The thing is, all worlds will be loaded when the module is. - */ - POST_WORLD, - - /** - * Loads the module when the game phase is set to STARTING, i.e. when the /uh start command - * is used. - */ - ON_GAME_STARTING, - - /** - * Loads the module when the game starts, i.e. when all players falls from their spawn into - * the world. - */ - ON_GAME_START, - - /** - * Loads the module when the game ends. - */ - ON_GAME_END - } + /** + * @return {@code true} if the module can be loaded after the moment it was declared to be loaded. If {@code false}, + * and an user tries to enable/load it during the game and the module is configured to be loaded, let's say, on + * {@link ModuleLoadTime#ON_GAME_STARTING game starting}, the operation will fail. Use this if you depends on the + * fact that the {@link UHModule#onEnable()} method is called at a specific time. + */ + boolean can_be_loaded_late() default true; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java new file mode 100644 index 0000000..52af8e5 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java @@ -0,0 +1,68 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.core; + +public enum ModuleLoadTime +{ + /** + * Loads the module at startup, before the worlds are loaded. + * + * Please note that most core modules (and localization) are not loaded at this point. Use that + * for modules altering the world generation. + */ + STARTUP, + + /** + * Loads the module after the world(s), or immediately if the plugin is reloaded. + * The thing is, all worlds will be loaded when the module is. + */ + POST_WORLD, + + /** + * Loads the module when the game phase is set to STARTING, i.e. when the /uh start command + * is used. + */ + ON_GAME_STARTING, + + /** + * Loads the module when the game starts, i.e. when all players falls from their spawn into + * the world. + */ + ON_GAME_START, + + /** + * Loads the module when the game ends. + */ + ON_GAME_END +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 6e0e214..829f6b0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -32,8 +32,11 @@ package eu.carrade.amaury.UHCReloaded.core; import com.google.common.base.CaseFormat; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleDisabledEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleEnabledEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.PluginLogger; @@ -51,7 +54,9 @@ public class ModuleWrapper { private final String name; private final String description; - private final ModuleInfo.ModuleLoadTime when; + private final ModuleLoadTime when; + + private boolean enabled; private final Class<? extends UHModule> moduleClass; @@ -60,20 +65,21 @@ public class ModuleWrapper private String[] dependencies; private final boolean internal; - private final boolean canBeDisabled; - - /** - * TODO reimplement properly activated modules - */ - @Deprecated - private boolean enabledAtStartup; + private final boolean canBeUnloaded; + private final boolean canBeLoadedLate; private UHModule instance = null; public ModuleWrapper(final Class<? extends UHModule> moduleClass) + { + this(moduleClass, true); + } + + public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enabled) { this.name = computeModuleName(moduleClass); this.moduleClass = moduleClass; + this.enabled = enabled; final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); @@ -81,8 +87,9 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass) { description = ""; internal = false; - canBeDisabled = true; - when = ModuleInfo.ModuleLoadTime.POST_WORLD; + canBeUnloaded = true; + canBeLoadedLate = true; + when = ModuleLoadTime.POST_WORLD; moduleConfiguration = null; settingsFileName = null; dependencies = new String[] {}; @@ -91,7 +98,8 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass) { description = info.description(); internal = info.internal(); - canBeDisabled = info.can_be_disabled(); + canBeUnloaded = info.can_be_unloaded(); + canBeLoadedLate = info.can_be_loaded_late(); when = info.when(); moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); @@ -103,24 +111,31 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass) /** * Enables this module. + * + * @param late {@code true} if the module is not loaded when specified in + * its {@link ModuleInfo properties}. */ - public void enable() + public boolean load(boolean late) { + if (isLoaded()) return true; + // Check dependencies - for (String dependency : dependencies) + for (final String dependency : dependencies) { final Plugin plugin = Bukkit.getPluginManager().getPlugin(dependency); if (plugin == null) { if (dependencies.length >= 2) { - PluginLogger.warning("Cannot enable module {0}: missing dependency {1} (depends on {2}).", name, dependency, String.join(", ", dependencies)); + PluginLogger.error("Cannot enable module {0}: missing dependency {1} (depends on {2}).", name, dependency, String.join(", ", dependencies)); } else { - PluginLogger.warning("Cannot enable module {0}: missing dependency {1}.", name, dependency); + PluginLogger.error("Cannot enable module {0}: missing dependency {1}.", name, dependency); } + + return false; } else if (!plugin.isEnabled()) { @@ -131,35 +146,85 @@ else if (!plugin.isEnabled()) instance = ZLib.loadComponent(moduleClass); - Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this)); + Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this, late)); + + if (late) instance.onEnableLate(); + + return true; } /** * Disable this module. */ - public void disable() + public void unload() { if (instance == null) return; instance.setEnabled(false); ZLib.unregisterEvents(instance); - Bukkit.getPluginManager().callEvent(new ModuleUnloadedEvent(instance)); + Bukkit.getPluginManager().callEvent(new ModuleUnloadedEvent(this)); instance = null; } /** - * If this module was not yet loaded (e.g. if we're pre-game and the module loads - * when the game starts), sets the module to be loaded (or not) when the time comes. + * Enables or disables this module. * - * @param enabledAtStartup {@code true} to register this module to be enabled at the right time. + * @param enabled new status. + * @return {@code true} if the operation succeeded. It will be {@code false} + * if you try to disable the module and if the module is internal or the + * module is loaded and marked as un-loadable, or if you try to enable the + * module and it is marked as un-loadable after its auto-load moment. */ - public void setEnabledAtStartup(boolean enabledAtStartup) + public boolean setEnabled(boolean enabled) { - if (instance != null) return; + if (this.enabled != enabled) + { + // Can we enabled this module? + if (enabled) + { + if (canBeReEnabled()) + { + return false; + } + } + + // Can we disable this module? + else if (internal || !canBeUnloaded) + { + return false; + } + + + this.enabled = enabled; + + if (enabled) + { + Bukkit.getPluginManager().callEvent(new ModuleEnabledEvent(this)); - this.enabledAtStartup = enabledAtStartup; + if (UR.get().isLoaded(when)) + { + return load(true); + } + } + else + { + Bukkit.getPluginManager().callEvent(new ModuleDisabledEvent(this)); + unload(); + } + } + + return true; + } + + /** + * @return {@code true} if after being disabled, this module will be reloadable + * (can depends on the moment this method is called). + */ + public boolean canBeReEnabled() + { + return !canBeLoadedLate && UR.get().isLoaded(when); } /** @@ -189,7 +254,7 @@ public String[] getDependencies() /** * @return When this module should be loaded. */ - public ModuleInfo.ModuleLoadTime getWhen() + public ModuleLoadTime getWhen() { return when; } @@ -266,23 +331,24 @@ public boolean isInternal() /** * @return {@code true} if this module can be disabled at runtime. */ - public boolean canBeDisabled() + public boolean canBeUnloaded() { - return canBeDisabled; + return canBeUnloaded; } /** - * @return {@code true} if this module, according to the configuration file, should be loaded at startup. + * @return {@code true} if the module is enabled. Disabled modules will not be + * loaded when the time comes. */ - public boolean isEnabledAtStartup() + public boolean isEnabled() { - return enabledAtStartup; + return enabled; } /** * @return {@code true} if the module was loaded and enabled. */ - public boolean isEnabled() + public boolean isLoaded() { return instance != null && instance.isEnabled(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java index 64e94e4..724bd9e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java @@ -56,6 +56,17 @@ public UHModule() */ public void onConfigLoaded() {} + /** + * Called only when the module is enabled late, i.e. not when configured in + * the {@link ModuleInfo}. This happens for modules loaded manually by the + * players, if the module allows such late load. + * + * This method will not be called for normal loads following the module info. + * + * It will be called after {@link #onEnable()}. + */ + public void onEnableLate() {} + /** * Use this method to register sub-commands into the /uh command. * diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java index e4ebb7f..107ffa8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java @@ -31,7 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -43,9 +43,9 @@ public class AllModulesLoadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final ModuleInfo.ModuleLoadTime loadTime; + private final ModuleLoadTime loadTime; - public AllModulesLoadedEvent(ModuleInfo.ModuleLoadTime loadTime) + public AllModulesLoadedEvent(ModuleLoadTime loadTime) { this.loadTime = loadTime; } @@ -55,7 +55,7 @@ public AllModulesLoadedEvent(ModuleInfo.ModuleLoadTime loadTime) * * @return the moment when these modules were all loaded. */ - public ModuleInfo.ModuleLoadTime getLoadTime() + public ModuleLoadTime getLoadTime() { return loadTime; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java new file mode 100644 index 0000000..2d26bf0 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java @@ -0,0 +1,76 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.core.events; + +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired after a module was disabled. + * + * The module can be loaded at this point. If so, it will be unloaded soon after + * this event was called. + */ +public class ModuleDisabledEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final ModuleWrapper module; + + + public ModuleDisabledEvent(final ModuleWrapper module) + { + this.module = module; + } + + /** + * @return the unloaded module. + */ + public ModuleWrapper getModule() + { + return module; + } + + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java new file mode 100644 index 0000000..9f84e51 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java @@ -0,0 +1,74 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.core.events; + +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + + +/** + * Fired after a module was enabled. + * This does not implies that the module is loaded. + */ +public class ModuleEnabledEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private final ModuleWrapper module; + + + public ModuleEnabledEvent(final ModuleWrapper module) + { + this.module = module; + } + + /** + * @return the enabled module. + */ + public ModuleWrapper getModule() + { + return module; + } + + + @Override + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java index 5180f8d..af37e41 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java @@ -44,11 +44,18 @@ public class ModuleLoadedEvent extends Event private static final HandlerList handlers = new HandlerList(); private final ModuleWrapper module; + private final boolean loadedLate; public ModuleLoadedEvent(final ModuleWrapper module) + { + this(module, false); + } + + public ModuleLoadedEvent(final ModuleWrapper module, boolean loadedLate) { this.module = module; + this.loadedLate = loadedLate; } /** @@ -59,6 +66,14 @@ public ModuleWrapper getModule() return module; } + /** + * @return {@code true} if the module is not loaded when specified in its + * {@link eu.carrade.amaury.UHCReloaded.core.ModuleInfo properties}. + */ + public boolean isLoadedLate() + { + return loadedLate; + } @Override public HandlerList getHandlers() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java index 51f8b22..6793dce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java @@ -31,7 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -40,16 +40,18 @@ * Fired after a module was unloaded. * * When this event is called, the embed instance is dying, unregistered from all - * events managers and soon-to-be-deleted. + * events managers and soon-to-be-deleted. At the time the event is called, you + * can still get the instance using {@link ModuleWrapper#get()}, but don't try + * that on a delayed task as the instance will no longer be available. */ public class ModuleUnloadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final UHModule module; + private final ModuleWrapper module; - public ModuleUnloadedEvent(final UHModule module) + public ModuleUnloadedEvent(final ModuleWrapper module) { this.module = module; } @@ -57,7 +59,7 @@ public ModuleUnloadedEvent(final UHModule module) /** * @return the unloaded module. */ - public UHModule getModule() + public ModuleWrapper getModule() { return module; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java index d36eec1..1a98e79 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; @@ -42,6 +44,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; import fr.zcraft.zteams.ZTeams; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -52,8 +55,11 @@ @ModuleInfo ( name = "Cages", description = "Puts players in cages (or platforms) instead of letting them float in the air, during the startup process.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, - settings = Config.class + when = ModuleLoadTime.ON_GAME_STARTING, + category = ModuleCategory.STARTING, + icon = Material.GLASS, + settings = Config.class, + can_be_loaded_late = false ) public class CagesModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index 442c4c0..01b78cd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.beginning.wait; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -70,6 +71,8 @@ @ModuleInfo ( name = "Waiting phase", description = "Manages the waiting phase: inventory, effects, modes, teleportation, etc.", + category = ModuleCategory.WAITING_PHASE, + icon = Material.WATCH, settings = Config.class ) public class WaitModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java index 7630216..b08d3d0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java @@ -33,9 +33,12 @@ */ package eu.carrade.amaury.UHCReloaded.modules.border.check; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Material; import java.util.Collections; import java.util.List; @@ -43,7 +46,9 @@ @ModuleInfo ( name = "Border Check", description = "Offers a command to check how far players are from a given border size.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START + category = ModuleCategory.UTILITIES, + icon = Material.FENCE, + when = ModuleLoadTime.ON_GAME_START ) public class CheckModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java index ba40708..a1e7b63 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java @@ -34,7 +34,9 @@ package eu.carrade.amaury.UHCReloaded.modules.border.walls; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.UnknownWallGenerator; @@ -51,7 +53,9 @@ @ModuleInfo ( name = "Walls Generator", description = "Generates a solid wall around the arena.", - when = ModuleInfo.ModuleLoadTime.POST_WORLD, + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.UTILITIES, + icon = Material.BARRIER, settings = Config.class ) public class WallsModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java index e8a5fcc..c29c208 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.border.warning; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; @@ -43,6 +45,7 @@ import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; import org.bukkit.scheduler.BukkitRunnable; @@ -53,7 +56,9 @@ @ModuleInfo ( name = "Border Warning", description = "Warns players about the future border size.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.UTILITIES, + icon = Material.FENCE_GATE, settings = Config.class ) public class WarningModule extends UHModule @@ -75,6 +80,12 @@ protected void onEnable() warningTimerName = I.t("Border shrinking"); } + @Override + protected void onDisable() + { + cancelWarning(); + } + @Override public List<Class<? extends Command>> getCommands() { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index b8f2872..9d45329 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.core.border; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.commands.BorderCommand; @@ -50,6 +51,7 @@ import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -65,8 +67,10 @@ @ModuleInfo ( name = "Border", description = "Manages the border size and reduction.", + category = ModuleCategory.CORE, + icon = Material.FENCE, settings = Config.class, - can_be_disabled = false, + can_be_unloaded = false, internal = true ) public class BorderModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index e2634f8..423a245 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -54,7 +54,7 @@ public Config(File file) public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = item("random-color-in-solo-games", true); - public static final ConfigurationItem<Boolean> BROADCAST_PROGRESS = item("broadcastP-progress", true); + public static final ConfigurationItem<Boolean> BROADCAST_PROGRESS = item("broadcast-progress", true); public static final SlowSection SLOW = section("slow", SlowSection.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index 3573f17..f60d154 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -31,6 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.game; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.KillCommand; @@ -76,9 +77,11 @@ @ModuleInfo ( name = "Game", description = "Manages the game execution and phases.", + category = ModuleCategory.CORE, + icon = Material.REDSTONE_BLOCK, settings = Config.class, internal = true, - can_be_disabled = false + can_be_unloaded = false ) public class GameModule extends UHModule implements Listener { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java new file mode 100644 index 0000000..d3c533a --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java @@ -0,0 +1,151 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules; + +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.ChatColor; + +import java.text.Normalizer; +import java.util.List; +import java.util.Locale; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +@CommandInfo (name = "module", usageParameters = "enable|disable <module>") +public class ModuleCommand extends Command +{ + private static final Pattern NON_LATIN = Pattern.compile("[^\\w-]"); + private static final Pattern WHITESPACE = Pattern.compile("[\\s]"); + + + @Override + protected void run() throws CommandException + { + if (args.length < 2 || (!args[0].equalsIgnoreCase("enable") && !args[0].equalsIgnoreCase("disable"))) + { + throwInvalidArgument(I.t("Invalid command usage.")); + } + + ModuleWrapper module = null; + + for (final ModuleWrapper m : UR.get().getModules()) + { + if (getModuleKey(m).equalsIgnoreCase(args[1])) + { + module = m; break; + } + } + + if (module == null) + { + throwInvalidArgument(I.t("No module with key {0}. Use autocompletion to get a list of keys.", args[1])); + return; + } + + if (args[0].equalsIgnoreCase("enable")) + { + if (module.isEnabled()) + { + error(I.t("{red}The module {darkred}{0}{red} is already enabled.", module.getName())); + } + else if (module.setEnabled(true)) + { + success(I.t("{green}The module {darkgreen}{0}{green} was successfully enabled.", module.getName())); + + if (module.isLoaded()) + { + info(I.t("It was also loaded and is now running.")); + } + else + { + info(I.t("It will be loaded when needed.")); + } + } + else + { + warning(I.t("{red}Unable to load the module {darkred}{0}{red}.", module.getName())); + info("It is probably too late to enable this module."); + } + } + else + { + if (!module.isEnabled()) + { + error(I.t("{red}he module {darkred}{0}{red} is already disabled.", module.getName())); + } + else if (module.setEnabled(false)) + { + success(I.t("{green}The module {darkred}{0}{green} was successfully disabled.", module.getName())); + } + else + { + error(I.t("{red}Unable to disable the module {darkred}{0}{red}. It is probably protected.", module.getName())); + } + } + } + + @Override + protected List<String> complete() + { + if (args.length == 1) return getMatchingSubset(args[0], "enable", "disable"); + else if (args.length == 2) return getMatchingSubset(UR.get().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); + else return null; + } + + private String getModuleKey(final ModuleWrapper module) + { + return slug(module.getName()); + } + + /** + * Generates a slug from the (potentially Minecraft-formatted) given string. + * + * @param input The string to convert into a slug. May contain Minecraft + * formatting codes: they will be striped. + * @return The slug. + */ + private static String slug(final String input) + { + final String nowhitespace = WHITESPACE.matcher(ChatColor.stripColor(input)).replaceAll("-"); + final String normalized = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD); + final String slug = NON_LATIN.matcher(normalized).replaceAll(""); + + return slug.toLowerCase(Locale.ENGLISH); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java index e1adb02..64e4986 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java @@ -47,7 +47,7 @@ import java.util.stream.Stream; -@CommandInfo (name = "modules", usageParameters = "[list|enable|disable]", aliases = {"module"}) +@CommandInfo (name = "modules") public class ModulesCommand extends Command { @Override @@ -56,6 +56,7 @@ protected void run() throws CommandException final Set<ModuleWrapper> modules = new TreeSet<>((module1, module2) -> { if (module1.equals(module2)) return 0; + if (module1.isLoaded() != module2.isLoaded()) return module1.isLoaded() ? -1 : 1; if (module1.isEnabled() != module2.isEnabled()) return module1.isEnabled() ? -1 : 1; if (module1.getWhen() != module2.getWhen()) @@ -72,7 +73,7 @@ protected void run() throws CommandException modules.forEach(module -> { final List<String> commands = new ArrayList<>(); - if (module.isEnabled()) + if (module.isLoaded()) { final List<Class<? extends Command>> commandsClasses = module.get().getCommands(); if (commandsClasses != null) @@ -95,10 +96,25 @@ protected void run() throws CommandException final RawTextPart<?> tooltip = new RawText(); - tooltip.then(module.getName()).style(ChatColor.BOLD).style(module.isEnabled() ? ChatColor.GREEN : ChatColor.RED).then("\n"); - tooltip.then(module.isEnabled() ? I.t("Enabled") : I.t("Disabled")).color(ChatColor.GRAY).then("\n\n"); - tooltip.then(module.getDescription()).style(ChatColor.WHITE).then("\n\n"); - tooltip.then(I.t("Load time")).style(ChatColor.BLUE).then("\n").then(module.getWhen().toString()).style(ChatColor.WHITE); + tooltip + .then(module.getName()) + .style(ChatColor.BOLD, module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + .then("\n") + .then(module.isLoaded() ? I.t("Loaded") : I.t("Unloaded")) + .color(ChatColor.GRAY) + .then(" - ") + .color(ChatColor.DARK_GRAY) + .then(module.isEnabled() ? I.t("Enabled") : I.t("Disabled")) + .color(ChatColor.GRAY) + .then("\n\n") + .then(module.getDescription()) + .color(ChatColor.WHITE) + .then("\n\n") + .then(I.t("Load time")) + .color(ChatColor.BLUE) + .then("\n") + .then(module.getWhen().toString()) + .color(ChatColor.WHITE); if (!commands.isEmpty()) { @@ -116,13 +132,13 @@ protected void run() throws CommandException { tooltip.then("\n\n").then(I.t("Internal module")).style(ChatColor.DARK_GRAY); } - if (!module.canBeDisabled()) + if (!module.canBeUnloaded()) { tooltip.then(module.isInternal() ? " - " : "\n\n").color(ChatColor.DARK_GRAY).then(I.t("Cannot be disabled")).color(ChatColor.DARK_GRAY); } send(new RawText().hover(tooltip) - .then("• ").color(module.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + .then("• ").color(module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) .then(module.getName()).color(ChatColor.WHITE) .build() ); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java index 6987a2e..71f3154 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -32,7 +32,9 @@ package eu.carrade.amaury.UHCReloaded.modules.core.modules; import com.google.common.collect.ImmutableMap; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; @@ -40,9 +42,10 @@ import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Material; import org.bukkit.entity.Player; -import java.util.Collections; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -50,15 +53,17 @@ @ModuleInfo ( name = "Modules Manager", description = "Offers to the users a way to manage modules.", - when = ModuleInfo.ModuleLoadTime.STARTUP, - can_be_disabled = false + when = ModuleLoadTime.STARTUP, + category = ModuleCategory.CORE, + icon = Material.COMMAND, + can_be_unloaded = false ) public class ModulesManagerModule extends UHModule { @Override public List<Class<? extends Command>> getCommands() { - return Collections.singletonList(ModulesCommand.class); + return Arrays.asList(ModulesCommand.class, ModuleCommand.class); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java index b9e7620..e8ac757 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java @@ -54,7 +54,7 @@ public GameSidebar() public void preRender() { UHCReloaded.get().getModules().stream() - .filter(ModuleWrapper::isEnabled) + .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) .forEach(UHModule::prepareInjectionIntoSidebar); } @@ -65,7 +65,7 @@ public List<String> getContent(Player player) final SidebarInjector injector = new SidebarInjector(); UHCReloaded.get().getModules().stream() - .filter(ModuleWrapper::isEnabled) + .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) .forEach(module -> module.injectIntoSidebar(player, injector)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java index 2d4b778..1d24f5a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java @@ -31,9 +31,11 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; @@ -42,9 +44,11 @@ @ModuleInfo ( name = "Sidebar", description = "Manages the sidebar and allows hooks for all modules into it.", + category = ModuleCategory.CORE, + icon = Material.BOOK_AND_QUILL, settings = Config.class, internal = true, - can_be_disabled = false + can_be_unloaded = false ) public class SidebarModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java index 1953d82..7ec8e95 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.core.spawns; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; @@ -47,6 +48,7 @@ import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; @@ -60,9 +62,11 @@ @ModuleInfo( name = "Spawns", description = "Manages the spawn points and allow users to generate them randomly.", + category = ModuleCategory.CORE, + icon = Material.MAP, settings = Config.class, internal = true, - can_be_disabled = false + can_be_unloaded = false ) public class SpawnsModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index be228ea..73256ed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.spectators; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; @@ -48,6 +50,7 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -60,9 +63,11 @@ @ModuleInfo ( name = "Spectators Manager", description = "Handles non-playing players.", - when = ModuleInfo.ModuleLoadTime.POST_WORLD, + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.CORE, + icon = Material.EYE_OF_ENDER, settings = Config.class, - can_be_disabled = false + can_be_unloaded = false ) public class SpectatorsModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java index 084af31..29b2275 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java @@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableMap; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -70,9 +71,11 @@ @ModuleInfo ( name = "Teams", description = "Manages the teams and related commands.", + category = ModuleCategory.CORE, + icon = Material.NETHER_STAR, settings = Config.class, internal = true, - can_be_disabled = false + can_be_unloaded = false ) public class TeamsModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java index c7805ee..6c08fa5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.core.timers; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; @@ -39,14 +40,10 @@ import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.tools.runners.RunTask; import org.apache.commons.lang3.tuple.Pair; +import org.bukkit.Material; import org.bukkit.entity.Player; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; @@ -54,8 +51,10 @@ @ModuleInfo ( name = "Timers", description = "The timekeeper of the whole UHCReloaded plugin & companions.", + category = ModuleCategory.CORE, + icon = Material.WATCH, internal = true, - can_be_disabled = false + can_be_unloaded = false ) public class TimersModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java index 19caa2d..b22e501 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.cosmetics.dynmap; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; @@ -47,6 +49,7 @@ import fr.zcraft.zteams.colors.TeamColor; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -61,7 +64,9 @@ @ModuleInfo ( name = "Dynmap", description = "Displays the spawn & death points on the dynmap.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING, + when = ModuleLoadTime.ON_GAME_STARTING, + category = ModuleCategory.EXTERNAL, + icon = Material.MAP, settings = Config.class, depends = "dynmap" ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java index 9090bb5..9cf9a69 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -34,15 +34,19 @@ package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; import com.comphenix.protocol.ProtocolLibrary; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import fr.zcraft.zlib.core.ZLib; +import org.bukkit.Material; @ModuleInfo ( name = "Hardcore Hearts", description = "Replaces hearts with hardcore hearts.", depends = "ProtocolLib", + category = ModuleCategory.COSMETICS, + icon = Material.RED_ROSE, // FIXME 1.13 settings = Config.class ) public class HardcoreHeartsModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java index c213788..54f04ad 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -40,6 +41,7 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.server.ServerListPingEvent; @@ -47,6 +49,8 @@ @ModuleInfo ( name = "MOTD", description = "Updates the MOTD according to the current game state.", + category = ModuleCategory.EXTERNAL, + icon = Material.SIGN, settings = Config.class ) public class MotdModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java index ae5ed39..805b906 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java @@ -33,15 +33,19 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.daylightCycle; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitTask; import java.util.concurrent.atomic.AtomicLong; @@ -49,6 +53,8 @@ @ModuleInfo ( name = "Daylight Cycle", description = "Configures the daylight cycle (disabled, slowed down, normal, accelerated) and the initial time.", + category = ModuleCategory.GAMEPLAY, + icon = Material.WATCH, settings = Config.class ) public class DaylightCycleModule extends UHModule @@ -57,6 +63,8 @@ public class DaylightCycleModule extends UHModule private final static long TICKS_IN_ONE_DAYLIGHT_CYCLE = 24000L; private final static TimeDelta NORMAL_DAYLIGHT_CYCLE_DURATION = new TimeDelta(0, 20, 0); + private BukkitTask daylightCycleTask = null; + @Override protected void onEnable() @@ -67,11 +75,36 @@ protected void onEnable() }); } + @Override + public void onEnableLate() + { + if (UR.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) + { + initDayLightCycle(UR.get().getWorld(World.Environment.NORMAL).getFullTime()); + } + } + + @Override + protected void onDisable() + { + if (daylightCycleTask != null) + { + daylightCycleTask.cancel(); + daylightCycleTask = null; + } + } + @EventHandler public void onGameStart(final GamePhaseChangedEvent ev) { - if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) + { + initDayLightCycle(Config.INITIAL_GAME_HOUR.get()); + } + } + private void initDayLightCycle(final long initialTime) + { final World world = UR.get().getWorld(World.Environment.NORMAL); world.setFullTime(Config.INITIAL_GAME_HOUR.get()); @@ -89,10 +122,10 @@ public void onGameStart(final GamePhaseChangedEvent ev) // will be the same for multiple updates. final long updateInterval = (long) Math.max(1L, (ticksPerDay * 1.0f) / TICKS_IN_ONE_DAYLIGHT_CYCLE); - final AtomicLong tick = new AtomicLong((Config.INITIAL_GAME_HOUR.get() * 20L) % TICKS_IN_ONE_DAYLIGHT_CYCLE); + final AtomicLong tick = new AtomicLong(initialTime % TICKS_IN_ONE_DAYLIGHT_CYCLE); if (tick.get() < 0L) tick.addAndGet(TICKS_IN_ONE_DAYLIGHT_CYCLE); - RunTask.timer(() -> { + daylightCycleTask = RunTask.timer(() -> { // We keep the current tick in one daylight cycle. if (tick.addAndGet(updateInterval) >= ticksPerDay) tick.set(0L); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java index 96b956c..bec2199 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.deathAnnouncement; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; @@ -47,6 +49,7 @@ import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; @@ -54,7 +57,9 @@ @ModuleInfo ( name = "Death Announcements", description = "Adds announcements for players & teams deaths.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.END, + icon = Material.BLAZE_ROD, settings = Config.class ) public class DeathAnnouncementModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java index 1f41877..304e063 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; @@ -50,6 +52,7 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; @@ -62,8 +65,11 @@ @ModuleInfo ( name = "Episodes", description = "Displays time marks every 20 minutes (by default), e.g. to divide a recording for diffusion.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, - settings = Config.class + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.COSMETICS, + icon = Material.SIGN, + settings = Config.class, + can_be_loaded_late = false ) public class EpisodesModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java index 93b351f..85d9200 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java @@ -33,11 +33,14 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.food; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedAllCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedCommand; import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Material; import java.util.Arrays; import java.util.List; @@ -46,7 +49,9 @@ @ModuleInfo ( name = "Food Commands", description = "Provides commands to update food level & saturation of some or all players.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.UTILITIES, + icon = Material.MUSHROOM_SOUP ) public class FoodModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java index f94acc8..c3d9af1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java @@ -33,23 +33,50 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.hardcore; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import org.bukkit.Difficulty; +import org.bukkit.Material; + +import java.util.HashMap; +import java.util.Map; @ModuleInfo ( name = "Hardcore Mode", description = "Disables health natural regeneration and sets correct difficulty in the game's worlds.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.GOLDEN_APPLE, settings = Config.class ) public class HardcoreModule extends UHModule { + private Map<String, Difficulty> oldDifficulties = new HashMap<>(); + private Map<String, String> oldNaturalRegenerations = new HashMap<>(); + @Override protected void onEnable() { - UR.get().getWorlds().forEach(world -> world.setDifficulty(Config.DIFFICULTY.get())); - UR.get().getWorlds().forEach(world -> world.setGameRuleValue("naturalRegeneration", Config.NATURAL_REGENERATION.get().toString())); + UR.get().getWorlds().forEach(world -> + { + oldDifficulties.put(world.getName(), world.getDifficulty()); + oldNaturalRegenerations.put(world.getName(), world.getGameRuleValue("naturalRegeneration")); + + world.setDifficulty(Config.DIFFICULTY.get()); + world.setGameRuleValue("naturalRegeneration", Config.NATURAL_REGENERATION.get().toString()); + }); + } + + @Override + protected void onDisable() + { + UR.get().getWorlds().forEach(world -> { + world.setDifficulty(oldDifficulties.getOrDefault(world.getName(), Difficulty.NORMAL)); + world.setGameRuleValue("naturalRegeneration", oldNaturalRegenerations.getOrDefault(world.getName(), "true")); + }); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java index 0ececaa..16f76ac 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java @@ -33,11 +33,14 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.health; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealAllCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealCommand; import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Material; import java.util.Arrays; import java.util.List; @@ -46,7 +49,9 @@ @ModuleInfo ( name = "Health Commands", description = "Provides commands to update health of some or all players.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.UTILITIES, + icon = Material.GOLDEN_APPLE ) public class HealthModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java index caefb84..0cdf65c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java @@ -33,16 +33,21 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.kick; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; import org.bukkit.event.EventHandler; @ModuleInfo ( name = "Kick On Death", description = "Kicks players on death after a delay.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.END, + icon = Material.BARRIER, settings = Config.class ) public class KickModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java index 4e2eca0..cbc3d1f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java @@ -33,12 +33,15 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.killsCount; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; import fr.zcraft.zlib.components.i18n.I; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,7 +51,9 @@ @ModuleInfo ( name = "Kills Count", description = "Displays the player's kills count in the sidebar.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.COSMETICS, + icon = Material.DIAMOND_SWORD ) public class KillsCountModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java index b7735d7..f582077 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java @@ -33,29 +33,38 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.listHealth; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Criterias; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; +import java.util.UUID; + @ModuleInfo ( name = "Health in Players List", description = "Displays the health of players in the overlay list displayed with <TAB>.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_STARTING + when = ModuleLoadTime.ON_GAME_STARTING, + category = ModuleCategory.COSMETICS, + icon = Material.DETECTOR_RAIL ) public class ListHealthModule extends UHModule { + private String objectiveID = UUID.randomUUID().toString().substring(0, 16); + @Override protected void onEnable() { // Initialization of the scoreboard (health in players' list) - final Objective healthObjective = UR.get().getScoreboard().registerNewObjective("Health", Criterias.HEALTH); + final Objective healthObjective = UR.get().getScoreboard().registerNewObjective(objectiveID, Criterias.HEALTH); healthObjective.setDisplayName("Health"); healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); @@ -67,6 +76,7 @@ protected void onEnable() protected void onDisable() { UR.get().getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST); + UR.get().getScoreboard().getObjective(objectiveID).unregister(); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java index d6a8564..73c9c30 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; @@ -42,6 +43,7 @@ import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPTeamCommand; import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; @@ -50,7 +52,9 @@ @ModuleInfo ( name = "Teleportation Commands", - description = "Provides commands to teleport to spawn, death location, or groups of players." + description = "Provides commands to teleport to spawn, death location, or groups of players.", + category = ModuleCategory.UTILITIES, + icon = Material.COMMAND_MINECART ) public class TeleportationModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java index 65858c9..5fe4254 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java @@ -33,12 +33,14 @@ */ package eu.carrade.amaury.UHCReloaded.modules.ingame.weather; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import org.bukkit.Material; import org.bukkit.WeatherType; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -51,7 +53,9 @@ @ModuleInfo ( name = "Weather", description = "Manages the in-game weather.", - settings = Config.class + settings = Config.class, + category = ModuleCategory.GAMEPLAY, + icon = Material.DOUBLE_PLANT // Sunflower - FIXME 1.13 ) public class WeatherModule extends UHModule { @@ -63,12 +67,18 @@ protected void onEnable() UR.get().getWorlds().forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); } + @Override + public void onEnableLate() + { + UR.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); + } + @EventHandler public void onGameStarts(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { - UR.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); + onEnableLate(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java index ed53b19..9e299d1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java @@ -65,9 +65,12 @@ protected void run() // Translation + info(""); info(I.t("{aqua}------ Translations ------")); info(I.t("Current language: {0} (translated by {1}).", I18n.getPrimaryLocale(), I18n.getTranslationTeam(I18n.getPrimaryLocale()))); info(I.t("Fallback language: {0} (translated by {1}).", I18n.getFallbackLocale(), I18n.getTranslationTeam(I18n.getFallbackLocale()))); + + info(""); info(I.t("{aqua}------ License ------")); info(I.t("Published under the CeCILL-B License.")); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java index d80e7f6..b75c5a9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java @@ -34,6 +34,7 @@ package eu.carrade.amaury.UHCReloaded.modules.other.about; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -43,6 +44,7 @@ import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import java.io.IOException; @@ -55,7 +57,9 @@ @ModuleInfo ( name = "About", - description = "Provides information about this plugin." + description = "Provides information about this plugin.", + category = ModuleCategory.OTHER, + icon = Material.BOOK ) public class AboutModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java index 8196416..7861f83 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java @@ -33,9 +33,11 @@ */ package eu.carrade.amaury.UHCReloaded.modules.other.playersLoader; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import fr.zcraft.zlib.components.commands.Command; +import org.bukkit.Material; import java.util.Collections; import java.util.List; @@ -43,7 +45,9 @@ @ModuleInfo ( name = "Players Loader", description = "Loads player into the server even if they never came before, so you can add them to teams and such. " + - "An interface to the built-in players loader." + "An interface to the built-in players loader.", + category = ModuleCategory.UTILITIES, + icon = Material.SKULL_ITEM // FIXME 1.13 ) public class PlayersLoaderModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java index 9e23f64..5111c81 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java @@ -33,18 +33,23 @@ */ package eu.carrade.amaury.UHCReloaded.modules.other.pomf; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.Config; import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.event.EventHandler; @ModuleInfo( name = "Pomf", description = "Pomf au milieu d'un épisode. #parceque", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.OTHER, + icon = Material.SLIME_BLOCK ) public class PomfModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index 9f2ef36..a56ab36 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.other.reports; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; @@ -87,8 +89,11 @@ "heals, statistics, etc., displayed on a web page, and gives the URL " + "when the match ends.\n\n" + "Using DamagesLogger by Florian Cassayre & Amaury Carrade.", - when = ModuleInfo.ModuleLoadTime.ON_GAME_START, - settings = Config.class + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.EXTERNAL, + icon = Material.BOOK_AND_QUILL, + settings = Config.class, + can_be_unloaded = false ) public class ReportsModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java index 1057d58..63df0fa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java @@ -34,7 +34,9 @@ package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; import com.google.common.collect.ImmutableMap; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; @@ -48,6 +50,7 @@ import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -72,7 +75,11 @@ "one alliance. If you form a three-players alliance, you lose two alliances. If you " + "run out of alliances, you can no longer form new alliances, and requests sent to you " + "will be silently declined.", - settings = Config.class + when = ModuleLoadTime.ON_GAME_STARTING, + category = ModuleCategory.SCENARII, + icon = Material.PAPER, + settings = Config.class, + can_be_loaded_late = false ) public class AlliancesModule extends UHModule { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0b49262..5074e6a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,7 +16,7 @@ lang: fr -# The modules to load & enable. You can add modules provided by other plugins. +# The modules to load & load. You can add modules provided by other plugins. # Each module's configuration is in plugins/UHPlugin/modules/<modulename>.yml . # You can put internal modules or refer to modules classes from other plugins. In all # cases, replace all dots in class paths by dashes. @@ -36,8 +36,9 @@ modules: "ingame-listHealth": true "ingame-teleportation": true "ingame-episodes": true + "ingame-killsCount": true "ingame-deathAnnouncement": true -# "ingame-kick": false + "ingame-kick": false "cosmetics-hardcoreHearts": true "cosmetics-motd": true @@ -47,7 +48,7 @@ modules: "other-playersLoader": true "other-about": true -# "scenarii-alliances": true + "scenarii-alliances": false # The worlds to use as main worlds. From 5b35c8251b3c0aff0936a962c39ace3c7e6183c9 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 15 Jan 2019 12:29:12 +0100 Subject: [PATCH 42/91] Added GUI to manage modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added GUI to list and manage modules. → Currently only allow to list basic properties, and enable/disable modules --- .../amaury/UHCReloaded/UHCReloaded.java | 8 +- .../UHCReloaded/core/ModuleCategory.java | 36 +-- .../amaury/UHCReloaded/core/ModuleInfo.java | 13 +- .../UHCReloaded/core/ModuleLoadTime.java | 28 ++- .../amaury/UHCReloaded/core/ModuleLogger.java | 28 ++- .../UHCReloaded/core/ModuleWrapper.java | 113 +++++++++- .../modules/beginning/wait/WaitModule.java | 3 +- .../modules/core/border/BorderModule.java | 2 +- .../core/modules/ModulesManagerModule.java | 14 +- .../modules/{ => commands}/ModuleCommand.java | 2 +- .../{ => commands}/ModulesCommand.java | 2 +- .../modules/commands/ModulesGUICommand.java | 50 ++++ .../modules/gui/ConfirmModuleDisableGUI.java | 112 +++++++++ .../core/modules/gui/FramedModuleGUI.java | 77 +++++++ .../core/modules/gui/ModulesListGUI.java | 213 ++++++++++++++++++ .../ingame/episodes/EpisodesModule.java | 7 + .../modules/other/reports/ReportsModule.java | 4 + .../scenarii/alliances/AlliancesModule.java | 2 + .../amaury/UHCReloaded/shortcuts/UR.java | 137 ++++++++++- .../amaury/UHCReloaded/utils/UHUtils.java | 53 +++++ 20 files changed, 854 insertions(+), 50 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/{ => commands}/ModuleCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/{ => commands}/ModulesCommand.java (98%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 5bfecf7..4232ec4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -428,11 +428,11 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) } @EventHandler - public void onModuleLoaded(final ModuleLoadedEvent e) + public void onModuleLoaded(final ModuleLoadedEvent ev) { - PluginLogger.info("Module {0} loaded.", e.getModule().getName()); + PluginLogger.info("Module {0} loaded.", ev.getModule().getName()); - if (e.isLoadedLate()) + if (ev.isLoadedLate()) { // If loaded late, we may have to re-register the module's commands. collectCommandsFromModules(); @@ -442,6 +442,8 @@ public void onModuleLoaded(final ModuleLoadedEvent e) @EventHandler public void onModuleUnloaded(final ModuleUnloadedEvent ev) { + PluginLogger.info("Module {0} unloaded.", ev.getModule().getName()); + // We remove commands if needed when a module is unloaded, // as it will be unable to handle them properly (the module // instance being null). diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java index 35b92f3..60cee4b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java @@ -35,7 +35,7 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import org.bukkit.DyeColor; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; @@ -48,70 +48,70 @@ public enum ModuleCategory I.t("Core Modules"), I.t("These modules are the core of UHCReloaded, required by other modules."), Material.BEDROCK, - DyeColor.WHITE + ChatColor.DARK_RED ), WORLD_GENERATION ( I.t("World Generation"), I.t("These modules alter the world generation. To use them, the server must be started without world."), Material.REDSTONE_COMPARATOR, - DyeColor.WHITE + ChatColor.DARK_GREEN ), WAITING_PHASE ( I.t("Waiting Phase"), I.t("These modules manage the waiting phase, when the game is not yet started."), Material.WATCH, - DyeColor.WHITE + ChatColor.YELLOW ), STARTING ( I.t("Game Beginning"), I.t("These modules enhance the starting phase of the game."), Material.FEATHER, - DyeColor.WHITE + ChatColor.GOLD ), END ( I.t("Game End"), I.t("These modules alter the game end (either player deaths or whole game end)."), Material.SKULL_ITEM, - DyeColor.WHITE + ChatColor.RED ), GAMEPLAY ( I.t("Gameplay"), I.t("These modules alter the world or gameplay during the game, e.g. adding or nerfing creatures, effects... This category does not contains scenarii, which are in a dedicated one."), Material.SADDLE, - DyeColor.WHITE + ChatColor.DARK_AQUA ), SCENARII ( I.t("Scenarii"), I.t("These modules adds scenarii to the game, i.e. global set of changes that changes the gameplay in a deeper way, and possibly the whole game experience."), Material.BEACON, - DyeColor.WHITE + ChatColor.AQUA ), UTILITIES ( I.t("Utilities"), I.t("These modules provides tools and utilities to manage the game and offer useful commands."), Material.COMMAND, - DyeColor.WHITE + ChatColor.DARK_PURPLE ), COSMETICS ( I.t("Cosmetics"), I.t("These modules adds cosmetics things to the game, like effects or visual enhancements that can be useful but does not change the gameplay."), new ItemStackBuilder(Material.RED_ROSE).data((short) 1), // FIXME 1.13 - DyeColor.WHITE + ChatColor.LIGHT_PURPLE ), EXTERNAL ( I.t("External"), I.t("These modules adds features alongside the game, like web maps, external summaries..."), Material.ENDER_CHEST, - DyeColor.WHITE + ChatColor.DARK_GREEN ), OTHER ( @@ -124,7 +124,7 @@ public enum ModuleCategory icon.setItemMeta(meta); return icon; }, - DyeColor.WHITE + ChatColor.WHITE ) ; @@ -133,9 +133,9 @@ public enum ModuleCategory private final String displayName; private final String description; private final ItemStack icon; - private final DyeColor color; + private final ChatColor color; - ModuleCategory(final String displayName, final String description, final ItemStack icon, DyeColor color) + ModuleCategory(final String displayName, final String description, final ItemStack icon, ChatColor color) { this.displayName = displayName; @@ -144,17 +144,17 @@ public enum ModuleCategory this.color = color; } - ModuleCategory(final String displayName, final String description, final ItemStackBuilder icon, DyeColor color) + ModuleCategory(final String displayName, final String description, final ItemStackBuilder icon, ChatColor color) { this(displayName, description, icon.item(), color); } - ModuleCategory(final String displayName, final String description, final Supplier<ItemStack> icon, DyeColor color) + ModuleCategory(final String displayName, final String description, final Supplier<ItemStack> icon, ChatColor color) { this(displayName, description, icon.get(), color); } - ModuleCategory(final String displayName, final String description, final Material icon, DyeColor color) + ModuleCategory(final String displayName, final String description, final Material icon, ChatColor color) { this(displayName, description, new ItemStack(icon), color); } @@ -174,7 +174,7 @@ public ItemStack getIcon() return icon.clone(); } - public DyeColor getColor() + public ChatColor getColor() { return color; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index d10e201..d9b6aa3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -50,10 +50,21 @@ String name() default ""; /** - * @return A short description for this module. + * @return A description for this module. */ String description() default ""; + /** + * @return A short description for this module. Used instead of the long one in the modules + * list GUI, so you can write novels in the description if you want. + */ + String short_description() default ""; + + /** + * @return The author(s) of this module. + */ + String authors() default ""; + /** * @return When this module should load. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java index 52af8e5..3adf9f3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java @@ -33,6 +33,8 @@ */ package eu.carrade.amaury.UHCReloaded.core; +import fr.zcraft.zlib.components.i18n.I; + public enum ModuleLoadTime { /** @@ -41,28 +43,44 @@ public enum ModuleLoadTime * Please note that most core modules (and localization) are not loaded at this point. Use that * for modules altering the world generation. */ - STARTUP, + STARTUP(I.t("When the server starts")), /** * Loads the module after the world(s), or immediately if the plugin is reloaded. * The thing is, all worlds will be loaded when the module is. */ - POST_WORLD, + POST_WORLD(I.t("When the worlds are loaded")), /** * Loads the module when the game phase is set to STARTING, i.e. when the /uh start command * is used. */ - ON_GAME_STARTING, + ON_GAME_STARTING(I.t("When the game start command is executed")), /** * Loads the module when the game starts, i.e. when all players falls from their spawn into * the world. */ - ON_GAME_START, + ON_GAME_START(I.t("When the game starts for real (after teleportations)")), /** * Loads the module when the game ends. */ - ON_GAME_END + ON_GAME_END(I.t("When the game ends")) + + ; + + + private final String description; + + ModuleLoadTime(String description) + { + + this.description = description; + } + + public String getDescription() + { + return description; + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index 1cae3c2..d200ecd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -46,6 +46,7 @@ public class ModuleLogger extends Logger { + private final String moduleName; private final String loggerName; public ModuleLogger(Class<?extends UHModule> module) @@ -55,7 +56,8 @@ public ModuleLogger(Class<?extends UHModule> module) setParent(ZLib.getPlugin().getLogger()); setLevel(Level.ALL); - loggerName = "[" + ZLib.getPlugin().getName() + "] [" + ModuleWrapper.computeModuleName(module) + "] "; + moduleName = ModuleWrapper.computeModuleName(module); + loggerName = "[" + ZLib.getPlugin().getName() + "] [" + moduleName + "] "; } @Override @@ -111,18 +113,12 @@ public void error(String message, Object... args) log(Level.SEVERE, message, args); } - public void broadcastAdministrative(String message) + public void broadcastAdministrative(final String message) { - // TODO use permissions - Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> { - player.sendMessage(""); - player.sendMessage(message); - }); - - info(ChatColor.stripColor(message)); + broadcastAdministrative(message, ChatColor.stripColor(message)); } - public void broadcastAdministrative(RawText message) + public void broadcastAdministrative(final RawText message) { // TODO use permissions Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> { @@ -132,4 +128,16 @@ public void broadcastAdministrative(RawText message) info(ChatColor.stripColor(message.toPlainText())); } + + public void broadcastAdministrativePrefixed(final String message) + { + broadcastAdministrative(ChatColor.GREEN + moduleName + ChatColor.GRAY + " \u2758 " + ChatColor.RESET + message, ChatColor.stripColor(message)); + } + + private void broadcastAdministrative(final String messagePlayers, final String messageConsole) + { + // TODO use permissions + Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> player.sendMessage(messagePlayers)); + info(messageConsole); + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 829f6b0..3ac05e2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -38,24 +38,36 @@ import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; import fr.zcraft.zlib.tools.reflection.Reflection; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.stream.Stream; public class ModuleWrapper { private final String name; + private final String shortDescription; private final String description; + private final String authors; + private final ModuleLoadTime when; + private final ModuleCategory category; + private final Material icon; + private boolean enabled; private final Class<? extends UHModule> moduleClass; @@ -86,10 +98,14 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable if (info == null) { description = ""; + shortDescription = ""; + authors = ""; internal = false; canBeUnloaded = true; canBeLoadedLate = true; when = ModuleLoadTime.POST_WORLD; + category = ModuleCategory.OTHER; + icon = Material.AIR; moduleConfiguration = null; settingsFileName = null; dependencies = new String[] {}; @@ -97,10 +113,14 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable else { description = info.description(); + shortDescription = info.short_description(); + authors = info.authors(); internal = info.internal(); canBeUnloaded = info.can_be_unloaded(); canBeLoadedLate = info.can_be_loaded_late(); when = info.when(); + category = info.category(); + icon = info.icon(); moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); dependencies = info.depends(); @@ -184,14 +204,14 @@ public boolean setEnabled(boolean enabled) // Can we enabled this module? if (enabled) { - if (canBeReEnabled()) + if (!canBeEnabled()) { return false; } } // Can we disable this module? - else if (internal || !canBeUnloaded) + else if (!canBeDisabled()) { return false; } @@ -222,9 +242,17 @@ else if (internal || !canBeUnloaded) * @return {@code true} if after being disabled, this module will be reloadable * (can depends on the moment this method is called). */ - public boolean canBeReEnabled() + public boolean canBeEnabled() { - return !canBeLoadedLate && UR.get().isLoaded(when); + return canBeLoadedLate || !UR.get().isLoaded(when); + } + + /** + * @return {@code true} if, at the moment this method is called, this module can be disabled. + */ + public boolean canBeDisabled() + { + return !internal && !(isLoaded() && !canBeUnloaded); } /** @@ -243,6 +271,83 @@ public String getDescription() return description != null && !description.isEmpty() ? description : null; } + /** + * @return A short description for the module, or {@code null} if none provided. + */ + public String getShortDescription() + { + return shortDescription != null && !shortDescription.isEmpty() ? shortDescription : null; + } + + /** + * @return The authors of the module, or {@code null} if not provided. + */ + public String getAuthors() + { + return authors != null && !authors.isEmpty() ? authors : null; + } + + /** + * @return This module's category. + */ + public ModuleCategory getCategory() + { + return category; + } + + /** + * @return This module's icon: either the declared one, or the category's. + */ + public ItemStack getIcon() + { + return icon == Material.AIR ? category.getIcon() : new ItemStack(icon); + } + + /** + * Generates and returns a full icon for the module, including its status and + * description in the tooltip. + * + * @param complete If {@code true}, will use the long complete description. + * Else, will use the short description if available, else + * the long one. + * @return The icon. + */ + public ItemStackBuilder getFullIcon(final boolean complete) + { + final ItemStackBuilder icon = new ItemStackBuilder(getIcon()) + .title( + (isLoaded() ? ChatColor.GREEN : (isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + "" + ChatColor.BOLD + "\u2758 ", + category.getColor() + "" + ChatColor.BOLD + name + ) + .loreLine( + ChatColor.DARK_GRAY + category.getDisplayName(), + ChatColor.DARK_GRAY + " - ", + ChatColor.DARK_GRAY + (enabled ? (isLoaded() ? I.t("Enabled and loaded") : I.t("Enabled")) : I.t("Disabled")) + ); + + String description; + if (((description = getShortDescription()) != null && !complete) || (description = getDescription()) != null) + { + icon.loreSeparator().longLore(ChatColor.WHITE, description, complete ? 100 : 42); + } + + icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Load time")).longLore(ChatColor.WHITE, when.getDescription(), 42); + + if (dependencies.length != 0) + { + icon.loreSeparator().longLore(ChatColor.BLUE, I.t("External dependencies")); + Stream.of(dependencies).forEach(dep -> icon.loreLine(ChatColor.GRAY + "- ", (Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED) + dep)); + } + + String authors; + if ((authors = getAuthors()) != null) + { + icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Brought to you by")).longLore(ChatColor.WHITE, authors, 42); + } + + return icon.hideAttributes(); + } + /** * @return A list of external plugins this module depends on. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index 01b78cd..8ed737c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -73,7 +73,8 @@ description = "Manages the waiting phase: inventory, effects, modes, teleportation, etc.", category = ModuleCategory.WAITING_PHASE, icon = Material.WATCH, - settings = Config.class + settings = Config.class, + can_be_loaded_late = false ) public class WaitModule extends UHModule { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 9d45329..1a5ab92 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -161,7 +161,7 @@ public void prepareInjectionIntoSidebar() public void injectIntoSidebar(Player player, SidebarInjector injector) { if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; - injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, sidebar); + injector.injectLines(SidebarInjector.SidebarPriority.MIDDLE, true, sidebar); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java index 71f3154..1880f04 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -38,6 +38,9 @@ import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModuleCommand; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModulesCommand; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModulesGUICommand; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; @@ -51,7 +54,7 @@ @ModuleInfo ( - name = "Modules Manager", + name = "Modules", description = "Offers to the users a way to manage modules.", when = ModuleLoadTime.STARTUP, category = ModuleCategory.CORE, @@ -63,14 +66,19 @@ public class ModulesManagerModule extends UHModule @Override public List<Class<? extends Command>> getCommands() { - return Arrays.asList(ModulesCommand.class, ModuleCommand.class); + return Arrays.asList( + ModulesCommand.class, + ModuleCommand.class, + ModulesGUICommand.class + ); } @Override public Map<String, Class<? extends Command>> getCommandsAliases() { return ImmutableMap.of( - "modules", ModulesCommand.class + "modules", ModulesCommand.class, + "config", ModulesGUICommand.class ); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java index d3c533a..08e06c6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModuleCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules; +package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java index 64e4986..d4d53ef 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules; +package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java new file mode 100644 index 0000000..50d512f --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java @@ -0,0 +1,50 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; + +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.ModulesListGUI; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.gui.Gui; + +@CommandInfo (name = "modules-gui") +public class ModulesGUICommand extends Command +{ + @Override + protected void run() throws CommandException + { + Gui.open(playerSender(), new ModulesListGUI()); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java new file mode 100644 index 0000000..278de8a --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java @@ -0,0 +1,112 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; + +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import fr.zcraft.zlib.components.gui.GuiAction; +import fr.zcraft.zlib.components.gui.GuiUtils; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import java.util.List; +import java.util.stream.Collectors; + +public class ConfirmModuleDisableGUI extends FramedModuleGUI +{ + public ConfirmModuleDisableGUI(final ModuleWrapper module) + { + super(module); + } + + @Override + protected void onUpdate() + { + setTitle(I.t("{darkgray}{0} » {black}Disable", module.getName())); + setSize(5 * 9); + + final List<String> title = GuiUtils.generateLore(I.t("If you disable this module, you won't be able to re-enable it."), 38); + final String firstTitleLine = title.get(0); + + title.remove(0); + + final ItemStack confirm = new ItemStackBuilder(Material.SKULL_ITEM) + .data((short) 3) + .title(ChatColor.RED, ChatColor.BOLD + firstTitleLine) + .lore(title.stream().map(line -> ChatColor.RED + "" + ChatColor.BOLD + line).collect(Collectors.toList())) + .loreSeparator() + .longLore(ChatColor.GRAY, I.t("This module cannot be re-loaded after its original load period. This means that if you disable this module, you won't be able to re-enable it during this game."), 38) + .longLore(ChatColor.WHITE, I.t("Are you sure you want to disable {0}?", module.getName()), 38) + .item(); + + final SkullMeta meta = (SkullMeta) confirm.getItemMeta(); + meta.setOwner("MHF_Question"); + confirm.setItemMeta(meta); + + action("", 22, confirm); + + final ItemStackBuilder no = new ItemStackBuilder(Material.STAINED_GLASS_PANE) + .data(DyeColor.RED.getWoolData()) // FIXME 1.13 + .title(ChatColor.GREEN, ChatColor.BOLD + I.t("I changed my mind")) + .longLore(ChatColor.GRAY, I.t("Go back without disabling the module")); + + final ItemStackBuilder yes = new ItemStackBuilder(Material.STAINED_GLASS_PANE) + .data(DyeColor.GREEN.getWoolData()) // FIXME 1.13 + .title(ChatColor.RED, ChatColor.BOLD + I.t("Yes, disable")) + .longLore(ChatColor.GRAY, I.t("Disable {0} without any possibility of re-enabling it", module.getName())); + + for (int slot : new int[] {10, 11, 19, 20, 28, 29}) + { + action("cancel", slot, no); + action("disable", slot + 5, yes); + } + } + + @GuiAction + protected void cancel() + { + close(); + } + + @GuiAction + protected void disable() + { + module.setEnabled(false); + close(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java new file mode 100644 index 0000000..53084fd --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java @@ -0,0 +1,77 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; + +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import fr.zcraft.zlib.components.gui.ActionGui; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zteams.colors.ColorsUtils; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public abstract class FramedModuleGUI extends ActionGui +{ + protected final ModuleWrapper module; + + public FramedModuleGUI(ModuleWrapper module) + { + this.module = module; + } + + @Override + protected void onAfterUpdate() + { + final ItemStack framePart = new ItemStackBuilder(Material.STAINED_GLASS_PANE) + .title("") + .data(ColorsUtils.chat2Dye(module.getCategory().getColor()).getWoolData()) // FIXME 1.13 + .item(); + + // Top and bottom + for (int slot = 0; slot < 9; slot++) + { + action("", slot, framePart); + action("", getSize() - (slot + 1), framePart); + } + + // Sides + for (int line = 0; line < getSize() / 9; line++) + { + action("", line * 9, framePart); + action("", line * 9 + 8, framePart); + } + + // Icon + action("__module_icon__", 4, module.getFullIcon(false)); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java new file mode 100644 index 0000000..c9a0527 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java @@ -0,0 +1,213 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.gui.ExplorerGui; +import fr.zcraft.zlib.components.gui.Gui; +import fr.zcraft.zlib.components.gui.GuiAction; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemStack; + +public class ModulesListGUI extends ExplorerGui<ModuleWrapper> +{ + /** + * The category filtered. {@code null} means all. + */ + private ModuleCategory filterCategory; + + public ModulesListGUI() + { + this(null); + } + + public ModulesListGUI(final ModuleCategory filterCategory) + { + this.filterCategory = filterCategory; + } + + @Override + protected void onUpdate() + { + setSize(6 * 9); + setMode(Mode.READONLY); + setKeepHorizontalScrollingSpace(true); + + final ModuleWrapper[] modules = UR.get().getModules().stream() + .filter(module -> filterCategory == null || module.getCategory() == filterCategory) + .sorted((module1, module2) -> { + if (module1.equals(module2)) return 0; + + if (module1.getCategory() != module2.getCategory()) + return Integer.compare(module1.getCategory().ordinal(), module2.getCategory().ordinal()); + + if (module1.getWhen() != module2.getWhen()) + return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal()); + + if (module1.isInternal() != module2.isInternal()) return module1.isInternal() ? -1 : 1; + + return module1.getName().compareTo(module2.getName()); + }) + .toArray(ModuleWrapper[]::new); + + setData(modules); + + // Sets the title + if (filterCategory == null) + { + setTitle(I.t("{black}All modules {darkgray}({0})", UR.get().getModules().size())); + } + else + { + setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, UR.get().getModules().size())); + } + + // Displays the bottom bar of color + final ItemStackBuilder bottomColorStripe = new ItemStackBuilder(Material.STAINED_GLASS_PANE) + .data(ColorsUtils.chat2Dye(filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE).getWoolData()) // FIXME 1.13 + .title(filterCategory != null ? filterCategory.getColor() + "" + ChatColor.BOLD + filterCategory.getDisplayName() : ""); + if (filterCategory != null) bottomColorStripe.longLore(ChatColor.GRAY, filterCategory.getDescription(), 38); + + for (int slot = getSize() - 9; slot < getSize(); slot++) action("", slot, bottomColorStripe); + + // Displays the category filter button + final Material endCrystal = Material.getMaterial("END_CRYSTAL"); + final ItemStackBuilder catFilter = new ItemStackBuilder(filterCategory == null ? new ItemStack(endCrystal != null ? endCrystal : Material.HOPPER) : filterCategory.getIcon()) + .title(ChatColor.YELLOW, ChatColor.BOLD + I.t("Filter modules category")) + .loreSeparator(); + + final String prefixActive = ChatColor.YELLOW + "» "; + final String prefixInactive = ChatColor.DARK_GRAY + "» " + ChatColor.GRAY; + + catFilter.loreLine((filterCategory == null ? prefixActive : prefixInactive) + I.t("All modules")); + + for (ModuleCategory category : ModuleCategory.values()) + { + catFilter.loreLine((filterCategory == category ? prefixActive : prefixInactive) + category.getDisplayName()); + } + + catFilter.loreSeparator(); + catFilter.longLore(ChatColor.WHITE, filterCategory == null ? I.t("Click to filter the modules by category. A description will be displayed here.") : filterCategory.getDescription(), 38); + + action("switch_category", getSize() - 5, catFilter); + } + + @Override + protected ItemStack getViewItem(final ModuleWrapper module) + { + final ItemStackBuilder item = module.getFullIcon(false).loreSeparator(); + final String prefix = ChatColor.DARK_GRAY + "» "; + + if (!module.isEnabled()) + { + if (module.canBeEnabled()) + { + item.lore(prefix + I.t("{white}Click {gray}to enable this module")); + } + else + { + item.lore(prefix + I.t("{red}This module can no longer be enabled.")); + } + } + else + { + if (module.canBeDisabled()) + { + item.lore(prefix + I.t("{white}Click {gray}to disable this module")); + } + else + { + item.lore(prefix + I.t("{red}This module cannot be disabled.")); + } + } + + item.lore(prefix + I.t("{white}Right click {gray}to access details and config")); + + return item.item(); + } + + + /** + * On left click + * @param module Clicked module + */ + @Override + protected ItemStack getPickedUpItem(final ModuleWrapper module) + { + if (module.isEnabled() && !module.canBeEnabled()) + { + Gui.open(getPlayer(), new ConfirmModuleDisableGUI(module), this); + } + else + { + if (module.setEnabled(!module.isEnabled())) + { + if (module.isEnabled()) + { + UR.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {green}enabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); + } + else + { + UR.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {red}disabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); + } + } + + update(); + } + + return null; + } + + @Override + protected void onRightClick(final ModuleWrapper module) + { + // TODO open details-gui + } + + @GuiAction + protected void switch_category(final InventoryClickEvent ev) + { + filterCategory = UHUtils.getNextElement(filterCategory, ev.getClick() == ClickType.RIGHT ? -1 : 1, true, ModuleCategory.class); + update(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java index 304e063..c874eff 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java @@ -94,6 +94,13 @@ protected void onEnable() episodesTimer.start(); } + @Override + protected void onDisable() + { + episodesTimer.setDisplayed(false); + timers.unregisterTimer(episodesTimer); + } + @Override public List<Class<? extends Command>> getCommands() { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index a56ab36..b0f567e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -85,10 +85,14 @@ @ModuleInfo ( name = "Reports", + short_description = "Generates reports of the game, including history, damages, " + + "heals, statistics, etc., displayed on a web page, and gives the URL " + + "when the match ends.", description = "Generates reports of the game, including history, damages, " + "heals, statistics, etc., displayed on a web page, and gives the URL " + "when the match ends.\n\n" + "Using DamagesLogger by Florian Cassayre & Amaury Carrade.", + authors = "Florian Cassayre & Amaury Carrade", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.EXTERNAL, icon = Material.BOOK_AND_QUILL, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java index 63df0fa..00495f7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java @@ -60,6 +60,8 @@ @ModuleInfo ( name = "Alliances Scenario", + short_description = "Provides an alliances-based game, where players form alliances only " + + "by meeting in the game, everyone being alone at the beginning.", description = "If enabled, the game will be alliances-based.\n\n" + "To use this scenario, start without any team configured. All players " + "will be alone at the beginning. If they meet someone, they can ask for " + diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index 20a1128..591bc0c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -33,9 +33,18 @@ */ package eu.carrade.amaury.UHCReloaded.shortcuts; +import com.google.common.reflect.ClassPath; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleLogger; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import org.apache.commons.lang.ArrayUtils; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; /** @@ -43,6 +52,9 @@ */ public final class UR { + private static final Map<Class<?>, Class<? extends UHModule>> classesModules = new HashMap<>(); + private static final Map<String, Class<? extends UHModule>> packagesModules = new HashMap<>(); + /** * Returns the plugin's instance. */ @@ -53,7 +65,7 @@ public static UHCReloaded get() /** * Gets a module's instance. This may return null if the module is not currently - * enabled. + * loaded. * * @param moduleClass The module's class. * @param <M> The module's type. @@ -65,9 +77,32 @@ public static <M extends UHModule> M module(final Class<M> moduleClass) return UHCReloaded.getModule(moduleClass); } + /** + * Returns the logger for the caller class' module. + * + * This works by looking up for the module class in the caller class' + * package or “parent” packages. Throws an exception if no module class can + * be found. + * + * @return The module's logger. + * @throws IllegalArgumentException if no module can be found for the caller + * class. + */ + public static UHModule module() + { + final Class<?> caller = Reflection.getCallerClass(); + if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in module()"); + + final Class<? extends UHModule> moduleClass = getModuleFromClass(caller); + + if (moduleClass != null) return module(moduleClass); + + throw new IllegalArgumentException("The class " + caller.getCanonicalName() + " is not inside a module's package."); + } + /** * Returns the logger for a given module. This may return null if the module is not - * currently enabled. + * currently loaded. * * @param moduleClass The module's class. * @return The module's logger. @@ -85,5 +120,103 @@ public static ModuleLogger log(final Class<? extends UHModule> moduleClass) } } + /** + * Returns the logger for the caller class' module. + * + * This works by looking up for the module class in the caller class' + * package or “parent” packages. Throws an exception if no module class can + * be found. + * + * @return The module's logger. + * @throws IllegalArgumentException if no module can be found for the caller + * class. + */ + public static ModuleLogger log() + { + final Class<?> caller = Reflection.getCallerClass(); + if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in log()"); + + final Class<? extends UHModule> moduleClass = getModuleFromClass(caller); + + if (moduleClass != null) return log(moduleClass); + + throw new IllegalArgumentException("The class " + caller.getCanonicalName() + " is not inside a module's package."); + } + + /** + * Tries to retrieve the module of a given class. + * + * It will lookup for a class extending {@link UHModule} in the class's + * package, then in the “parent” package, etc., until the “root” package is + * reached. {@code null} will be returned if no package can be found. + * + * The result of this method is cached at runtime. + * + * @param clazz The class to search the module of. + * @return The module class, or {@code null} if not found. + */ + private static Class<? extends UHModule> getModuleFromClass(final Class<?> clazz) + { + if (classesModules.containsKey(clazz)) return classesModules.get(clazz); + + try + { + final ClassPath classPath = ClassPath.from(clazz.getClassLoader()); + final Set<String> analyzedPackages = new HashSet<>(); + + String packaj = clazz.getPackage().getName(); + while (packaj != null) + { + // Cached? + if (packagesModules.containsKey(packaj)) return packagesModules.get(packaj); + + analyzedPackages.add(packaj); + + // We try to find a class in this package extending UHModule + for (final ClassPath.ClassInfo packajClazzInfo : classPath.getTopLevelClasses(packaj)) + { + final Class<?> packajClazz = packajClazzInfo.load(); + + if (UHModule.class.isAssignableFrom(packajClazz)) + { + // We found the One™. + @SuppressWarnings("unchecked") + final Class<? extends UHModule> moduleClazz = (Class<? extends UHModule>) packajClazz; + + // We cache as hard as we can as these operations can be heavy. + analyzedPackages.forEach(analyzed -> packagesModules.put(analyzed, moduleClazz)); + classesModules.put(clazz, moduleClazz); + + return moduleClazz; + } + } + + // If we fail, we try with the “parent” package. + if (packaj.contains(".")) + { + final String[] packajParts = packaj.split("\\."); + ArrayUtils.remove(packajParts, packajParts.length - 1); + packaj = String.join(".", (String[]) ArrayUtils.remove(packajParts, packajParts.length - 1)); + } + else + { + packaj = null; + } + } + + PluginLogger.error("Unable to find module for class {0}", clazz.getCanonicalName()); + classesModules.put(clazz, null); + analyzedPackages.forEach(analyzed -> packagesModules.put(analyzed, null)); + + return null; + } + catch (final Throwable e) + { + PluginLogger.error("Unable to find module for class {0}", e, clazz.getCanonicalName()); + classesModules.put(clazz, null); + return null; + } + } + private class UnknownModule extends UHModule {} } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java index 1a7cf68..87f0558 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java @@ -34,6 +34,7 @@ import fr.zcraft.zlib.tools.Callback; import fr.zcraft.zlib.tools.PluginLogger; +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -401,4 +402,56 @@ public static World getOverworld() .filter(world -> world.getEnvironment() != World.Environment.NETHER && world.getEnvironment() != World.Environment.THE_END) .findFirst().orElse(null); } + + /** + * Returns the next (or other...) enum value, as declared in the source + * code. + * + * @param enumValue An enum value. + * @param shift A shift. If this is positive, will return the (shift)th + * element after, else the |shift|th element before. The enum + * is visited as a cycle. + * + * @return The next/previous/other enum value, according to shift. + */ + public static <T extends Enum> T getNextElement(final T enumValue, final int shift) + { + return getNextElement(enumValue, shift, false, null); + } + + /** + * Returns the next (or other...) enum value, as declared in the source + * code. + * + * @param enumValue An enum value. + * @param shift A shift. If this is positive, will return the (shift)th + * element after, else the |shift|th element before. The enum + * is visited as a cycle. + * @param shiftThroughNull If {@code true}, will return {@code null} after the + * last element, and the first element after {@code null}. + * Else, will throw an {@link IllegalArgumentException} if + * the given element is {@code null}. + * @param enumClass The (non-empty) enum class, required if + * {@code shiftThroughNull = true}. Else, can be {@code null}. + * @param <T> The enum type. + * + * @return The next/previous/other enum value, according to shift. + */ + public static <T extends Enum> T getNextElement(final T enumValue, final int shift, final boolean shiftThroughNull, Class<T> enumClass) + { + Validate.isTrue(shiftThroughNull || enumValue != null, "The enum value cannot be null with shiftThroughNull = false."); + + if (enumValue != null) enumClass = (Class<T>) enumValue.getClass(); + + final T[] values = enumClass.getEnumConstants(); + final int ord = enumValue != null ? enumValue.ordinal() : values.length; + + final int shiftLength = shiftThroughNull ? values.length + 1 : values.length; + + int newOrd = (ord + shift) % shiftLength; + if (newOrd < 0) newOrd += shiftLength; + + if (shiftThroughNull && newOrd == values.length) return null; + return values[newOrd]; + } } From b38c399adfb14eb4aedd57286ac930e67f1fdab3 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Tue, 15 Jan 2019 16:24:44 +0100 Subject: [PATCH 43/91] Added Compass and fixed some bugs here and there --- .../amaury/UHCReloaded/core/ModuleLogger.java | 3 +- .../modules/core/border/BorderModule.java | 2 +- .../UHCReloaded/modules/core/game/Config.java | 2 +- .../core/spectators/SpectatorsModule.java | 5 +- .../gameplay/compass/CompassModule.java | 220 +++++++++++++++ .../gameplay/compass/CompassRecipes.java | 260 ++++++++++++++++++ .../modules/gameplay/compass/Config.java | 59 ++++ .../modules/other/reports/ReportsModule.java | 1 + .../old/listeners/CraftingListener.java | 69 +---- .../old/listeners/GameplayListener.java | 102 ------- .../amaury/UHCReloaded/shortcuts/UR.java | 4 +- .../amaury/UHCReloaded/utils/UHUtils.java | 20 +- src/main/resources/config.yml | 2 + 13 files changed, 566 insertions(+), 183 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index d200ecd..d1d47f7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.core; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.text.RawMessage; @@ -131,7 +132,7 @@ public void broadcastAdministrative(final RawText message) public void broadcastAdministrativePrefixed(final String message) { - broadcastAdministrative(ChatColor.GREEN + moduleName + ChatColor.GRAY + " \u2758 " + ChatColor.RESET + message, ChatColor.stripColor(message)); + broadcastAdministrative(UHUtils.prefixedMessage(moduleName, message), ChatColor.stripColor(message)); } private void broadcastAdministrative(final String messagePlayers, final String messageConsole) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 1a5ab92..9d45329 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -161,7 +161,7 @@ public void prepareInjectionIntoSidebar() public void injectIntoSidebar(Player player, SidebarInjector injector) { if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; - injector.injectLines(SidebarInjector.SidebarPriority.MIDDLE, true, sidebar); + injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, sidebar); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index 423a245..441d4b9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -70,7 +70,7 @@ public static final class BeginningSection extends ConfigurationSection public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); - public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0, 15, 0)); + public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0, 1, 0)); public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 20, 0)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index 73256ed..3eb4e68 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -49,6 +49,7 @@ import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -133,7 +134,7 @@ public void addSpectator(final UUID playerID) spectators.add(playerID); if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) - manager.setSpectating(playerID, true); + RunTask.nextTick(() -> manager.setSpectating(playerID, true)); } /** @@ -156,7 +157,7 @@ public void removeSpectator(final UUID playerID) spectators.remove(playerID); if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) - manager.setSpectating(playerID, false); + RunTask.nextTick(() -> manager.setSpectating(playerID, false)); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java new file mode 100644 index 0000000..e6861e4 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java @@ -0,0 +1,220 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHSound; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.*; + +@ModuleInfo ( + name = "Compass", + description = "Compasses in the game can be used to point to the nearest player, " + + "and/or give the distance to them, at a configurable fee. The compass' craft " + + "can also be made harder.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.COMPASS, + settings = Config.class +) +public class CompassModule extends UHModule +{ + private CompassRecipes recipes = null; + + private Set<UUID> compassLocked = new HashSet<>(); + + + @Override + public void onEnable() + { + recipes = ZLib.loadComponent(CompassRecipes.class); + } + + @Override + protected void onDisable() + { + if (recipes != null) + { + ZLib.unregisterEvents(recipes); + recipes = null; + } + } + + /** + * Used to update the compass. + */ + @EventHandler (ignoreCancelled = true) + public void onPlayerInteract(final PlayerInteractEvent ev) + { + if (compassLocked.contains(ev.getPlayer().getUniqueId())) return; + else + { + compassLocked.add(ev.getPlayer().getUniqueId()); + RunTask.later(() -> compassLocked.remove(ev.getPlayer().getUniqueId()), 20L); + } + + if ((ev.getAction() == Action.RIGHT_CLICK_AIR || ev.getAction() == Action.RIGHT_CLICK_BLOCK) + && ev.getPlayer().getItemInHand().getType() == Material.COMPASS + && UR.module(GameModule.class).isAlive(ev.getPlayer())) + { + final Player compassUser = ev.getPlayer(); + + // We check if the player have what needed + + int feeAvailable = Arrays.stream(compassUser.getInventory().getContents()) + .filter(item -> item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) + .mapToInt(ItemStack::getAmount) + .sum(); + + if (feeAvailable < Config.COMPASS_FEE_AMOUNT.get()) + { + RawMessage.send(compassUser, new RawText(I.t("To use the compass, you must have the following: ")) + .then().translate(new ItemStack(Config.COMPASS_FEE_ITEM.get(), Config.COMPASS_FEE_AMOUNT.get())) + .then(Config.COMPASS_FEE_AMOUNT.get() > 1 ? " × " + Config.COMPASS_FEE_AMOUNT.get() + "." : ".") + .build() + ); + new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + return; + } + + // We consume the fee + + int feeLeft = Config.COMPASS_FEE_AMOUNT.get(); + + for (final ItemStack item : compassUser.getInventory().getContents()) + { + if (item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) + { + final int consumed = item.getAmount() - feeLeft; + + if (consumed <= 0) + { + feeLeft -= item.getAmount(); + item.setAmount(0); + item.setType(Material.AIR); + } + else + { + feeLeft = 0; + item.setAmount(consumed); + } + + if (feeLeft == 0) break; + } + } + + // We lookup for the nearest player + + Player nearest = null; + Double distance = Double.MAX_VALUE; + + for (Player otherPlayer : UR.module(GameModule.class).getAliveConnectedPlayers()) + { + try + { + Double calc = compassUser.getLocation().distanceSquared(otherPlayer.getLocation()); + + if (calc > 1 && calc < distance) + { + distance = calc; + + if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(ZTeams.get().getTeamForPlayer(compassUser), ZTeams.get().getTeamForPlayer(otherPlayer)))) + { + nearest = otherPlayer.getPlayer(); + } + } + } + catch (Exception ignored) {} // Different worlds + } + + if (nearest == null) + { + /// Error message if a player tries to use his pointing compass without a player nearby. + compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("Only silence answers your request."))); // TODO update language files + + new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + return; + } + + final CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); + + if (behavior == CompassBehavior.GIVE_DIRECTION || behavior == CompassBehavior.GIVE_BOTH) + { + /// Success message when a player uses his pointing compass. + compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("The compass now points to the closest player."))); // TODO update language files + compassUser.setCompassTarget(nearest.getLocation()); + } + + if (behavior == CompassBehavior.GIVE_DISTANCE || behavior == CompassBehavior.GIVE_BOTH) + { + compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), I.tn("{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); + } + + else if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) + { + // TODO + } + + new UHSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); + } + } + + public enum CompassBehavior + { + GIVE_DIRECTION, + GIVE_DISTANCE, + GIVE_BOTH, + GIVE_EITHER_RANDOMLY + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java new file mode 100644 index 0000000..cf164bc --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java @@ -0,0 +1,260 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; + +import fr.zcraft.zlib.core.ZLibComponent; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.CraftingInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; + +public class CompassRecipes extends ZLibComponent implements Listener +{ + /** + * Checks if the recipe is a valid compass recipe. + * <p> + * A valid compass recipe is a recipe with: + * <ul> + * <li> + * in the center, the valid ingredient for the current compass craft + * (redstone, ender pearl or eye of ender); + * </li> + * <li> + * four iron ingots placed like the vanilla compass recipe; + * </li> + * <li> + * in the four corners, a bone, a rotten flesh, a spider eye and a gunpowder, + * placed in any shape. + * </li> + * </ul> + * <p> + * Executed in the {@code onInventoryClick} and {@code onInventoryDrag} events, to allow this to be recognized even if + * the recipe is not registered. + * + * @param matrix The content of the crafting inventory. + * @return true if the recipe is an alternate recipe for the compass. + */ + public boolean isValidCompassRecipe(final ItemStack[] matrix) + { + if (matrix.length <= 5) + { + return false; // Small crafting grid + } + + + // 0: is it fully filled? + + for (int i = 0; i < 9; i++) + { + if (matrix[i] == null) return false; + } + + + // 1: check of the static part (central ingredient + iron) + + final Material iron1 = matrix[1].getType(); + final Material iron2 = matrix[3].getType(); + final Material iron3 = matrix[5].getType(); + final Material iron4 = matrix[7].getType(); + final Material centralIngredient = matrix[4].getType(); + + if (!(iron1.equals(Material.IRON_INGOT) + && iron2.equals(Material.IRON_INGOT) + && iron3.equals(Material.IRON_INGOT) + && iron4.equals(Material.IRON_INGOT) + && centralIngredient.equals(getCentralIngredient()))) + { + return false; + } + + + // 2: check of the dynamic part (loots) + + final ArrayList<Material> corners = new ArrayList<>(); + corners.add(matrix[0].getType()); + corners.add(matrix[2].getType()); + corners.add(matrix[6].getType()); + corners.add(matrix[8].getType()); + + return corners.contains(Material.BONE) + && corners.contains(Material.ROTTEN_FLESH) + && corners.contains(Material.SPIDER_EYE) + && corners.contains(Material.SULPHUR); + } + + private Material getCentralIngredient() + { + switch (Config.RECIPE.get()) + { + case MEDIUM: + return Material.ENDER_PEARL; + + case HARD: + return Material.EYE_OF_ENDER; + + default: + return Material.REDSTONE; + } + } + + @EventHandler (ignoreCancelled = true) + public void onInventoryClick(final InventoryClickEvent ev) + { + if (Config.RECIPE.get() == CompassRecipe.DEFAULT) return; + + if (ev.getWhoClicked() instanceof Player) + { + final Inventory inventory = ev.getInventory(); + + // Workaround to fix the crafting grid being not updated when the item is taken + // from the grid. + if (inventory instanceof CraftingInventory && ev.getSlotType() == InventoryType.SlotType.RESULT) + { + RunTask.later( + () -> ev.getViewers().stream() + .filter(viewer -> viewer instanceof Player) + .forEach(viewer -> ((Player) viewer).updateInventory()), + 1L + ); + } + + + /* *** Allows any shape for the loots in the compass recipe. *** */ + + if (inventory instanceof CraftingInventory) + { + // This is ran one tick after the click because when the event is fired, the inventory + // object is not updated, and so the result of the isValidCompassResult is invalid. + + RunTask.later(() -> + { + if (isValidCompassRecipe(((CraftingInventory) inventory).getMatrix())) + { + // Puts the compass in the result slot + if (ev.getSlotType() == InventoryType.SlotType.CRAFTING) + { + ((CraftingInventory) inventory).setResult(new ItemStack(Material.COMPASS)); + ev.setResult(Event.Result.ALLOW); + + ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed + } + + // Consumes the materials in the crafting grid. + // Because this is not an "official" recipe, we need to do that manually. + else if (ev.getSlotType() == InventoryType.SlotType.RESULT) + { + int index = 1; + for (ItemStack stack : ((CraftingInventory) inventory).getMatrix()) + { + if (stack == null) continue; + + if (stack.getAmount() != 1) + { + stack.setAmount(stack.getAmount() - 1); + inventory.setItem(index, stack); + } + else + { + inventory.setItem(index, new ItemStack(Material.AIR)); + } + + index++; + } + + ev.setCurrentItem(new ItemStack(Material.COMPASS)); + ev.setResult(Event.Result.ALLOW); + + ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed + } + } + }, 1L); + } + } + } + + @EventHandler (ignoreCancelled = true) + public void onInventoryDrag(final InventoryDragEvent ev) + { + if (Config.RECIPE.get() == CompassRecipe.DEFAULT) return; + + if (ev.getInventory() instanceof CraftingInventory) + { + RunTask.later(() -> + { + if (isValidCompassRecipe(((CraftingInventory) ev.getInventory()).getMatrix())) + { + ((CraftingInventory) ev.getInventory()).setResult(new ItemStack(Material.COMPASS)); + ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed + } + }, 1L); + } + } + + public enum CompassRecipe + { + /** + * The default recipe with redstone and iron. + */ + DEFAULT, + + /** + * The same recipe as the default, but with the four main mobs loots + * in the corners: one string, one spider eye, one gun powder and + * one zombie flesh. + */ + EASY, + + /** + * The same recipe as the easy one, but with an ender pearl instead + * of the redstone at the center. + */ + MEDIUM, + + /** + * The same recipe as the medium one, but wyth an eye of ender instead + * of the ender pearl. + */ + HARD + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java new file mode 100644 index 0000000..3d1c605 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java @@ -0,0 +1,59 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import org.bukkit.Material; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public final static ConfigurationItem<CompassRecipes.CompassRecipe> RECIPE = item("recipe", CompassRecipes.CompassRecipe.EASY); + + public final static ConfigurationItem<Material> COMPASS_FEE_ITEM = item("compass-fee-item", Material.ROTTEN_FLESH); + public final static ConfigurationItem<Integer> COMPASS_FEE_AMOUNT = item("compass-fee-amount", 1); + + public final static ConfigurationItem<Boolean> NEVER_TARGET_TEAMMATES = item("never-target-teammates", true); + + public final static ConfigurationItem<CompassModule.CompassBehavior> COMPASS_BEHAVIOR = item("compass-behavior", CompassModule.CompassBehavior.GIVE_BOTH); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index b0f567e..4b01fb6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -108,6 +108,7 @@ public class ReportsModule extends UHModule /* * Switches for some timeline's events. */ + private boolean firstApple = false; private boolean firstGold = false; private boolean firstDiamond = false; private boolean firstEnchant = false; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java index e7fe13c..95e0a52 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java @@ -40,12 +40,10 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.*; import org.bukkit.inventory.meta.ItemMeta; @@ -167,75 +165,10 @@ public void onInventoryClick(final InventoryClickEvent ev) { final Inventory inventory = ev.getInventory(); - // Workaround to fix the crafting grid being not updated when the item is taken - // from the grid. - if (inventory instanceof CraftingInventory && ev.getSlotType() == SlotType.RESULT) - { - RunTask.later( - () -> ev.getViewers().stream() - .filter(viewer -> viewer instanceof Player) - .forEach(viewer -> ((Player) viewer).updateInventory()), - 1L - ); - } - - - /* *** Allows any shape for the loots in the compass recipe. *** */ - - if (inventory instanceof CraftingInventory) - { - // This is ran one tick after the click because when the event is fired, the inventory - // object is not updated, and so the result of the isValidCompassResult is invalid. - - RunTask.later(() -> - { - if (p.getRecipesManager().isValidCompassRecipe(((CraftingInventory) inventory).getMatrix())) - { - - // Puts the compass in the result slot - if (ev.getSlotType() == SlotType.CRAFTING) - { - ((CraftingInventory) inventory).setResult(new ItemStack(Material.COMPASS)); - ev.setResult(Result.ALLOW); - - ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed - } - - // Consumes the materials in the crafting grid. - // Because this is not an "official" recipe, we need to do that manually. - else if (ev.getSlotType() == SlotType.RESULT) - { - int index = 1; - for (ItemStack stack : ((CraftingInventory) inventory).getMatrix()) - { - if (stack == null) continue; - - if (stack.getAmount() != 1) - { - stack.setAmount(stack.getAmount() - 1); - inventory.setItem(index, stack); - } - else - { - inventory.setItem(index, new ItemStack(Material.AIR)); - } - - index++; - } - - ev.setCurrentItem(new ItemStack(Material.COMPASS)); - ev.setResult(Result.ALLOW); - - ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed - } - } - }, 1L); - } - /* *** Prevent an apple to be renamed to/from the name of an head apple. *** */ - else if (inventory instanceof AnvilInventory) + if (inventory instanceof AnvilInventory) { InventoryView view = ev.getView(); int rawSlot = ev.getRawSlot(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index 28fac67..da1b21d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -40,24 +40,19 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Ghast; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.inventory.BrewerInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -269,101 +264,4 @@ else if ((dataValue == 0 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) } } } - - - /** - * Used to update the compass. - */ - @SuppressWarnings ("deprecation") - @EventHandler - public void onPlayerInteract(PlayerInteractEvent ev) - { - if ((ev.getAction() == Action.RIGHT_CLICK_AIR || ev.getAction() == Action.RIGHT_CLICK_BLOCK) - && ev.getPlayer().getItemInHand().getType() == Material.COMPASS - && p.getConfig().getBoolean("gameplay-changes.compass.enabled") - && !p.getGameManager().isPlayerDead(ev.getPlayer())) - { - Player player1 = ev.getPlayer(); - - boolean foundRottenFlesh = false; - for (ItemStack item : player1.getInventory().getContents()) - { - if (item != null && item.getType() == Material.ROTTEN_FLESH) - { - if (item.getAmount() != 1) - { - item.setAmount(item.getAmount() - 1); - } - else - { - player1.getInventory().removeItem(item); - } - - player1.updateInventory(); - foundRottenFlesh = true; - break; - } - } - - if (!foundRottenFlesh) - { - /// Error message if a player tries to use his pointing compass without rotten flesh. - player1.sendMessage(I.t("{gray}{italic}You do not have rotten flesh.")); - player1.playSound(player1.getLocation(), Sound.STEP_WOOD, 1F, 1F); - return; - } - - Player nearest = null; - Double distance = 99999D; - for (Player player2 : p.getGameManager().getOnlineAlivePlayers()) - { - try - { - Double calc = player1.getLocation().distanceSquared(player2.getLocation()); - - if (calc > 1 && calc < distance) - { -// distance = calc; -// if (!player2.getUniqueId().equals(player1.getUniqueId()) && !p.getTeamManager().inSameTeam(player1, player2)) -// { -// nearest = player2.getPlayer(); -// } - } - } - catch (Exception ignored) - { - - } - } - - if (nearest == null) - { - /// Error message if a player tries to use his pointing compass without a player nearby. - player1.sendMessage(I.t("{gray}{italic}Only silence answers your request.")); - - player1.playSound(player1.getLocation(), Sound.STEP_WOOD, 1F, 1F); - return; - } - - /// Success message when a player uses his pointing compass. - player1.sendMessage(I.t("{gray}The compass now points to the closest player.")); - player1.setCompassTarget(nearest.getLocation()); - - player1.playSound(player1.getLocation(), Sound.ENDERMAN_TELEPORT, 1F, 1F); - } - } - - - /** - * Used to disable the "bad" weather (aka non-clear weather). - * The weather is initially clear. - */ - @EventHandler - public void onWeatherChange(WeatherChangeEvent ev) - { - if (!UHConfig.GAMEPLAY_CHANGES.WEATHER.get()) - { - ev.setCancelled(true); - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index 591bc0c..4056284 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -78,13 +78,13 @@ public static <M extends UHModule> M module(final Class<M> moduleClass) } /** - * Returns the logger for the caller class' module. + * Returns the module for the caller class' module. * * This works by looking up for the module class in the caller class' * package or “parent” packages. Throws an exception if no module class can * be found. * - * @return The module's logger. + * @return The module's instance. * @throws IllegalArgumentException if no module can be found for the caller * class. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java index 87f0558..7faf635 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java @@ -35,13 +35,8 @@ import fr.zcraft.zlib.tools.Callback; import fr.zcraft.zlib.tools.PluginLogger; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; +import org.bukkit.*; import org.bukkit.FireworkEffect.Builder; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; @@ -454,4 +449,17 @@ public static <T extends Enum> T getNextElement(final T enumValue, final int shi if (shiftThroughNull && newOrd == values.length) return null; return values[newOrd]; } + + /** + * Generates a message prefixed with a prefix and a separator, for chat. + * + * @param prefix The prefix. + * @param message The message. + * + * @return The formatted prefixed message. + */ + public static String prefixedMessage(final String prefix, final String message) + { + return ChatColor.GREEN + prefix + ChatColor.GRAY + " \u2758 " + ChatColor.RESET + message; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5074e6a..6d09e67 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,8 @@ modules: "ingame-deathAnnouncement": true "ingame-kick": false + "gameplay-compass": true + "cosmetics-hardcoreHearts": true "cosmetics-motd": true "cosmetics-dynmap": true From 4af24b5a172e66a7016c7c080c771b2ac2229bef Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 10:53:54 +0100 Subject: [PATCH 44/91] Added golden heads & apples module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added module to handle golden apple regen & to add heads → Misc. fixes --- .../UHCReloaded/core/ModuleWrapper.java | 2 +- .../amaury/UHCReloaded/core/UHModule.java | 7 +- .../gameplay/compass/CompassModule.java | 1 - .../modules/gameplay/goldenHeads/Config.java | 87 +++++ .../goldenHeads/GoldenHeadsModule.java | 361 ++++++++++++++++++ .../daylightCycle/DaylightCycleModule.java | 2 +- .../ingame/killsCount/KillsCountModule.java | 2 +- .../modules/ingame/weather/WeatherModule.java | 4 +- .../modules/other/reports/ReportsModule.java | 37 ++ .../old/listeners/CraftingListener.java | 164 +------- .../old/listeners/GameplayListener.java | 95 ----- .../old/recipes/RecipesManager.java | 11 +- .../RecipesUtils.java} | 12 +- src/main/resources/config.yml | 1 + 14 files changed, 503 insertions(+), 283 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/recipes/RecipeUtil.java => utils/RecipesUtils.java} (96%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 3ac05e2..82649ff 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -168,7 +168,7 @@ else if (!plugin.isEnabled()) Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this, late)); - if (late) instance.onEnableLate(); + if (late) instance.onLateEnable(); return true; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java index 724bd9e..554c2e5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java @@ -51,11 +51,6 @@ public UHModule() logger = new ModuleLogger(getClass()); } - /** - * Called when the configuration is loaded. - */ - public void onConfigLoaded() {} - /** * Called only when the module is enabled late, i.e. not when configured in * the {@link ModuleInfo}. This happens for modules loaded manually by the @@ -65,7 +60,7 @@ public void onConfigLoaded() {} * * It will be called after {@link #onEnable()}. */ - public void onEnableLate() {} + public void onLateEnable() {} /** * Use this method to register sub-commands into the /uh command. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java index e6861e4..5c097a4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java @@ -44,7 +44,6 @@ import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.RawMessage; import fr.zcraft.zteams.ZTeams; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java new file mode 100644 index 0000000..3c4366e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java @@ -0,0 +1,87 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH = item("drop-head-on-death", true); + public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH_PVP_ONLY = item("drop-head-on-death-pvp-only", false); + + public static final GoldenAppleSection GOLDEN_APPLE = section("golden-apple", GoldenAppleSection.class); + public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = section("golden-apple", EnchantedGoldenAppleSection.class); + + public static final GoldenHeadSection PLAYER_GOLDEN_HEAD = section("player-golden-head", GoldenHeadSection.class); + public static final GoldenHeadSection WITHER_GOLDEN_HEAD = section("wither-golden-head", GoldenHeadSection.class); + + public static final EnchantedGoldenHeadSection PLAYER_ENCHANTED_GOLDEN_HEAD = section("player-enchanted-golden-head", EnchantedGoldenHeadSection.class); + public static final EnchantedGoldenHeadSection WITHER_ENCHANTED_GOLDEN_HEAD = section("wither-enchanted-golden-head", EnchantedGoldenHeadSection.class); + + public static class GoldenAppleSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLE = item("enable", true); + public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 4); + } + + public static class EnchantedGoldenAppleSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLE = item("enable", false); + public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 180); + } + + public static class GoldenHeadSection extends GoldenAppleSection + { + public final ConfigurationItem<Integer> AMOUNT_CRAFTED = item("amount-crafted", 1); + public final ConfigurationItem<Boolean> ADD_LORE = item("add-lore", true); + } + + public static class EnchantedGoldenHeadSection extends EnchantedGoldenAppleSection + { + public final ConfigurationItem<Integer> AMOUNT_CRAFTED = item("amount-crafted", 1); + public final ConfigurationItem<Boolean> ADD_LORE = item("add-lore", true); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java new file mode 100644 index 0000000..5debf17 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -0,0 +1,361 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import fr.zcraft.zlib.components.attributes.Attribute; +import fr.zcraft.zlib.components.attributes.Attributes; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.items.ItemUtils; +import fr.zcraft.zlib.tools.reflection.NMSException; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.SkullType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.UUID; + + +@ModuleInfo ( + name = "Golden Apple & Heads", + description = "Changes golden apple behavior. This can change the regeneration from these apple, " + + "and allow players to craft “golden heads” from fallen heads when they kill a player. You can " + + "also enable or disable enchanted golden apples (aka “Notch Apples”).", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.GOLDEN_APPLE, // TODO 1.13: enchanted golden apple or player head + settings = Config.class +) +public class GoldenHeadsModule extends UHModule +{ + private final static UUID HEADS_UUID = UUID.fromString("1a050e3b-6274-434e-b8c0-a720048142e7"); + + private final static int TICKS_BETWEEN_EACH_REGENERATION = 50; + private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN = 4; + private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH = 180; + private final static int REGENERATION_LEVEL_GOLDEN_APPLE = 2; + private final static int REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE = 5; + + @Override + protected void onEnable() + { + if (Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get()) + Bukkit.addRecipe(getOldEnchantedGoldenAppleRecipe()); + + if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get()) + Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); // FIXME Translation + + if (Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) + Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); // FIXME Translation + + if (Config.WITHER_GOLDEN_HEAD.ENABLE.get()) + Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); // FIXME Translation + + if (Config.WITHER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) + Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); // FIXME Translation + } + + private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted, final int amount, final String resultDisplayName) + { + short damage = (short) (enchanted ? 1 : 0); + + final ItemStack goldenApple = new ItemStackBuilder(Material.GOLDEN_APPLE) + .title(ChatColor.RESET + resultDisplayName) + .amount(amount) + .data(damage) + .craftItem(); // Required to write attributes by reference + + writeHeadType(goldenApple, player ? SkullType.PLAYER : SkullType.WITHER); + + final ShapedRecipe goldenAppleFromHeadRecipe = new ShapedRecipe(goldenApple); + + goldenAppleFromHeadRecipe.shape("GGG", "GHG", "GGG"); + goldenAppleFromHeadRecipe.setIngredient('G', enchanted ? Material.GOLD_BLOCK : Material.GOLD_INGOT); + + // TODO: deprecated, but no alternative found... + // FIXME 1.13 + goldenAppleFromHeadRecipe.setIngredient('H', Material.SKULL_ITEM, player ? SkullType.PLAYER.ordinal() : SkullType.WITHER.ordinal()); + + return goldenAppleFromHeadRecipe; + } + + private Recipe getOldEnchantedGoldenAppleRecipe() + { + final ShapedRecipe enchantedGoldenAppleRecipe = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); // FIXME 1.13 + enchantedGoldenAppleRecipe.shape("GGG", "GAG", "GGG"); + enchantedGoldenAppleRecipe.setIngredient('G', Material.GOLD_BLOCK); + enchantedGoldenAppleRecipe.setIngredient('A', Material.APPLE); + + return enchantedGoldenAppleRecipe; + } + + private void writeHeadType(final ItemStack stack, final SkullType type) + { + final Attribute attribute = new Attribute(); + attribute.setUUID(HEADS_UUID); + attribute.setCustomData(type.name()); + + try + { + Attributes.set(stack, attribute); + } + catch (NMSException e) + { + PluginLogger.error("Unable to write head type into item stack.", e); + } + } + + private SkullType readHeadType(final ItemStack stack) + { + try + { + final Attribute attribute = Attributes.get(stack, HEADS_UUID); + + if (attribute != null) + { + return SkullType.valueOf(attribute.getCustomData()); + } + else return null; + } + catch (NMSException | IllegalArgumentException e) + { + return null; + } + } + + @EventHandler + public void onPreCraft(final PrepareItemCraftEvent ev) + { + /* *** We remove these recipes if disabled *** */ + + final ItemStack result = ev.getInventory().getResult(); + if (result == null || (result.getType() != Material.GOLDEN_APPLE /* && result.getType() != Material.ENCHANTED_GOLDEN_APPLE FIXME 1.13 */)) return; + + if ((!Config.GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && result.getData().getData() == 0) + || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && result.getData().getData() == 1)) + { + result.setType(Material.AIR); + } + + + /* *** We add a lore to the golden apples *** */ + + final SkullType headType = readHeadType(result); + if (headType != null) + { + final ItemStackBuilder revampedResult = new ItemStackBuilder(result); + + if (headType == SkullType.WITHER && + ((result.getData().getData() == 0 && Config.WITHER_GOLDEN_HEAD.ADD_LORE.get()) || (result.getData().getData() == 1 && Config.WITHER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) + { + revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of a malignant monster")); + } + + else if (headType == SkullType.PLAYER && + ((result.getData().getData() == 0 && Config.PLAYER_GOLDEN_HEAD.ADD_LORE.get()) || (result.getData().getData() == 1 && Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) + { + // We retrieve the player name to write it into the lore + String name = null; + + for (final ItemStack item : ev.getInventory().getContents()) + { + // An human head + if (item.getType() == Material.SKULL_ITEM && item.getDurability() == (short) SkullType.PLAYER.ordinal()) + { + SkullMeta sm = (SkullMeta) item.getItemMeta(); + if (sm.hasOwner()) // An human head + { + name = sm.getOwner(); + } + break; + } + } + + if (name != null) + { + revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of {0}", name)); + } + else + { + revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of a powerful opponent")); + } + } + + revampedResult.hideAttributes().item(); + } + } + + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (Config.DROP_HEAD_ON_DEATH.get() && ev.getPlayer().isOnline() && (!Config.DROP_HEAD_ON_DEATH_PVP_ONLY.get() || ev.getPlayer().getPlayer().getKiller() != null)) + { + final ItemStackBuilder headBuilder = new ItemStackBuilder(Material.SKULL_ITEM) + .data((short) 3) + .title(ChatColor.AQUA, I.t("{0}'s head", ev.getPlayer().getName())); + + if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get() || Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) + { + headBuilder.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Old legends tell how the heads of the brave fallen warriors can become, through a rich and complex transformation, a precious healing balm..."), 38); + } + + final ItemStack head = headBuilder.item(); + final SkullMeta meta = (SkullMeta) head.getItemMeta(); + + meta.setOwner(ev.getPlayer().getName()); + head.setItemMeta(meta); + + ItemUtils.dropNaturally(ev.getPlayer().getPlayer().getLocation(), head); + } + } + + + /** + * Used to change the amount of regenerated hearts from a golden apple. + */ + @EventHandler + public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) + { + if (ev.getItem().getType() == Material.GOLDEN_APPLE) // FIXME 1.13 + { + final SkullType headType = readHeadType(ev.getItem()); + final short dataValue = ev.getItem().getDurability(); + + final int halfHearts; + final int level; + + // Standard golden apple + if (headType == null) + { + if (dataValue == 0) // FIXME 1.13 + { + halfHearts = Config.GOLDEN_APPLE.REGENERATION.get(); + level = REGENERATION_LEVEL_GOLDEN_APPLE; + } + else + { + halfHearts = Config.ENCHANTED_GOLDEN_APPLE.REGENERATION.get(); + level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; + } + } + + else if (headType == SkullType.PLAYER) + { + if (dataValue == 0) // FIXME 1.13 + { + halfHearts = Config.PLAYER_GOLDEN_HEAD.REGENERATION.get(); + level = REGENERATION_LEVEL_GOLDEN_APPLE; + } + else + { + halfHearts = Config.PLAYER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); + level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; + } + } + + else if (headType == SkullType.WITHER) + { + if (dataValue == 0) // FIXME 1.13 + { + halfHearts = Config.WITHER_GOLDEN_HEAD.REGENERATION.get(); + level = REGENERATION_LEVEL_GOLDEN_APPLE; + } + else + { + halfHearts = Config.WITHER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); + level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; + } + } + + // Invalid attribute. Should never happen. + else return; + + + // Technically, a level-I effect is « level 0 ». + final int realLevel = level - 1; + + + // What is needed to do? + if ((dataValue == 0 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN) + || (dataValue == 1 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) + { + // Default behavior, nothing to do. + return; + } + + if ((dataValue == 0 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) + || (dataValue == 1 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) + { + // If the heal needs to be increased, the effect can be applied immediately. + + int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * halfHearts; + + new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); + } + else + { + // The heal needs to be decreased. + // We can't apply the effect immediately, because the server will just ignore it. + // So, we apply it two ticks later, with one half-heart less (because in two ticks, + // one half-heart is given to the player). + final int healthApplied = halfHearts - 1; + + RunTask.later(() -> + { + // The original, vanilla, effect is removed + ev.getPlayer().removePotionEffect(PotionEffectType.REGENERATION); + + int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * healthApplied; + new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); + }, 2L); + } + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java index 805b906..f213ef1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java @@ -76,7 +76,7 @@ protected void onEnable() } @Override - public void onEnableLate() + public void onLateEnable() { if (UR.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java index cbc3d1f..a87c39c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java @@ -78,7 +78,7 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) { if (ev.getPlayer().isOnline() && ev.getPlayer().getPlayer().getKiller() != null) { - getKillsFor(ev.getPlayer().getUniqueId()).add(ev.getPlayer().getPlayer().getKiller().getUniqueId()); + getKillsFor(ev.getPlayer().getPlayer().getKiller().getUniqueId()).add(ev.getPlayer().getUniqueId()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java index 5fe4254..836f512 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java @@ -68,7 +68,7 @@ protected void onEnable() } @Override - public void onEnableLate() + public void onLateEnable() { UR.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); } @@ -78,7 +78,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { - onEnableLate(); + onLateEnable(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index 4b01fb6..87c4e4c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -70,6 +70,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.BrewEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -130,6 +131,7 @@ public class ReportsModule extends UHModule */ private BukkitTask waitAfterEndTask = null; private TimeDelta waitAfterEndDelay = new TimeDelta(30); + private boolean waitingfterEnd = false; @Override @@ -245,8 +247,12 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) final ZTeam winner = game.getWinner(); if (winner != null) report.setWinners(winner.getPlayers()); + waitingfterEnd = true; + waitAfterEndTask = RunTask.later(() -> { + waitingfterEnd = false; + report.autoTrack(false); report.save( @@ -335,6 +341,8 @@ else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) report.resetWinners(); report.autoTrack(true); + waitingfterEnd = false; + if (waitAfterEndTask != null) { waitAfterEndTask.cancel(); @@ -361,6 +369,25 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) )); } + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final PlayerDeathEvent ev) + { + // Recording cross-kills and other deaths after the game end (i.e. from fire) + // during a 30-seconds period. + + if (!waitingfterEnd) return; + + report + .untrackPlayer(ev.getEntity()) + .record(ReportEvent.withPlayer( + ReportEvent.EventType.GOLD, + /// Title of the death event on the game report's timeline. + I.t("Death of {0}", ev.getEntity().getName()), + !ev.getDeathMessage().isEmpty() ? ev.getDeathMessage() : null, + ev.getEntity() + )); + } + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerResurrected(final PlayerResurrectedEvent ev) { @@ -451,6 +478,16 @@ else if (!firstGold && (item == Material.GOLD_INGOT || item == Material.GOLD_ORE firstGold = true; } + + else if (!firstApple && item == Material.APPLE) + { + report.record(ReportEvent.withIcon( + I.t("{0} harvested the first apple", player.getName()), + "" + )); + + firstApple = true; + } } /* diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java index 95e0a52..4878ff1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java @@ -35,21 +35,14 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.inventory.*; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.HashSet; -import java.util.Set; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; public class CraftingListener implements Listener @@ -142,157 +135,4 @@ public void onPreCraftEvent(PrepareItemCraftEvent ev) return; } } - - - /** - * - Workaround to fix the crafting grid being not updated when the item is taken - * from the grid. - * <p> - * - Prevents an apple to be renamed to/from the name of an head apple. - * - * (In vanilla clients, it is not possible to rename an apple to that name because of the - * ChatColor.RESET before, but some modded clients allows the player to write §r.) - * - * (Thanks to Zelnehlun on BukkitDev.) - * <p> - * - Crafts the special compass (“semi-shapeless” recipe). - */ - @EventHandler (ignoreCancelled = true) - public void onInventoryClick(final InventoryClickEvent ev) - { - // Just in case - if (ev.getWhoClicked() instanceof Player) - { - final Inventory inventory = ev.getInventory(); - - - /* *** Prevent an apple to be renamed to/from the name of an head apple. *** */ - - if (inventory instanceof AnvilInventory) - { - InventoryView view = ev.getView(); - int rawSlot = ev.getRawSlot(); - - // ensure we are talking about the upper inventory - if (rawSlot == view.convertSlot(rawSlot)) - { - // "result" slot - if (rawSlot == 2) - { - ItemStack item = ev.getCurrentItem(); - - // result slot non empty - if (item != null) - { - final ItemMeta meta = item.getItemMeta(); - - final Set<String> prohibited = new HashSet<>(); - - prohibited.add(I.t("Golden head")); - prohibited.add(ChatColor.RESET + I.t("{aqua}Golden head")); - prohibited.add(ChatColor.RESET + I.t("{lightpurple}Golden head")); - - // It is possible that the client filters the name of the golden apple in the anvil UI, - // removing all §. - new HashSet<>(prohibited).stream() - .map(prohibition -> prohibition.replace("§", "")) - .forEach(prohibited::add); - - - // An item can't be renamed to the name of a golden head - if (meta != null && meta.hasDisplayName()) - { - if (prohibited.contains(meta.getDisplayName())) - { - ev.setCancelled(true); // nope nope nope - } - } - - // A golden head can't be renamed to any other name - if (view.getItem(0) != null) // slot 0 = first slot - { - ItemMeta metaOriginal = view.getItem(0).getItemMeta(); - - if (metaOriginal != null && metaOriginal.hasDisplayName()) - { - if (prohibited.contains(metaOriginal.getDisplayName())) - { - ev.setCancelled(true); - } - } - } - } - } - } - } - } - } - - - /** - * Used to craft the special compass (“semi-shapeless” recipe). - */ - @EventHandler (ignoreCancelled = true) - public void onInventoryDrag(final InventoryDragEvent ev) - { - if (ev.getInventory() instanceof CraftingInventory) - { - RunTask.later(() -> - { - if (p.getRecipesManager().isValidCompassRecipe(((CraftingInventory) ev.getInventory()).getMatrix())) - { - ((CraftingInventory) ev.getInventory()).setResult(new ItemStack(Material.COMPASS)); - ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed - } - }, 1L); - } - } - - - /** - * Adds the team banner on crafted shields. - * - * Done indirectly because the plugin must be able to run - * on Minecraft 1.8. - */ - @EventHandler (ignoreCancelled = true) - public void onShieldPreCraft(PrepareItemCraftEvent ev) - { -// if (!UHConfig.TEAMS_OPTIONS.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; -// -// final Player player = (Player) ev.getViewers().get(0); -// final UHTeam team = UHCReloaded.get().getTeamManager().getTeamForPlayer(player); -// -// if (team == null || team.getBanner() == null) return; -// -// final ItemStack result = ev.getRecipe().getResult(); -// -// final Material MATERIAL_SHIELD = Material.getMaterial("SHIELD"); -// if (MATERIAL_SHIELD == null) return; // MC 1.8 -// -// if (result != null && result.getType() == MATERIAL_SHIELD) -// { -// try -// { -// final BannerMeta banner = (BannerMeta) team.getBanner().getItemMeta(); -// -// final BlockStateMeta bsMeta = (BlockStateMeta) result.getItemMeta(); -// final Banner shieldBanner = (Banner) bsMeta.getBlockState(); -// -// shieldBanner.setBaseColor(banner.getBaseColor()); -// shieldBanner.setPatterns(banner.getPatterns()); -// -// shieldBanner.update(); -// -// bsMeta.setBlockState(shieldBanner); -// result.setItemMeta(bsMeta); -// -// ev.getInventory().setResult(result); -// } -// catch (ClassCastException | NullPointerException ignored) -// { -// // Bad Minecraft version (1.8) -// } -// } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index da1b21d..b6cdc61 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -35,9 +35,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.old.task.CancelBrewTask; -import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -49,15 +47,11 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.BrewerInventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; import java.util.List; @@ -175,93 +169,4 @@ public void onCreatureSpawn(CreatureSpawnEvent ev) } } } - - - /** - * Used to change the amount of regenerated hearts from a golden apple. - */ - @EventHandler - public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) - { - final int TICKS_BETWEEN_EACH_REGENERATION = 50; - final int DEFAULT_NUMBER_OF_HEARTS_REGEN = 4; - final int DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH = 180; - final int REGENERATION_LEVEL_GOLDEN_APPLE = 2; - final int REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE = 5; - - if (ev.getItem().getType() == Material.GOLDEN_APPLE) - { - ItemMeta meta = ev.getItem().getItemMeta(); - short dataValue = ev.getItem().getDurability(); - int halfHearts; - int level; - - if (meta.hasDisplayName() - && (meta.getDisplayName().equals(ChatColor.RESET + I.t("{aqua}Golden head")) - || meta.getDisplayName().equals(ChatColor.RESET + I.t("{lightpurple}Golden head")))) - { - // Normal golden apple from a head - if (dataValue == 0) - { - halfHearts = UHConfig.GAMEPLAY_CHANGES.GOLDEN_APPLE.REGENERATION.FROM_NORMAL_HEAD.get(); - level = REGENERATION_LEVEL_GOLDEN_APPLE; - } - // Notch golden apple from a head - else - { - halfHearts = UHConfig.GAMEPLAY_CHANGES.GOLDEN_APPLE.REGENERATION.FROM_NOTCH_HEAD.get(); - level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; - } - } - // Normal golden apple from an apple - else if (dataValue == 0) - { - halfHearts = UHConfig.GAMEPLAY_CHANGES.GOLDEN_APPLE.REGENERATION.NORMAL.get(); - level = REGENERATION_LEVEL_GOLDEN_APPLE; - } - // Notch golden apple from an apple - else - { - halfHearts = UHConfig.GAMEPLAY_CHANGES.GOLDEN_APPLE.REGENERATION.NOTCH.get(); - level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; - } - - // Technically, a level-I effect is « level 0 ». - final int realLevel = level - 1; - - - // What is needed to do? - if ((dataValue == 0 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (dataValue == 1 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) - { - // Default behavior, nothing to do. - } - else if ((dataValue == 0 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (dataValue == 1 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) - { - // If the heal needs to be increased, the effect can be applied immediately. - - int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * halfHearts; - - new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); - } - else - { - // The heal needs to be decreased. - // We can't apply the effect immediately, because the server will just ignore it. - // So, we apply it two ticks later, with one half-heart less (because in two ticks, - // one half-heart is given to the player). - final int healthApplied = halfHearts - 1; - - RunTask.later(() -> - { - // The original, vanilla, effect is removed - ev.getPlayer().removePotionEffect(PotionEffectType.REGENERATION); - - int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * healthApplied; - new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); - }, 2L); - } - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java index 69b5a53..0abc414 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java @@ -34,6 +34,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.ChatColor; @@ -132,14 +133,14 @@ public void registerRecipes() public boolean isRecipeAllowed(Recipe recipe) { // Vanilla compass recipe is disabled if the special compass is used. - if (UHConfig.GAMEPLAY_CHANGES.COMPASS.ENABLED.get() && RecipeUtil.areSimilar(recipe, getVanillaCompassRecipe())) + if (UHConfig.GAMEPLAY_CHANGES.COMPASS.ENABLED.get() && RecipesUtils.areSimilar(recipe, getVanillaCompassRecipe())) { this.lastFailedRecipe = RECIPE_COMPASS; return false; } // Vanilla golden melon recipe is disabled if the craft with a gold block is enabled. - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_MELON_WITH_GOLD_BLOCK.get() && RecipeUtil.areSimilar(recipe, getVanillaGoldenMelonRecipe())) + if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_MELON_WITH_GOLD_BLOCK.get() && RecipesUtils.areSimilar(recipe, getVanillaGoldenMelonRecipe())) { this.lastFailedRecipe = RECIPE_GLISTERING_MELON; return false; @@ -151,7 +152,7 @@ public boolean isRecipeAllowed(Recipe recipe) { if (recipe.getResult().getType() == Material.GOLDEN_APPLE) { - for (ItemStack item : RecipeUtil.getListOfIngredients(recipe)) + for (ItemStack item : RecipesUtils.getListOfIngredients(recipe)) { if (item.getType() == Material.GOLD_BLOCK) { @@ -247,7 +248,7 @@ public ItemStack addLore(Recipe recipe, CraftingInventory inventory) { if ((UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.DO.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.DO.get()) && (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - && (RecipeUtil.areSimilar(recipe, getGoldenHeadHumanRecipe()) || RecipeUtil.areSimilar(recipe, getGoldenHeadMonsterRecipe()))) + && (RecipesUtils.areSimilar(recipe, getGoldenHeadHumanRecipe()) || RecipesUtils.areSimilar(recipe, getGoldenHeadMonsterRecipe()))) { ItemStack result = recipe.getResult(); ItemMeta meta = result.getItemMeta(); @@ -304,7 +305,7 @@ public ItemStack addLore(Recipe recipe, CraftingInventory inventory) public ItemStack keepNameOnLoreRemover(Recipe recipe, CraftingInventory inventory) { if ((UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - && (RecipeUtil.areSimilar(recipe, getLoreRemoverNormalRecipe()) || RecipeUtil.areSimilar(recipe, getLoreRemoverNotchRecipe()))) + && (RecipesUtils.areSimilar(recipe, getLoreRemoverNormalRecipe()) || RecipesUtils.areSimilar(recipe, getLoreRemoverNotchRecipe()))) { ItemStack original = null; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java index 70062e7..bbb8e80 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipeUtil.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.recipes; +package eu.carrade.amaury.UHCReloaded.utils; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; @@ -50,14 +50,8 @@ * @version R1.3 * @author Digi */ -public class RecipeUtil +public class RecipesUtils { - /** - * The wildcard data value for ingredients.<br> - * If this is used as data value on an ingredient it will accept any data value. - */ - public static final short DATA_WILDCARD = Short.MAX_VALUE; - /** * Checks if both recipes are equal.<br> * Compares both ingredients and results.<br> @@ -226,4 +220,4 @@ public static List<ItemStack> getListOfIngredients(Recipe recipe) return listOfItems; } -} \ No newline at end of file +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6d09e67..c1fbffd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -41,6 +41,7 @@ modules: "ingame-kick": false "gameplay-compass": true + "gameplay-goldenHeads": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true From fb08e6690834263b95a7fc5992c37663d3f6e927 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 11:28:48 +0100 Subject: [PATCH 45/91] No Ghast Tears module --- .../modules/gameplay/NoGhastTearsModule.java | 98 +++++++++++++ .../old/listeners/CraftingListener.java | 138 ------------------ .../UHCReloaded/utils/ModulesUtils.java | 14 ++ src/main/resources/config.yml | 1 + 4 files changed, 113 insertions(+), 138 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java new file mode 100644 index 0000000..987e5a8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java @@ -0,0 +1,98 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import org.bukkit.Material; +import org.bukkit.entity.Ghast; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +@ModuleInfo ( + name = "No Ghast Tears", + description = "Replaces ghast tears with gold, to disable regeneration " + + "potions while keeping a reward for the action.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.GHAST_TEAR +) +public class NoGhastTearsModule extends UHModule +{ + /** + * Used to replace ghast tears with gold (if needed). + */ + @EventHandler(ignoreCancelled = true) + public void onEntityDeath(EntityDeathEvent ev) + { + if (ev.getEntity() instanceof Ghast) + { + final List<ItemStack> drops = new ArrayList<>(ev.getDrops()); + ev.getDrops().clear(); + + for (final ItemStack i : drops) + { + if (i.getType() == Material.GHAST_TEAR) + { + ev.getDrops().add(new ItemStack(Material.GOLD_INGOT, i.getAmount())); + } + else + { + ev.getDrops().add(i); + } + } + } + } + + /** + * Used to prevent the user to get a ghast tear. + */ + @EventHandler (ignoreCancelled = true) + public void onPlayerPickupItem(PlayerPickupItemEvent ev) + { + if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR && UR.module(GameModule.class).isAlive(ev.getPlayer())) + { + ev.setCancelled(true); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java deleted file mode 100644 index 4878ff1..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.listeners; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; - - -public class CraftingListener implements Listener -{ - private UHCReloaded p = null; - - public CraftingListener(UHCReloaded p) - { - this.p = p; - } - - - /** - * Used to: - * - prevent items to be crafted; - * - send a ProTip containing the craft to use, if an error occurred; - * - add a lure to the golden apples crafted from a head; - * - keep the name of the item when the anti-lore craft is used. - */ - @EventHandler - public void onPreCraftEvent(PrepareItemCraftEvent ev) - { - Recipe recipe = ev.getRecipe(); - - if (recipe == null) - { - return; - } - - /* *** Prevents items to be crafted *** */ - - if (!p.getRecipesManager().isRecipeAllowed(recipe)) - { - ev.getInventory().setResult(new ItemStack(Material.AIR)); - - // ProTips - final String failedRecipe = p.getRecipesManager().getLastFailedRecipe(); - final Player player = (Player) ev.getViewers().get(0); // crafting inventory: only one viewer in all cases. - - RunTask.later(() -> - { - switch (failedRecipe) - { - case RecipesManager.RECIPE_COMPASS: - switch (p.getRecipesManager().getCompassRecipeType()) - { - case RecipesManager.COMPASS_EASY: - ProTips.CRAFT_COMPASS_EASY.sendTo(player); - break; - case RecipesManager.COMPASS_MEDIUM: - ProTips.CRAFT_COMPASS_MEDIUM.sendTo(player); - break; - case RecipesManager.COMPASS_HARD: - ProTips.CRAFT_COMPASS_HARD.sendTo(player); - break; - } - - break; - - case RecipesManager.RECIPE_GLISTERING_MELON: - ProTips.CRAFT_GLISTERING_MELON.sendTo(player); - break; - - case RecipesManager.RECIPE_ENCHANTED_GOLDEN_APPLE: - ProTips.CRAFT_NO_ENCHANTED_GOLDEN_APPLE.sendTo(player); - break; - } - }, 40L); - - return; - } - - - /* *** Adds a lore to the golden apples crafted from a head *** */ - - ItemStack loreResult = p.getRecipesManager().addLore(recipe, ev.getInventory()); - if (loreResult != null) - { - ev.getInventory().setResult(loreResult); - return; - } - - - /* *** The lore remover don't change the name of the item *** */ - - ItemStack keepNameResult = p.getRecipesManager().keepNameOnLoreRemover(recipe, ev.getInventory()); - if (keepNameResult != null) - { - ev.getInventory().setResult(keepNameResult); - return; - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java index 759d16a..bb1671c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java @@ -31,6 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.utils; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import java.util.Arrays; @@ -53,15 +54,18 @@ public class ModulesUtils public static <T> Class<? extends T> getClassFromName(final String name, final String optionalPackage, final String optionalSuffix, final Class<T> superClass) { final String alternateName; + final String alternativePackage; if (name.contains(".")) { final String[] lastClassPathParts = name.split("\\."); alternateName = lastClassPathParts[lastClassPathParts.length - 1]; + alternativePackage = String.join(".", (String[]) ArrayUtils.remove(lastClassPathParts, lastClassPathParts.length - 1)); } else { alternateName = name; + alternativePackage = ""; } final List<String> possibilities = Arrays.asList( @@ -72,6 +76,7 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S optionalPackage + "." + StringUtils.capitalize(name.toLowerCase()), optionalPackage + "." + StringUtils.capitalize(name.toLowerCase()) + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name), optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name) + optionalSuffix, @@ -80,6 +85,15 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName), optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName) + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + name, + optionalPackage + "." + alternativePackage + "." + name + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(name), + optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(name) + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + alternateName, + optionalPackage + "." + alternativePackage + "." + alternateName + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(alternateName), + optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(alternateName) + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + optionalSuffix, name ); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c1fbffd..2d51819 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -42,6 +42,7 @@ modules: "gameplay-compass": true "gameplay-goldenHeads": true + "gameplay-noGhastTears": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true From 2db8356d920dc997745dd4512ca0198724e3b087 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 11:32:39 +0100 Subject: [PATCH 46/91] No Ender Pearl Damages module --- .../gameplay/NoEnderPearlDamagesModule.java | 69 ++++++++++++++++++ .../old/listeners/GameplayListener.java | 70 ------------------- 2 files changed, 69 insertions(+), 70 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java new file mode 100644 index 0000000..b9d2422 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java @@ -0,0 +1,69 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + + +@ModuleInfo ( + name = "No Ender Pearl Damages", + description = "Removes all damages from ender pearls, basically allowing players to use them.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.ENDER_PEARL +) +public class NoEnderPearlDamagesModule extends UHModule +{ + @EventHandler(ignoreCancelled = true) + public void onPlayerTeleport(final PlayerTeleportEvent ev) + { + if (ev.getCause() == TeleportCause.ENDER_PEARL) + { + ev.setCancelled(true); + + // Technically its an ender pearl teleportation, but + // if we use that, an infinite loop will occur due to + // the event being re-captured and re-emitted. That's + // why PLUGIN is used instead. + ev.getPlayer().teleport(ev.getTo(), TeleportCause.PLUGIN); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index b6cdc61..c4a3e9c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -36,25 +36,14 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.old.task.CancelBrewTask; import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.BrewerInventory; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; public class GameplayListener implements Listener @@ -67,46 +56,6 @@ public GameplayListener() } - /** - * Used to replace ghast tears with gold (if needed). - */ - @EventHandler (ignoreCancelled = true) - public void onEntityDeath(EntityDeathEvent ev) - { - if (ev.getEntity() instanceof Ghast && UHConfig.GAMEPLAY_CHANGES.REPLACE_GHAST_TEARS_WITH_GOLD.get()) - { - final List<ItemStack> drops = new ArrayList<ItemStack>(ev.getDrops()); - ev.getDrops().clear(); - - for (final ItemStack i : drops) - { - if (i.getType() == Material.GHAST_TEAR) - { - ev.getDrops().add(new ItemStack(Material.GOLD_INGOT, i.getAmount())); - } - else - { - ev.getDrops().add(i); - } - } - } - } - - /** - * Used to prevent the user to get a ghast tear, if forbidden by the config. - */ - @EventHandler (ignoreCancelled = true) - public void onPlayerPickupItem(PlayerPickupItemEvent ev) - { - if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR - && ev.getPlayer().getGameMode().equals(GameMode.SURVIVAL) - && UHConfig.GAMEPLAY_CHANGES.REPLACE_GHAST_TEARS_WITH_GOLD.get()) - { - ev.setCancelled(true); - } - } - - /** * Used to disable power-II potions. */ @@ -132,25 +81,6 @@ public void onInventoryClick(InventoryClickEvent ev) } - /** - * Used to disable ender pearl damages (if needed). - */ - @EventHandler (ignoreCancelled = true) - public void onPlayerTeleport(final PlayerTeleportEvent ev) - { - if (UHConfig.GAMEPLAY_CHANGES.DISABLE_ENDERPEARLS_DAMAGES.get()) - { - if (ev.getCause() == TeleportCause.ENDER_PEARL) - { - ev.setCancelled(true); - ev.getPlayer().teleport(ev.getTo(), TeleportCause.PLUGIN); // Technically its an ender pearl teleportation, but - // if we use that, an infinite loop will occur due to - // the event being re-captured and re-emitted. - } - } - } - - /** * Used to disable witch spawn (if needed). */ From 10889a3b529cf5e104593e436a7d0f430503ecb5 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 11:42:43 +0100 Subject: [PATCH 47/91] No Witches module --- .../modules/gameplay/noWitches/Config.java | 52 ++++++++++++++ .../gameplay/noWitches/NoWitchesModule.java | 70 +++++++++++++++++++ .../old/listeners/GameplayListener.java | 23 ------ .../old/listeners/SpawnsListener.java | 20 ------ src/main/resources/config.yml | 2 + 5 files changed, 124 insertions(+), 43 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java new file mode 100644 index 0000000..762c71d --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.noWitches; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Boolean> DISABLE_NATURAL_SPAWN = item("disable-natural-spawn", true); + public static final ConfigurationItem<Boolean> DISABLE_LIGHTNING_SPAWN = item("disable-lightning-spawn", true); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java new file mode 100644 index 0000000..ba517ae --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java @@ -0,0 +1,70 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.noWitches; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; + +@ModuleInfo ( + name = "No Witches", + description = "Prevents witches from spawning, either naturally, from lightning strike on a villager, or both.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.POTION +) +public class NoWitchesModule extends UHModule +{ + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent ev) + { + if (ev.getEntityType().equals(EntityType.WITCH)) + { + if (Config.DISABLE_NATURAL_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.NATURAL)) + { + ev.setCancelled(true); + } + if (Config.DISABLE_LIGHTNING_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.LIGHTNING)) + { + ev.setCancelled(true); + } + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index c4a3e9c..ae64a66 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -36,11 +36,8 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.old.task.CancelBrewTask; import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.inventory.BrewerInventory; @@ -79,24 +76,4 @@ public void onInventoryClick(InventoryClickEvent ev) RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); } } - - - /** - * Used to disable witch spawn (if needed). - */ - @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent ev) - { - if (ev.getEntityType().equals(EntityType.WITCH)) - { - if (UHConfig.GAMEPLAY_CHANGES.WITCH.DISABLE_NATURAL_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.NATURAL)) - { - ev.setCancelled(true); - } - if (UHConfig.GAMEPLAY_CHANGES.WITCH.DISABLE_LIGHTNING_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.LIGHTNING)) - { - ev.setCancelled(true); - } - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java index 2562d95..c642d73 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java @@ -31,9 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.old.listeners; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; import org.bukkit.entity.EntityType; import org.bukkit.entity.Rabbit; import org.bukkit.event.EventHandler; @@ -81,22 +79,4 @@ public void onRabbitSpawn(CreatureSpawnEvent ev) rabbit.setCustomNameVisible(true); } } - - - /** - * Used to cancel the spawn of the creatures if the game is not started. - * <p> - * We don't use the peaceful difficulty for that because it causes bugs with Minecraft 1.8 - * (the difficulty is not correctly updated client-side when the game starts). - */ - @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent ev) - { - if (!UHCReloaded.get().getGameManager().isGameStarted() - && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) - && EntitiesUtils.isHostile(ev.getEntityType())) - { - ev.setCancelled(true); - } - } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2d51819..d2daa59 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -43,6 +43,8 @@ modules: "gameplay-compass": true "gameplay-goldenHeads": true "gameplay-noGhastTears": true + "gameplay-noEnderPearlDamages": true + "gameplay-noWitches": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true From 4c11d4bcdeab0599f0cbdc75274a19ca07cec2b7 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 11:51:53 +0100 Subject: [PATCH 48/91] Killer Rabbit module --- .../modules/beginning/wait/WaitModule.java | 19 +++++ .../modules/gameplay/killerRabbit/Config.java | 52 ++++++++++++ .../killerRabbit/KillerRabbitModule.java | 80 ++++++++++++++++++ .../gameplay/noWitches/NoWitchesModule.java | 4 +- .../old/listeners/SpawnsListener.java | 82 ------------------- 5 files changed, 154 insertions(+), 83 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index 8ed737c..e0ea36b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -40,6 +40,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiUtils; @@ -59,6 +60,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.inventory.InventoryClickEvent; @@ -271,6 +273,23 @@ public void onEntityDamage(final EntityDamageEvent ev) } } + /** + * Used to cancel the spawn of the creatures if the game is not started. + * <p> + * We don't use the peaceful difficulty for that because it causes bugs with Minecraft 1.8 + * (the difficulty is not correctly updated client-side when the game starts). + */ + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent ev) + { + if (!isGameStarted() + && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) + && EntitiesUtils.isHostile(ev.getEntityType())) + { + ev.setCancelled(true); + } + } + /** * Used to prevent the food level from dropping if the game has not started. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java new file mode 100644 index 0000000..4b57386 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.killerRabbit; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Double> SPAWN_PROBABILITY = item("spawn-probability", 0.05); + public static final ConfigurationItem<String> NAME = item("name", "The Killer Rabbit of Cærbannog"); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java new file mode 100644 index 0000000..fb65c45 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java @@ -0,0 +1,80 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.killerRabbit; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Rabbit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.CreatureSpawnEvent; + +import java.util.Random; + + +@ModuleInfo ( + name = "Killer Rabbit", + description = "Brings back the Killer Rabbit of Cærbannog into the game. Beware, it bites.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.RABBIT_FOOT, + settings = Config.class +) +public class KillerRabbitModule extends UHModule +{ + private final Random random = new Random(); + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onRabbitSpawn(final CreatureSpawnEvent ev) + { + if (ev.getEntity().getType() != EntityType.RABBIT) + return; + + if (random.nextDouble() >= Config.SPAWN_PROBABILITY.get()) + return; + + final Rabbit rabbit = (Rabbit) ev.getEntity(); + rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY); + + if (!Config.NAME.get().isEmpty()) + { + rabbit.setCustomName(Config.NAME.get()); + rabbit.setCustomNameVisible(true); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java index ba517ae..925304b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java @@ -48,7 +48,8 @@ description = "Prevents witches from spawning, either naturally, from lightning strike on a villager, or both.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.POTION + icon = Material.POTION, + settings = Config.class ) public class NoWitchesModule extends UHModule { @@ -61,6 +62,7 @@ public void onCreatureSpawn(CreatureSpawnEvent ev) { ev.setCancelled(true); } + if (Config.DISABLE_LIGHTNING_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.LIGHTNING)) { ev.setCancelled(true); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java deleted file mode 100644 index c642d73..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/SpawnsListener.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.listeners; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Rabbit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; - -import java.util.Random; - - -public class SpawnsListener implements Listener -{ - private final Random random = new Random(); - - private final boolean RABBIT_SPAWN_ENABLED; - private final double RABBIT_SPAWN_PROBABILITY; - private final String RABBIT_NAME; - - public SpawnsListener() - { - RABBIT_SPAWN_ENABLED = UHConfig.GAMEPLAY_CHANGES.RABBIT.KILLER_RABBIT_SPAWN.get(); - RABBIT_SPAWN_PROBABILITY = UHConfig.GAMEPLAY_CHANGES.RABBIT.KILLER_RABBIT_SPAWN_PROBABILITY.get(); - - RABBIT_NAME = UHConfig.GAMEPLAY_CHANGES.RABBIT.KILLER_RABBIT_NAME.get().trim(); - } - - @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onRabbitSpawn(CreatureSpawnEvent ev) - { - if (!RABBIT_SPAWN_ENABLED) - return; - - if (ev.getEntity().getType() != EntityType.RABBIT) - return; - - if (random.nextDouble() >= RABBIT_SPAWN_PROBABILITY) - return; - - Rabbit rabbit = (Rabbit) ev.getEntity(); - rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY); - - if (!RABBIT_NAME.isEmpty()) - { - rabbit.setCustomName(RABBIT_NAME); - rabbit.setCustomNameVisible(true); - } - } -} From 4b76d95fd63fe810b5badcf300c98d00ca59e7c4 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 12:46:26 +0100 Subject: [PATCH 49/91] Potions module --- .../gameplay/noWitches/NoWitchesModule.java | 2 +- .../gameplay/potions}/CancelBrewTask.java | 63 ++++++--------- .../modules/gameplay/potions/Config.java | 54 +++++++++++++ .../gameplay/potions/PotionsModule.java | 76 +++++++++++++++++++ .../old/listeners/GameplayListener.java | 2 +- src/main/resources/config.yml | 1 + 6 files changed, 157 insertions(+), 41 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/task => modules/gameplay/potions}/CancelBrewTask.java (56%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java index 925304b..b10ae87 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java @@ -48,7 +48,7 @@ description = "Prevents witches from spawning, either naturally, from lightning strike on a villager, or both.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.POTION, + icon = Material.GLASS_BOTTLE, settings = Config.class ) public class NoWitchesModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java similarity index 56% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java index ab8b289..fd61edb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/CancelBrewTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java @@ -30,8 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.task; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; +import fr.zcraft.zlib.tools.items.ItemUtils; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -39,6 +40,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; +import java.util.HashSet; +import java.util.Set; + public class CancelBrewTask extends BukkitRunnable { @@ -61,48 +65,29 @@ public void run() if (whoClicked instanceof Player) { - ItemStack ingredient = inventory.getIngredient(); - - if (ingredient.getType() != null && ingredient.getType().equals(Material.GLOWSTONE_DUST)) - { - inventory.setIngredient(new ItemStack(Material.AIR)); // The glowstone is removed. - - // First try: try to add the glowstone to an existing stack - boolean added = false; - for (ItemStack item : whoClicked.getInventory().getContents()) - { - if (item != null && item.getType() != null && item.getType().equals(Material.GLOWSTONE_DUST)) - { - if (item.getAmount() + ingredient.getAmount() <= item.getMaxStackSize()) - { - // We can add the glowstone here. - item.setAmount(item.getAmount() + ingredient.getAmount()); - added = true; - break; - } - } - } + final ItemStack ingredient = inventory.getIngredient(); - // Failed... We adds the glowstone to the first empty slot found. - if (!added) - { - int slotEmpty = whoClicked.getInventory().firstEmpty(); + final Set<Material> forbiddenIngredients = new HashSet<>(); - // -1 is returned if there isn't any empty slot - if (slotEmpty != -1) - { - whoClicked.getInventory().setItem(slotEmpty, ingredient); - } + if (Config.DISABLE_EXTENDED.get()) forbiddenIngredients.add(Material.REDSTONE); + if (Config.DISABLE_LEVEL_II.get()) forbiddenIngredients.add(Material.GLOWSTONE_DUST); + if (Config.DISABLE_SPLASH.get()) forbiddenIngredients.add(Material.SULPHUR); + if (Config.DISABLE_LINGERING.get()) + { + // 1.9 - 1.12 + try { forbiddenIngredients.add(Material.valueOf("DRAGONS_BREATH")); } + catch (IllegalArgumentException ignored) { } - // Failed again (!). Maybe an item captured between the click and this execution. - // The stack is dropped at the player's location. - else - { - whoClicked.getWorld().dropItem(whoClicked.getLocation(), ingredient); - } - } + // 1.13+ + try { forbiddenIngredients.add(Material.valueOf("DRAGON_BREATH")); } + catch (IllegalArgumentException ignored) { } + } - ((Player) whoClicked).updateInventory(); + if (ingredient.getType() != null && forbiddenIngredients.contains(ingredient.getType())) + { + // The element is removed and added back to the player's inventory. + inventory.setIngredient(new ItemStack(Material.AIR)); + ItemUtils.give((Player) whoClicked, ingredient); } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java new file mode 100644 index 0000000..85500ff --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java @@ -0,0 +1,54 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + final static public ConfigurationItem<Boolean> DISABLE_LEVEL_II = item("disable-level-II", true); + final static public ConfigurationItem<Boolean> DISABLE_EXTENDED = item("disable-extended", false); + final static public ConfigurationItem<Boolean> DISABLE_SPLASH = item("disable-splash", false); + final static public ConfigurationItem<Boolean> DISABLE_LINGERING = item("disable-lingering", false); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java new file mode 100644 index 0000000..265374f --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java @@ -0,0 +1,76 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.inventory.BrewerInventory; + + +@ModuleInfo ( + name = "Potions", + description = "Allows to tweak potions, by disabling level-II, enhanced, " + + "splash or lingering potions.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.POTION, + settings = Config.class +) +public class PotionsModule extends UHModule +{ + @EventHandler + public void onInventoryDrag(InventoryDragEvent ev) + { + if (ev.getInventory() instanceof BrewerInventory) + { + RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); + } + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent ev) + { + if (ev.getInventory() instanceof BrewerInventory) + { + RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java index ae64a66..187f69e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java @@ -34,7 +34,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.task.CancelBrewTask; +import eu.carrade.amaury.UHCReloaded.modules.gameplay.potions.CancelBrewTask; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d2daa59..767fd1f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -45,6 +45,7 @@ modules: "gameplay-noGhastTears": true "gameplay-noEnderPearlDamages": true "gameplay-noWitches": true + "gameplay-potions": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true From 61f1a50c9d203389ef0dddb21086a71b26d2fb1e Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 12:59:28 +0100 Subject: [PATCH 50/91] XP to killer module Also removed migrated features from the config file --- .../modules/ingame/xpToKillers/Config.java | 52 ++ .../ingame/xpToKillers/XpToKillersModule.java | 76 +++ src/main/resources/config.yml | 474 +----------------- 3 files changed, 129 insertions(+), 473 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java new file mode 100644 index 0000000..9e66544 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.xpToKillers; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationItem<Integer> LEVELS = item("levels", 2); + public static final ConfigurationItem<Boolean> ONLY_OTHER_TEAM = item("only-other-team", true); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java new file mode 100644 index 0000000..5bec3aa --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java @@ -0,0 +1,76 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame.xpToKillers; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.Objects; + +@ModuleInfo ( + name = "XP to Killers", + description = "Gives a configurable amount of XP levels on player kill " + + "(optionally only for different team).", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.END, + icon = Material.EXP_BOTTLE, + settings = Config.class +) +public class XpToKillersModule extends UHModule +{ + @EventHandler + public void onPlayerDeath(final AlivePlayerDeathEvent ev) + { + if (!ev.getPlayer().isOnline()) return; + + final Player killer = ev.getPlayer().getPlayer().getKiller(); + if (killer != null) + { + boolean inSameTeam = Objects.equals(ZTeams.get().getTeamForPlayer(ev.getPlayer()), ZTeams.get().getTeamForPlayer(killer)); + boolean onlyOtherTeam = Config.ONLY_OTHER_TEAM.get(); + + if (!onlyOtherTeam || !inSameTeam) + { + killer.giveExpLevels(Config.LEVELS.get()); + } + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 767fd1f..3db8121 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -46,6 +46,7 @@ modules: "gameplay-noEnderPearlDamages": true "gameplay-noWitches": true "gameplay-potions": true + "gameplay-xpToKillers": true "cosmetics-hardcoreHearts": true "cosmetics-motd": true @@ -66,127 +67,6 @@ worlds: the_end: world_the_end -episodes: - enabled: true - - # Format: "mm", "mm:ss" or "hh:mm:ss". If invalid, 20 minutes. - # Don't remove the "quotes" (because of the commas)! - length: "20:00" - - # A title is displayed when the episode changes. - title: true - - - -map: - # The diameter of the map (not the radius!), in blocks. - size: 2000 - - # "squared" or "circular". Affects the WorldBorder pre-configuration, and the - # wall generator used. - shape: "squared" - - wall: - height: 128 - block: - # The replaceAir block will be placed where there where some transparent blocks or trees before. - # The replaceSolid one, where there was an other kind of block. - replaceAir: GLASS - replaceSolid: BEDROCK - - border: - # The world border manager. Can be: - # - "vanilla", to use the vanilla world border; or - # - "brettflan", to use the WorldBorder Bukkit plugin by Brettflan - # (http://dev.bukkit.org/bukkit-plugins/worldborder/). - # - # If the shape is "circular", fallbacks to "brettflan" as the vanilla world border don't - # support circular borders. And if the WorldBorder plugin is not installed, fallbacks to - # no border. - motor: "vanilla" - - # The amount of blocks a player may safely be outside the border before taking damage. - # Only for the vanilla world border. Ignored else. - damagesBuffer: 5 - - # The amount of damage a player takes when outside the border plus the border buffer. - # The damages delt is calculated by multiplying this amount by the number of blocks behind the buffer. - # Only for the vanilla world border. Ignored else. - damagesAmount: 0.2 - - # The warning distance that causes the screen to be tinted red when the player is within the specified - # number of blocks from the border. - # Only for the vanilla world border. Ignored else. - warningDistance: 5 - - - # You can display the border size in the scoreboard; see `scoreboard.border`. - - - # Automatic and progressive border shrinking. - # Notice: if the border is circular, the WorldBorder Bukkit plugin by Brettflan (see above) - # is REQUIRED. Without, the border shrinking will not work. - shrinking: - enabled: false - - # Formats: "mm", "mm:ss" or "hh:mm:ss". - # With the default values, the border eats one block every 8 seconds on each side. - startsAfter: "30:00" - shrinksDuring: "2:00:00" - diameterAfterShrink: 200 - - - # The delay between two warning messages sent to the players out of a future border - # (this warning is set using /uh border warning <futureDiameter>). - warningInterval: 90 # seconds - - spawnPoints: - # Don't generate the spawn points (with /uh spawns generate) above the water? - dontGenerateAboveWater: true - - - -daylightCycle: - do: false - time: 6000 # Initial time (or game time if the daylight cycle is disabled) in ticks. 6000 = noon. - - - -scoreboard: - title: Kill the Patrick - - # Scoreboard displayed on the left of the screen - enabled: true - episode: true - players: true - teams: true - ownTeam: - enabled: true # Displays the player's team in the scoreboard - title: - color: "" # The color of the title. If empty, the team color is used. - useTeamName: false # If true, the title is the team's name. Else, a generic title (« Your team »). - content: - displayHearts: true # Displays hearts colored following the player's life (low = red, high = green) - colorName: false # Color the whole name, not only the heart, following the life. If disabled the name is white (alive) or gray (dead). - strikeDeadPlayers: false # Strike the dead players lines. - loginState: - italic: true # Logged-out players are displayed in italic - suffix: "\u27A5" # This string is displayed after the name of logged-out players - displayMetPlayersOnly: - enabled: false # If enabled, the sidebar will only contains players met at some time. - displayedWhenCloserThan: 10 # If enabled, a teammate will be displayed to the reference player if he/she is closer that this amount of blocks to the player. - border: - displayed: true - displayDiameter: false # If true, displays the border diameter (ex. "2000 blocks wide"). Else, the min/max coordinates (ex. "-1000 +1000"). Ignored if the border is circular. - kills: true - timer: true - freezeStatus: true - - # Health in the list of the players - health: true - - - # Controls what is displayed in the tab list headers and footers. # Tags: # - {title}: contains the scoreboard title (key scoreboard.title). @@ -207,25 +87,6 @@ playersList: footer: "§a{episodeText} §7- §a{playersText} §7- §a{teamsText}" - -# Update the MOTD according to the current state of the game? -# This will overwrite the original MOTD. -motd: - enabled: false - - # Display the name of the match ("scoreboard.title") in the first line of the MOTD? - displayMatchName: true - # This will be displayed before the match name (formatting...) - matchNamePrefix: "" - - -# Teleport the players to the spawn point on login if the game is not started? -# Avoids the random spawn point of Minecraft, and teleports them back to -# there if they log out then in. -teleportToSpawnIfNotStarted: true - - - achievements: # When a player joins the game before the beginning of the game, his achievements are reset? resetAchievementsAtStartup: true @@ -234,276 +95,6 @@ achievements: disableAchievementsBeforeStart: true - -statistics: - # A player cannot increment a statistic if the game is not started? - disableStatisticsBeforeStart: true - - - -before-start: - inventory: - # True to clear the inventory of the players before the beginning of the game. - clear: true - - # True to prevent users from using their inventory when the game is not started. - preventUsage: true - - # True to disable all the inventory points above for players with the uh.build permission. - allowForBuilders: true - - teamSelector: - # True to give to the players a team selector, opening the teams inventory GUI (same as /teams). - enabled: true - - # The item to use as the team selector. Right-clicking it will open the GUI. - item: NETHER_STAR - - # Displays the current team in the action bar before the game. Nothing is displayed if the player is - # not in a team. - teamInActionBar: true - - enablePVP: false - - -start: - slow: - delayBetweenTP: 3 # in seconds - broadcastProgress: true # Displays something like « Teleporting... (14/28) » in the action bar for every player. - - cages: - # Instead of flying above the ground, if this is enabled, players will wait for the game start in - # cages, built in the material you want. - enabled: true - - # The cage type. Can be: - # - team_color_transparent (stained glass using the team color, or white without color/for solo); - # - team_color_solid (the same with stained hardened clay); - # - custom (a custom block, configure the one to use after). - type: team_color_transparent - - # If you selected “custom” before, write here the block you want to use. It can be any valid Material. - # You can use safely any falling block here, they will never fall. - customBlock: - - # If true, the cages will be built completly, including the ceiling. Else, they will be open to the sky. - buildCeiling: false - - # If true, the walls will be built using the block above. Else, using barrier blocks. - visibleWalls: true - - # The internal square radius of the cage. - # With 0, you'll have a cage with one block to walk. - # With 1, you'll have a 3×3 cage. - # With 2, a 5×5 cage. Etc. - radius: 1 - - # The internal height of the cages, i.e. the height of the space available to the players inside the cage. - height: 3 - - sound: - name: NONE - volume: 1 - pitch: 1 - - # Display a title to everyone when the game begins - displayTitle: true - - # Damages are enabled after this amount of time. - # Cannot be less than 15 seconds, to avoid initial-fall-related problems. - # Format: "mm", "mm:ss", "hh:mm:ss" - gracePeriod: "00:30" - - # If true, a message will be broadcasted when the grace period ends. - broadcastGraceEnd: true - - # PVP is enabled after this amount of time. - # If 0, enabled immediately. - # Format: "mm", "mm:ss", "hh:mm:ss" - peacePeriod: 0 - - # The hostile mobs will not be allowed to spawn on the surface during this amount of time after - # the beginning of the game. This prevents mobs from lightning errors to cause deaths during the - # early game, when players just started and are not protected. - # This option is here to prevent lightning-bugs-related deaths or damages, so spawns on surface - # areas normally dark (like overhangs or floating islands) are not cancelled. Also, mobs will - # still spawn on caves. - # Format: "mm", "mm:ss", "hh:mm:ss". To disable, set to 0. - surfaceMobsFreePeriod: "15:00" - - - -death: - messages: - notifyIfTeamHasFallen: true - deathMessagesFormat: "§6" # Use this to increase visibility of death messages. - teamDeathMessagesFormat: "§6" - - kick: - do: false - time: 30 - allow-reconnect: true - - head: - drop: true - pvpOnly: false - - give-xp-to-killer: - levels: 2 # set to 0 to disable - onlyOtherTeam: true # Give XP only if the player kills a player from another team? - - announcements: - lightning-strike: false - - sound: - name: WITHER_SPAWN - volume: 1 - pitch: 1 - - - -# If true, the name of the players will be colorized according to the teams. -colorizeChat: true - - - -gameplay-changes: - naturalRegeneration: false # If true, the health will regenerate with food (just like in the default vanilla game). - - weather: true # If false, the "bad" weather (rain, thunder) is disabled. - - replaceGhastTearsWithGold: true - craftGoldenMelonWithGoldBlock: true - - craftGoldenAppleFromHead: - fromHuman: - do: true - numberCrafted: 2 - addLore: true - craftNotchApple: false - fromWither: - do: true - numberCrafted: 1 - addLore: true - craftNotchApple: false - - goldenApple: - regeneration: - # Half-hearts regenerated by one apple. Vanilla: normal 4, notch 180 (yes, 180). - normal: 4 - notch: 180 - fromNormalHead: 4 - fromNotchHead: 180 - - disableNotchApples: false - - disableEnderpearlsDamages: true - - disableLevelIIPotions: false - - witch: - disableNaturalSpawn: false - disableLightningSpawn: false # from a villager - - rabbit: - killerRabbitSpawn: true - # When a rabbit spawns, it will be transformed into a Killer Rabbit following - # this probability (between 0 and 1). - killerRabbitSpawnProbability: 0.05 - # The rabbit will be named after this configuration point, except if empty - then, the - # default vanilla name will be used ("The Killer Bunny"). - killerRabbitName: "The Killer Rabbit of Caerbannog" - - - # If true a compass will show the nearest player, and the craft will be different. - # Else, the craft will be standard and the compass will show the spawn point of the team/player (not the world spawn point). - compass: - enabled: true - - # The special recipe is with an ingredient in the center, and then, - # from the top, clockwise: iron, spider eye, iron, rotten flesh, iron, bone, iron, gunpowder. - # This field change the central ingredient. - # "easy": redstone (like the normal compass). - # "medium": ender pearl. - # "hard": eye of ender. - recipe: "medium" - - - -teams-options: - canSeeFriendlyInvisibles: true - allowFriendlyFire: true - - # 0 = unlimited. - maxPlayersPerTeam: 0 - - # Randoms colors for solo games and solo teams (i.e. all the teams generated when the game starts)? - # If false, no color (aka white) used. - randomColors: true - - # These options are related to the auto-generated banner of each team. - # This banner is used on the teams selector (if set to "banner"), and can be given to the - # players when the game starts. - banner: - shape: - writeLetter: true - addBorder: true - give: - placeOnSpawn: true # Places the team banner on the spawn point. - giveInHotbar: false # Gives a banner to each player. - giveInHead: false # Places the banner on the head of each player. - shields: - addOnShields: true # Crafted shields will have the team banner on them. MC 1.9+ only. - - - # Chat-based GUI to choose a team - gui: - # Display the players in each team, in the tooltip linked to the players count? - displayPlayersInTeams: true - - # Display the GUI when a player login out of any team? - autoDisplay: true - # Delay between the login and the display? (Seconds) - delay: 4 - - # Chest-based GUI to choose a team and manage the teams - chestGui: - display: - teamItem: "banner" # Values: "banner", "glass", "glass_pane", "clay", "wool", "dye" - glowOnSelectedTeam: true # Set to true to display an enchantment glow on the player team - - teamChat: - # Forces disable the team-chat when the player die. - # If you use SpectatorPlus with the block-commands option enabled, this will prevent spectators - # from using the team chat. - disableLockOnDeath: true - - # Log the private team-chat in the console? - log: false - - - -hardcore-hearts: - # Display hardcore hearts instead of normal ones? - display: true - - # If a player die, his client will display an hardcore Game Over screen, without a « Respawn » button. - # But the player CAN respawn, by clicking « Leave server » and then, on the confirmation screen, - # « Respawn ». - # With this option enabled, a short message will notify the player about that. - # Notice: this will be disabled even with this set to true if the hardcore hearts are not enabled (useless). - respawnMessage: false - - - -# Automatically respawn the player after his death. -# Avoid the interrogation about the ability to respawn, if hardcore hearts are enabled. -auto-respawn: - do: true - delay: 6 # seconds - - - # Controls the behavior of the /uh finish command finish: auto: @@ -519,19 +110,6 @@ finish: areaSize: 6 # The size of the square, centered on each player, where the fireworks will be launched. - -dynmap: - showSpawnLocations: true - showDeathLocations: true - - - -# Enable spectator mode for player joining the game after the beginning -# (only for out-of-the-UHC players of course)? -spectatorModeWhenNewPlayerJoinAfterStart: true - - - # Rules are a way to display rules & other informations to the players. # The content is completly up to you, formatting included (using standard # formatting codes with either § or &). It will be displayed as a list to @@ -546,7 +124,6 @@ rules: - - # Execute commands during the game or after the end of it, and after a configurable delay? # Format explained below. # Respect the spaces before the keywords ("exec" and "delay" need to be aligned). @@ -567,52 +144,3 @@ commands: # (After the last kill, when only one team is left.) execute-end: - - - -protips: - sound: - name: NOTE_PLING - volume: 2 - pitch: 3 - - teamchat: - useTCommand: true # Protip: team-chat command - lock: true # Protip: can lock the team-chat - useGCommand: true # Protip: global-chat command - - crafts: - goldenHead: true # ProTip: craft of golden apples with an head - compassEasy: true # Protip: "easy" compass craft - compassMedium: true # Protip: "medium" compass craft - compassHard: true # Protip: "hard" compass craft - glisteringMelon: true # Protip: glistering melon crafted with a gold block - noEnchGoldenApple: true # Protip: enchanted golden apple disabled - - start: - invincibility: true # Protip: 30 seconds (25 after the message) of invincibility. - - - -# Use this to set the spawnpoints of the teams (or the players) -# You can also use the command `/uh spawns add` to add temporary spawn points, -# and `/uh spawns generate` to automatically generate them. (See `/uh spawns` for documentation.) -# (The spawn points added through `/uh spawns` are deleted when the server is stopped.) -# -# Format: -# - x,z -# - x,z -# - etc. - -spawnpoints: - - - - - -# Use this to pre-register the teams. -# Format: -# - color -# -- OR -- -# - color,name - -teams: - - From 4df73cf87d6a9e81903d0c50231d0c1e21224bd7 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 17 Jan 2019 13:23:04 +0100 Subject: [PATCH 51/91] Moved modules manager logic to a dedicated class --- .../amaury/UHCReloaded/UHCReloaded.java | 294 +--------------- .../UHCReloaded/core/ModuleWrapper.java | 4 +- .../UHCReloaded/core/ModulesManager.java | 326 ++++++++++++++++++ .../modules/border/walls/WallsCommand.java | 3 +- .../modules/border/walls/WallsModule.java | 4 +- .../core/modules/commands/ModuleCommand.java | 4 +- .../core/modules/commands/ModulesCommand.java | 2 +- .../core/modules/gui/ModulesListGUI.java | 6 +- .../modules/core/sidebar/GameSidebar.java | 4 +- .../CircularSpawnPointsGenerator.java | 4 +- .../generators/GridSpawnPointsGenerator.java | 4 +- .../RandomSpawnPointsGenerator.java | 4 +- .../core/timers/commands/TimersCommand.java | 6 +- .../amaury/UHCReloaded/shortcuts/UR.java | 3 +- 14 files changed, 366 insertions(+), 302 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 4232ec4..53c0302 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -33,10 +33,8 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.core.ModulesManager; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; @@ -53,9 +51,7 @@ import eu.carrade.amaury.UHCReloaded.old.misc.*; import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; -import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.i18n.I; @@ -64,25 +60,18 @@ import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.core.ZPlugin; import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.command.CommandMap; -import org.bukkit.command.PluginCommand; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.world.WorldLoadEvent; -import org.bukkit.plugin.Plugin; import org.bukkit.scoreboard.Scoreboard; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.function.BiConsumer; -import java.util.stream.Collectors; public class UHCReloaded extends ZPlugin implements Listener @@ -92,6 +81,8 @@ public class UHCReloaded extends ZPlugin implements Listener private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); + private ModulesManager modulesManager = null; + private Scoreboard scoreboard = null; private World worldNormal = null; @@ -128,6 +119,8 @@ public void onEnable() loadComponents(UHConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, OfflinePlayersLoader.class); + modulesManager = loadComponent(ModulesManager.class); + /* *** Internationalization *** */ @@ -144,7 +137,7 @@ public void onEnable() /* *** Core modules *** */ - registerModules( + modulesManager.registerModules( ModulesManagerModule.class, // Manages the modules from the game/commands. SidebarModule.class, // Manages the sidebar and provides hooks for other modules. @@ -169,12 +162,12 @@ public void onEnable() /* *** Config modules *** */ - UHConfig.MODULES.forEach((BiConsumer<String, Boolean>) this::registerModule); + UHConfig.MODULES.forEach((BiConsumer<String, Boolean>) modulesManager::registerModule); /* *** Loads modules from startup time *** */ - loadModules(ModuleLoadTime.STARTUP); + modulesManager.loadModules(ModuleLoadTime.STARTUP); /* *** Loads modules from post-world time if worlds are loaded (server reloaded) *** */ @@ -207,162 +200,20 @@ private void onEnableWhenWorldsAvailable() worldNether = setDefaultWorld(World.Environment.NETHER, UHConfig.WORLDS.NETHER.get()); worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get()); - loadModules(ModuleLoadTime.POST_WORLD); + modulesManager.loadModules(ModuleLoadTime.POST_WORLD); }); worldsLoaded = true; } - - - /** - * Registers an UHCReloaded module (or many). It is not enabled by this method. - * - * @param modules the module's class, that must accept a zero-arguments constructor. - */ - @SafeVarargs - public final void registerModules(final Class<? extends UHModule>... modules) - { - Arrays.stream(modules).forEach(module -> registerModule(module, true)); - } - - /** - * Registers an UHCReloaded module (or many). It is not enabled by this method. - * - * @param module the module's class, that must accept a zero-arguments constructor. - * @param enableAtStartup {@code true} if this module, according to the configuration file, should be loaded at startup. - */ - private void registerModule(final Class<? extends UHModule> module, final boolean enableAtStartup) - { - this.modules.put(module, new ModuleWrapper(module, enableAtStartup)); - } - - /** - * Registers an UHCReloaded module. It is not enabled by this method. - * - * It tries to load the following classes (in this order, taking the first existing): - * - * - eu.carrade.amaury.UHCReloaded.modules.[name] - * - eu.carrade.amaury.UHCReloaded.modules.[name]Module - * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] - * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module - * - [name] - * - * @param module the module's class name; the class must accept a zero-arguments constructor. - */ - public void registerModule(final String module) - { - registerModule(module, true); - } - - /** - * Registers an UHCReloaded module. It is not enabled by this method. - * - * It tries to load the following classes (in this order, taking the first existing): - * - * - eu.carrade.amaury.UHCReloaded.modules.[name] - * - eu.carrade.amaury.UHCReloaded.modules.[name]Module - * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] - * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module - * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module - * - [name] - * - * @param module the module's class name; the class must accept a zero-arguments constructor. - * @param initiallyEnabled {@code true} if this module, according to the configuration file, - * should be enabled at startup. - */ - private void registerModule(final String module, boolean initiallyEnabled) - { - final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( - module.replace('-', '.'), - "eu.carrade.amaury.UHCReloaded.modules", - "Module", - UHModule.class - ); - - if (moduleClass != null) - { - registerModule(moduleClass, initiallyEnabled); - } - else - { - PluginLogger.error("Error registering a module: unable to find a module named {0} in the class path. Maybe you spelled it wrong?", module); - } - } - - - - /** - * Loads registered modules. Internal modules will always be loaded first. - * - * @param loadTime Loads the modules registered to be loaded at that given time. - */ - private void loadModules(final ModuleLoadTime loadTime) - { - if (loadedPriorities.contains(loadTime)) return; - - // Loads all internal modules first - modules.values().stream() - .filter(module -> module.getWhen() == loadTime) - .filter(ModuleWrapper::isEnabled) - .filter(module -> !module.isLoaded()) - .filter(ModuleWrapper::isInternal) - .forEach(module -> module.load(false)); - - // Then loads other modules - modules.values().stream() - .filter(module -> module.getWhen() == loadTime) - .filter(ModuleWrapper::isEnabled) - .filter(module -> !module.isLoaded()) - .filter(module -> !module.isInternal()) - .forEach(module -> module.load(false)); - - loadedPriorities.add(loadTime); - - collectCommandsFromModules(); - - getServer().getPluginManager().callEvent(new AllModulesLoadedEvent(loadTime)); - } - - /** - * Checks if the given load time was already loaded. - * - * @param loadTime The load time. - * @return {@code true} if loaded. - */ - public boolean isLoaded(final ModuleLoadTime loadTime) - { - return loadedPriorities.contains(loadTime); - } - /** - * Gets a module's instance. This may return null if the module is not currently - * enabled. - * - * @param moduleClass The module's class. - * @param <M> The module's type. - * - * @return The module's instance. + * @return The modules manager. */ - public static <M extends UHModule> M getModule(final Class<M> moduleClass) + public ModulesManager getModulesManager() { - final ModuleWrapper module = get().modules.get(moduleClass); - - if (module == null) return null; - else return (M) module.get(); + return modulesManager; } - - /** * @return The Bukkit scoreboard to use for everything. */ @@ -414,42 +265,19 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) switch (ev.getNewPhase()) { case STARTING: - loadModules(ModuleLoadTime.ON_GAME_STARTING); + modulesManager.loadModules(ModuleLoadTime.ON_GAME_STARTING); break; case IN_GAME: - loadModules(ModuleLoadTime.ON_GAME_START); + modulesManager.loadModules(ModuleLoadTime.ON_GAME_START); break; case END: - loadModules(ModuleLoadTime.ON_GAME_END); + modulesManager.loadModules(ModuleLoadTime.ON_GAME_END); break; } } - @EventHandler - public void onModuleLoaded(final ModuleLoadedEvent ev) - { - PluginLogger.info("Module {0} loaded.", ev.getModule().getName()); - - if (ev.isLoadedLate()) - { - // If loaded late, we may have to re-register the module's commands. - collectCommandsFromModules(); - } - } - - @EventHandler - public void onModuleUnloaded(final ModuleUnloadedEvent ev) - { - PluginLogger.info("Module {0} unloaded.", ev.getModule().getName()); - - // We remove commands if needed when a module is unloaded, - // as it will be unable to handle them properly (the module - // instance being null). - collectCommandsFromModules(); - } - @EventHandler (priority = EventPriority.LOWEST) public final void onPlayerJoin(final PlayerJoinEvent ev) { @@ -457,90 +285,6 @@ public final void onPlayerJoin(final PlayerJoinEvent ev) } - - @SuppressWarnings ("unchecked") - private void collectCommandsFromModules() - { - Commands.register("uh", modules.values().stream() - .filter(ModuleWrapper::isLoaded) - .map(module -> module.get().getCommands()) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .toArray(Class[]::new)); - - final Map<String, Class<? extends Command>> commandAliases = modules.values().stream() - .filter(ModuleWrapper::isLoaded) - .map(module -> module.get().getCommandsAliases()) - .filter(Objects::nonNull) - .flatMap(commandsAliases -> commandsAliases.entrySet().stream()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a)); - - // As they are not registered in the plugin.yml, for each command, we have to force-register - // the name manually. - - final Map<org.bukkit.command.Command, Class<? extends Command>> pluginCommands = new HashMap<>(); - final Set<String> registered = new HashSet<>(); - - try - { - final Constructor<PluginCommand> pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); - pluginCommandConstructor.setAccessible(true); - - for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) - { - try - { - pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), this), commandAlias.getValue()); - registered.add(commandAlias.getKey()); - } - catch (InstantiationException | InvocationTargetException | IllegalAccessException e) - { - PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandAlias); - } - } - - try - { - final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); - - String mutPrefix = getDescription().getPrefix(); - if (mutPrefix == null) mutPrefix = getDescription().getName().toLowerCase(); - - final String prefix = mutPrefix; - - pluginCommands.forEach((pluginCommand, commandClass) -> - { - if (commandMap.register(prefix, pluginCommand)) - { - PluginLogger.info( - "Hot-registered new command /{0} for class “{1}”.", - pluginCommand.getName(), - commandClass.getName().replace("eu.carrade.amaury.UHCReloaded.", "...") - ); - } - }); - } - catch (NoSuchFieldException | IllegalAccessException e) - { - PluginLogger.error("Unable to retrieve Bukkit's command map, is this version supported by UHCReloaded?", e); - } - } - catch (NoSuchMethodException | SecurityException e) - { - PluginLogger.error("Unable to register plugin commands: unable to retrieve PluginCommand's constructor. Is this version supported by UHCReloaded?", e); - } - - // Now that all commands are registered into Bukkit, we can register them into zLib. - - commandAliases.forEach((name, klass) -> - { - // Bukkit registration failed? - if (!registered.contains(name)) return; - - Commands.registerShortcut("uh", klass, name); - }); - } - private World setDefaultWorld(final World.Environment environment, final String worldName) { final World userWorld = Bukkit.getWorld(worldName); @@ -656,12 +400,4 @@ public static UHCReloaded get() { return instance; } - - /** - * @return A view on all registered modules. - */ - public Collection<ModuleWrapper> getModules() - { - return modules.values(); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index 82649ff..c4b7031 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -223,7 +223,7 @@ else if (!canBeDisabled()) { Bukkit.getPluginManager().callEvent(new ModuleEnabledEvent(this)); - if (UR.get().isLoaded(when)) + if (UR.get().getModulesManager().isLoaded(when)) { return load(true); } @@ -244,7 +244,7 @@ else if (!canBeDisabled()) */ public boolean canBeEnabled() { - return canBeLoadedLate || !UR.get().isLoaded(when); + return canBeLoadedLate || !UR.get().getModulesManager().isLoaded(when); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java new file mode 100644 index 0000000..af05a88 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -0,0 +1,326 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.core; + +import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; +import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.Commands; +import fr.zcraft.zlib.core.ZLibComponent; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandMap; +import org.bukkit.command.PluginCommand; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.plugin.Plugin; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.stream.Collectors; + +public class ModulesManager extends ZLibComponent implements Listener +{ + private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); + private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); + + + /** + * @return A view on all registered modules. + */ + public Collection<ModuleWrapper> getModules() + { + return modules.values(); + } + + /** + * Registers an UHCReloaded module (or many). It is not enabled by this method. + * + * @param modules the module's class, that must accept a zero-arguments constructor. + */ + @SafeVarargs + public final void registerModules(final Class<? extends UHModule>... modules) + { + Arrays.stream(modules).forEach(module -> registerModule(module, true)); + } + + /** + * Registers an UHCReloaded module (or many). It is not enabled by this method. + * + * @param module the module's class, that must accept a zero-arguments constructor. + * @param initiallyEnabled {@code true} if this module, according to the configuration file, should be loaded at startup. + */ + public void registerModule(final Class<? extends UHModule> module, final boolean initiallyEnabled) + { + this.modules.put(module, new ModuleWrapper(module, initiallyEnabled)); + } + + /** + * Registers an UHCReloaded module. It is not enabled by this method. + * + * It tries to load the following classes (in this order, taking the first existing): + * + * - eu.carrade.amaury.UHCReloaded.modules.[name] + * - eu.carrade.amaury.UHCReloaded.modules.[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module + * - [name] + * + * @param module the module's class name; the class must accept a zero-arguments constructor. + */ + public void registerModule(final String module) + { + registerModule(module, true); + } + + /** + * Registers an UHCReloaded module. It is not enabled by this method. + * + * It tries to load the following classes (in this order, taking the first existing): + * + * - eu.carrade.amaury.UHCReloaded.modules.[name] + * - eu.carrade.amaury.UHCReloaded.modules.[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[name]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName] + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].[capitalizedName]Module + * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module + * - [name] + * + * @param module the module's class name; the class must accept a zero-arguments constructor. + * @param initiallyEnabled {@code true} if this module, according to the configuration file, + * should be enabled at startup. + */ + public void registerModule(final String module, boolean initiallyEnabled) + { + final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( + module.replace('-', '.'), + "eu.carrade.amaury.UHCReloaded.modules", + "Module", + UHModule.class + ); + + if (moduleClass != null) + { + registerModule(moduleClass, initiallyEnabled); + } + else + { + PluginLogger.error("Error registering a module: unable to find a module named {0} in the class path. Maybe you spelled it wrong?", module); + } + } + + + + /** + * Loads registered modules. Internal modules will always be loaded first. + * + * @param loadTime Loads the modules registered to be loaded at that given time. + */ + public void loadModules(final ModuleLoadTime loadTime) + { + if (loadedPriorities.contains(loadTime)) return; + + // Loads all internal modules first + modules.values().stream() + .filter(module -> module.getWhen() == loadTime) + .filter(ModuleWrapper::isEnabled) + .filter(module -> !module.isLoaded()) + .filter(ModuleWrapper::isInternal) + .forEach(module -> module.load(false)); + + // Then loads other modules + modules.values().stream() + .filter(module -> module.getWhen() == loadTime) + .filter(ModuleWrapper::isEnabled) + .filter(module -> !module.isLoaded()) + .filter(module -> !module.isInternal()) + .forEach(module -> module.load(false)); + + loadedPriorities.add(loadTime); + + collectCommandsFromModules(); + + Bukkit.getPluginManager().callEvent(new AllModulesLoadedEvent(loadTime)); + } + + /** + * Checks if the given load time was already loaded. + * + * @param loadTime The load time. + * @return {@code true} if loaded. + */ + public boolean isLoaded(final ModuleLoadTime loadTime) + { + return loadedPriorities.contains(loadTime); + } + + /** + * Gets a module's instance. This may return null if the module is not currently + * enabled. + * + * @param moduleClass The module's class. + * @param <M> The module's type. + * + * @return The module's instance. + */ + public static <M extends UHModule> M getModule(final Class<M> moduleClass) + { + final ModuleWrapper module = UR.get().getModulesManager().modules.get(moduleClass); + + if (module == null) return null; + else return (M) module.get(); + } + + + @SuppressWarnings ("unchecked") + private void collectCommandsFromModules() + { + Commands.register("uh", modules.values().stream() + .filter(ModuleWrapper::isLoaded) + .map(module -> module.get().getCommands()) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .toArray(Class[]::new)); + + final Map<String, Class<? extends Command>> commandAliases = modules.values().stream() + .filter(ModuleWrapper::isLoaded) + .map(module -> module.get().getCommandsAliases()) + .filter(Objects::nonNull) + .flatMap(commandsAliases -> commandsAliases.entrySet().stream()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a)); + + // As they are not registered in the plugin.yml, for each command, we have to force-register + // the name manually. + + final Map<org.bukkit.command.Command, Class<? extends Command>> pluginCommands = new HashMap<>(); + final Set<String> registered = new HashSet<>(); + + try + { + final Constructor<PluginCommand> pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); + pluginCommandConstructor.setAccessible(true); + + for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) + { + try + { + pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), this), commandAlias.getValue()); + registered.add(commandAlias.getKey()); + } + catch (InstantiationException | InvocationTargetException | IllegalAccessException e) + { + PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandAlias); + } + } + + try + { + final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); + + String mutPrefix = UR.get().getDescription().getPrefix(); + if (mutPrefix == null) mutPrefix = UR.get().getDescription().getName().toLowerCase(); + + final String prefix = mutPrefix; + + pluginCommands.forEach((pluginCommand, commandClass) -> + { + if (commandMap.register(prefix, pluginCommand)) + { + PluginLogger.info( + "Hot-registered new command /{0} for class “{1}”.", + pluginCommand.getName(), + commandClass.getName().replace("eu.carrade.amaury.UHCReloaded.", "...") + ); + } + }); + } + catch (NoSuchFieldException | IllegalAccessException e) + { + PluginLogger.error("Unable to retrieve Bukkit's command map, is this version supported by UHCReloaded?", e); + } + } + catch (NoSuchMethodException | SecurityException e) + { + PluginLogger.error("Unable to register plugin commands: unable to retrieve PluginCommand's constructor. Is this version supported by UHCReloaded?", e); + } + + // Now that all commands are registered into Bukkit, we can register them into zLib. + + commandAliases.forEach((name, klass) -> + { + // Bukkit registration failed? + if (!registered.contains(name)) return; + + Commands.registerShortcut("uh", klass, name); + }); + } + + + + @EventHandler + public void onModuleLoaded(final ModuleLoadedEvent ev) + { + PluginLogger.info("Module {0} loaded.", ev.getModule().getName()); + + if (ev.isLoadedLate()) + { + // If loaded late, we may have to re-register the module's commands. + collectCommandsFromModules(); + } + } + + @EventHandler + public void onModuleUnloaded(final ModuleUnloadedEvent ev) + { + PluginLogger.info("Module {0} unloaded.", ev.getModule().getName()); + + // We remove commands if needed when a module is unloaded, + // as it will be unable to handle them properly (the module + // instance being null). + collectCommandsFromModules(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java index 23a7a7b..ed4623b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java @@ -35,6 +35,7 @@ import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; @@ -69,7 +70,7 @@ else if (sender instanceof BlockCommandSender) try { - UHCReloaded.getModule(WallsModule.class).generateWalls(world); + UR.module(WallsModule.class).generateWalls(world); } catch (CannotGenerateWallsException e) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java index a1e7b63..de2d434 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java @@ -33,7 +33,6 @@ */ package eu.carrade.amaury.UHCReloaded.modules.border.walls; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; @@ -42,6 +41,7 @@ import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.UnknownWallGenerator; import eu.carrade.amaury.UHCReloaded.modules.border.walls.generators.WallGenerator; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Material; import org.bukkit.World; @@ -65,7 +65,7 @@ public class WallsModule extends UHModule @Override protected void onEnable() { - borderModule = UHCReloaded.getModule(BorderModule.class); + borderModule = UR.module(BorderModule.class); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java index 08e06c6..23777a9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java @@ -64,7 +64,7 @@ protected void run() throws CommandException ModuleWrapper module = null; - for (final ModuleWrapper m : UR.get().getModules()) + for (final ModuleWrapper m : UR.get().getModulesManager().getModules()) { if (getModuleKey(m).equalsIgnoreCase(args[1])) { @@ -124,7 +124,7 @@ else if (module.setEnabled(false)) protected List<String> complete() { if (args.length == 1) return getMatchingSubset(args[0], "enable", "disable"); - else if (args.length == 2) return getMatchingSubset(UR.get().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); + else if (args.length == 2) return getMatchingSubset(UR.get().getModulesManager().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); else return null; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java index d4d53ef..a44967f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java @@ -67,7 +67,7 @@ protected void run() throws CommandException return module1.getName().compareTo(module2.getName()); }); - modules.addAll(UHCReloaded.get().getModules()); + modules.addAll(UHCReloaded.get().getModulesManager().getModules()); success(I.tn("{0} module registered {gray}(hover for details)", "{0} modules registered {gray}(hover for details)", modules.size())); modules.forEach(module -> { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java index c9a0527..54c5527 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java @@ -73,7 +73,7 @@ protected void onUpdate() setMode(Mode.READONLY); setKeepHorizontalScrollingSpace(true); - final ModuleWrapper[] modules = UR.get().getModules().stream() + final ModuleWrapper[] modules = UR.get().getModulesManager().getModules().stream() .filter(module -> filterCategory == null || module.getCategory() == filterCategory) .sorted((module1, module2) -> { if (module1.equals(module2)) return 0; @@ -95,11 +95,11 @@ protected void onUpdate() // Sets the title if (filterCategory == null) { - setTitle(I.t("{black}All modules {darkgray}({0})", UR.get().getModules().size())); + setTitle(I.t("{black}All modules {darkgray}({0})", UR.get().getModulesManager().getModules().size())); } else { - setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, UR.get().getModules().size())); + setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, UR.get().getModulesManager().getModules().size())); } // Displays the bottom bar of color diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java index e8ac757..2e04809 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java @@ -53,7 +53,7 @@ public GameSidebar() @Override public void preRender() { - UHCReloaded.get().getModules().stream() + UHCReloaded.get().getModulesManager().getModules().stream() .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) .forEach(UHModule::prepareInjectionIntoSidebar); @@ -64,7 +64,7 @@ public List<String> getContent(Player player) { final SidebarInjector injector = new SidebarInjector(); - UHCReloaded.get().getModules().stream() + UHCReloaded.get().getModulesManager().getModules().stream() .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) .forEach(module -> module.injectIntoSidebar(player, injector)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index 2c7b688..736580f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -32,9 +32,9 @@ package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -49,7 +49,7 @@ public class CircularSpawnPointsGenerator implements SpawnPointsGenerator { - private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); + private final BorderModule borderModule = UR.module(BorderModule.class); /** * Generates spawn points in concentric circles. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java index ffefa51..7eb0b60 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -31,10 +31,10 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -48,7 +48,7 @@ public class GridSpawnPointsGenerator implements SpawnPointsGenerator { - private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); + private final BorderModule borderModule = UR.module(BorderModule.class); /** * Generates spawn points in a grid. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index c298739..873fa65 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -32,10 +32,10 @@ package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -54,7 +54,7 @@ public class RandomSpawnPointsGenerator implements SpawnPointsGenerator { private final Random random = new Random(); - private final BorderModule borderModule = UHCReloaded.getModule(BorderModule.class); + private final BorderModule borderModule = UR.module(BorderModule.class); /** * Generates randomly some spawn points in the map, with a minimal distance. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java index 86c0e11..a2b10bf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java @@ -31,10 +31,10 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.timers.commands; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; @@ -54,7 +54,7 @@ @WithFlags public class TimersCommand extends Command { - private final TimersModule timersModule = UHCReloaded.getModule(TimersModule.class); + private final TimersModule timersModule = UR.module(TimersModule.class); @Override protected void run() throws CommandException @@ -354,7 +354,7 @@ private Timer getTimerParameter(int index) throws CommandException try { final String timerName = UHUtils.getStringFromCommandArguments(args, index); - final Timer timer = UHCReloaded.getModule(TimersModule.class).getTimer(timerName); + final Timer timer = timersModule.getTimer(timerName); if (timer == null) throwInvalidArgument(I.t("{ce}This timer is not registered.", timerName)); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index 4056284..0be2303 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -36,6 +36,7 @@ import com.google.common.reflect.ClassPath; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleLogger; +import eu.carrade.amaury.UHCReloaded.core.ModulesManager; import eu.carrade.amaury.UHCReloaded.core.UHModule; import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.reflection.Reflection; @@ -74,7 +75,7 @@ public static UHCReloaded get() */ public static <M extends UHModule> M module(final Class<M> moduleClass) { - return UHCReloaded.getModule(moduleClass); + return ModulesManager.getModule(moduleClass); } /** From 22da7d907e96026d5678861c08cf7fc1a5fe089c Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 18 Jan 2019 16:11:57 +0100 Subject: [PATCH 52/91] Dead code cleanup Breath \o/ --- .../amaury/UHCReloaded/UHCReloaded.java | 104 +- .../UHCReloaded/game/UHGameManager.java | 1264 ----------------- .../modules/beginning/cages/Cage.java | 2 +- .../modules/core/border/BorderModule.java | 10 + .../core/border/WorldBorderDependency.java} | 33 +- .../worldborders/BrettflanWorldBorder.java | 8 +- .../core/border/worldborders/WorldBorder.java | 7 +- .../core/modules/gui/ModulesListGUI.java | 2 +- .../spectators/SpectatorPlusDependency.java} | 42 +- .../core/spectators/SpectatorsModule.java | 1 + .../managers/SPlusSpectatorsManager.java | 20 +- .../managers/SpectatorsManager.java | 15 +- .../modules/other/about/AboutCommand.java | 2 +- .../modules/other/reports/ReportsModule.java | 2 +- .../old/commands/UHCommandExecutor.java | 54 - .../commands/GlobalMessageCommand.java | 117 -- .../commands/commands/TeamMessageCommand.java | 116 -- .../commands/commands/ToggleChatCommand.java | 132 -- .../old/commands/commands/UHRootCommand.java | 83 -- .../commands/categories/Category.java | 55 - .../commands/commands/uh/UHFinishCommand.java | 112 -- .../commands/commands/uh/UHFreezeCommand.java | 25 +- .../commands/commands/uh/UHInfosCommand.java | 205 --- .../commands/commands/uh/UHRulesCommand.java | 20 +- .../old/commands/core/AbstractCommand.java | 409 ------ .../core/AbstractCommandExecutor.java | 288 ---- .../commands/core/annotations/Command.java | 107 -- .../CannotExecuteCommandException.java | 102 -- .../old/events/UHGameEndsEvent.java | 93 -- .../old/events/UHGameStartsEvent.java | 56 - .../old/listeners/GameListener.java | 599 +------- .../old/listeners/GameplayListener.java | 79 -- .../amaury/UHCReloaded/old/misc/Freezer.java | 6 +- .../UHCReloaded/old/misc/MOTDManager.java | 147 -- .../misc/PlayerListHeaderFooterManager.java | 46 +- .../UHCReloaded/old/misc/RulesManager.java | 2 +- .../UHCReloaded/old/protips/ProTip.java | 147 -- .../UHCReloaded/old/protips/ProTips.java | 89 -- .../UHCReloaded/scoreboard/GameSidebar.java | 386 ----- .../scoreboard/ScoreboardManager.java | 179 --- .../amaury/UHCReloaded/utils/ColorsUtils.java | 90 -- .../core => }/utils/CommandUtils.java | 115 +- 42 files changed, 110 insertions(+), 5261 deletions(-) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/integration/UHWorldBorderIntegration.java => modules/core/border/WorldBorderDependency.java} (77%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/integration/UHSpectatorPlusIntegration.java => modules/core/spectators/SpectatorPlusDependency.java} (76%) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/utils/ColorsUtils.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/commands/core => }/utils/CommandUtils.java (56%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 53c0302..20057f0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -32,10 +32,7 @@ package eu.carrade.amaury.UHCReloaded; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.core.ModulesManager; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.game.UHGameManager; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; @@ -43,14 +40,10 @@ import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.old.integration.UHSpectatorPlusIntegration; -import eu.carrade.amaury.UHCReloaded.old.integration.UHWorldBorderIntegration; -import eu.carrade.amaury.UHCReloaded.old.misc.*; -import eu.carrade.amaury.UHCReloaded.old.recipes.RecipesManager; -import eu.carrade.amaury.UHCReloaded.scoreboard.ScoreboardManager; +import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; +import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.gui.Gui; @@ -70,7 +63,9 @@ import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.Scoreboard; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; import java.util.function.BiConsumer; @@ -78,9 +73,6 @@ public class UHCReloaded extends ZPlugin implements Listener { private static UHCReloaded instance; - private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); - private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); - private ModulesManager modulesManager = null; private Scoreboard scoreboard = null; @@ -91,21 +83,10 @@ public class UHCReloaded extends ZPlugin implements Listener private boolean worldsLoaded = false; - private UHGameManager gameManager = null; - private SpectatorsManager spectatorsManager = null; - private ScoreboardManager scoreboardManager = null; - private MOTDManager motdManager = null; private RulesManager rulesManager = null; - private PlayerListHeaderFooterManager playerListHeaderFooterManager = null; - private RecipesManager recipesManager = null; - - private RuntimeCommandsExecutor runtimeCommandsExecutor = null; private Freezer freezer = null; - private UHWorldBorderIntegration wbintegration = null; - private UHSpectatorPlusIntegration spintegration = null; - @Override public void onEnable() @@ -302,40 +283,6 @@ private World setDefaultWorld(final World.Environment environment, final String return Bukkit.getWorlds().get(0); } - - - /** - * Returns the game manager. - */ - public UHGameManager getGameManager() - { - return gameManager; - } - - /** - * @return the spectators manager. - */ - public SpectatorsManager getSpectatorsManager() - { - return spectatorsManager; - } - - /** - * Returns the scoreboard manager. - */ - public ScoreboardManager getScoreboardManager() - { - return scoreboardManager; - } - - /** - * Returns the MOTD manager. - */ - public MOTDManager getMOTDManager() - { - return motdManager; - } - /** * @return the rules manager. */ @@ -344,31 +291,6 @@ public RulesManager getRulesManager() return rulesManager; } - /** - * Returns the players list's headers & footers manager. - */ - public PlayerListHeaderFooterManager getPlayerListHeaderFooterManager() - { - return playerListHeaderFooterManager; - } - - /** - * Returns the recipe manager. - */ - public RecipesManager getRecipesManager() - { - return recipesManager; - } - - /** - * Returns the manager used to manage the commands executed after the start/the end of the - * game (or any other moment using the generic API). - */ - public RuntimeCommandsExecutor getRuntimeCommandsExecutor() - { - return runtimeCommandsExecutor; - } - /** * Returns the freezer. */ @@ -377,22 +299,6 @@ public Freezer getFreezer() return freezer; } - /** - * Returns the representation of the WorldBorder integration in the plugin. - */ - public UHWorldBorderIntegration getWorldBorderIntegration() - { - return wbintegration; - } - - /** - * Returns the representation of the SpectatorPlus integration in the plugin. - */ - public UHSpectatorPlusIntegration getSpectatorPlusIntegration() - { - return spintegration; - } - /** * Returns the plugin's instance. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java deleted file mode 100644 index 68a7eb0..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java +++ /dev/null @@ -1,1264 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.game; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.tools.Callback; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ActionBar; -import fr.zcraft.zlib.tools.text.RawMessage; -import org.bukkit.*; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; - -import java.util.*; -import java.util.stream.Collectors; - - -public class UHGameManager -{ - public final boolean START_GIVE_BANNER; - public final boolean START_PLACE_BANNER_HEAD; - public final boolean START_PLACE_BANNER_SPAWN; - - private final Boolean RANDOM_COLORS_IN_SOLO; - private final Boolean BROADCAST_SLOW_START_PROGRESS; - private final Long GRACE_PERIOD; - private final Long PEACE_PERIOD; - private final Long SURFACE_MOBS_FREE_PERIOD; - private final UHSound DEATH_SOUND; - - private UHCReloaded p; -// private TeamManager tm; - private Random random; - - private Boolean damagesEnabled = false; - private Boolean mobsOnSurface = false; - - private Set<String> players = new HashSet<>(); // Will be converted to UUID when a built-in API for name->UUID conversion will be available - private Set<UUID> alivePlayers = new HashSet<>(); -// private Set<UHTeam> aliveTeams = new HashSet<>(); - private Set<UUID> spectators = new HashSet<>(); - private Map<UUID, Location> deathLocations = new HashMap<>(); - - private Set<String> deadPlayersToBeResurrected = new HashSet<>(); // Same - - private Integer alivePlayersCount = 0; - private Integer aliveTeamsCount = 0; - - private Boolean gameWithTeams = true; - - // Used for the slow start. - private Boolean slowStartInProgress = false; - private Boolean slowStartTPFinished = false; - - private Boolean gameStarted = false; - private Boolean gameFinished = false; - private Integer episode = 0; - - private Teleporter teleporter = null; - - // Used to send a contextual error message in UHCommandManager, using only one exception, - // by checking the message. (Used in this.finishGame().) - public final static String FINISH_ERROR_NOT_STARTED = "Unable to finish the game: the game is not started"; - public final static String FINISH_ERROR_NOT_FINISHED = "Unable to finish the game: the game is not finished"; - - - public UHGameManager(UHCReloaded plugin) - { - this.p = plugin; -// this.tm = p.getTeamManager(); - - this.random = new Random(); - - - // Loads the config - - RANDOM_COLORS_IN_SOLO = UHConfig.TEAMS_OPTIONS.RANDOM_COLORS.get(); - - BROADCAST_SLOW_START_PROGRESS = UHConfig.START.SLOW.BROADCAST_PROGRESS.get(); - - GRACE_PERIOD = (long) Math.max(UHUtils.string2Time(UHConfig.START.GRACE_PERIOD.get(), 30), 15) * 20l; - PEACE_PERIOD = (long) UHUtils.string2Time(UHConfig.START.PEACE_PERIOD.get(), 0) * 20l; - SURFACE_MOBS_FREE_PERIOD = (long) UHUtils.string2Time(UHConfig.START.SURFACE_MOBS_FREE_PERIOD.get(), 900) * 20l; - - DEATH_SOUND = new UHSound(UHConfig.DEATH.ANNOUNCEMENTS.SOUND); - - START_GIVE_BANNER = UHConfig.TEAMS_OPTIONS.BANNER.GIVE.GIVE_IN_HOTBAR.get(); - START_PLACE_BANNER_SPAWN = UHConfig.TEAMS_OPTIONS.BANNER.GIVE.PLACE_ON_SPAWN.get(); - START_PLACE_BANNER_HEAD = UHConfig.TEAMS_OPTIONS.BANNER.GIVE.GIVE_IN_HEAD.get(); - } - - /** - * Initializes the environment before the start of the game. - */ - public void initEnvironment() - { - p.getServer().getWorlds().get(0).setGameRuleValue("doDaylightCycle", "false"); - p.getServer().getWorlds().get(0).setTime(6000L); - p.getServer().getWorlds().get(0).setStorm(false); - p.getServer().getWorlds().get(0).setDifficulty(Difficulty.HARD); - } - - /** - * Initializes the given player. - * - * - Teleportation to the default world's spawn point. - * - Max food level & health. - * - Scoreboard. - * - Fixed health score. - * - Spectate mode disabled. - * - Gamemode: creative (if permission "uh.build" granted) or adventure (else). - * - * @param player The player to initialize. - */ - public void initPlayer(final Player player) - { - if (UHConfig.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get()) - { - Location l = player.getWorld().getSpawnLocation().add(0.5, 0.5, 0.5); - if (!UHUtils.safeTP(player, l)) - { - player.teleport(l.add(0, 1, 0)); - } - } - - player.setFoodLevel(20); - player.setSaturation(20f); - player.setHealth(20d); - - p.getScoreboardManager().setScoreboardForPlayer(player); - - // Used to update the "health" objective, to avoid a null one. - // Launched later because else, the health is constantly set to 20, - // and this prevents the health score to be updated. - Bukkit.getScheduler().runTaskLater(p, () -> p.getScoreboardManager().updateHealthScore(player), 20L); - - // Disable the spectator mode if the game is not started. - p.getSpectatorsManager().setSpectating(player, false); - - // Resets the achievements - if (UHConfig.ACHIEVEMENTS.RESET_ACHIEVEMENTS_AT_STARTUP.get()) - { - player.removeAchievement(Achievement.OPEN_INVENTORY); - } - - // If the user has the permission to build before the game, he will probably needs - // the creative mode. - if (!player.hasPermission("uh.build")) - { - player.setGameMode(GameMode.ADVENTURE); - } - else - { - player.setGameMode(GameMode.CREATIVE); - } - } - - - /** - * Starts the game. - * - * - Teleports the teams - * - Changes the gamemode, reset the life, clear inventories, etc. - * - Launches the timer - * - * @param sender The player who launched the game. - * @param slow If true, the slow mode is enabled. With the slow mode, the players are, at - * first, teleported one by one with a configurable delay, and with the - * fly. Then, the fly is removed and the game starts. - * @param ignoreTeams If true, the players will be teleported in individual teleportation spots, - * just like without teams, even with teams. - * - * @throws IllegalStateException if the game is running. - */ - public void start(final CommandSender sender, final Boolean slow, Boolean ignoreTeams) throws IllegalStateException - { - if (isGameRunning()) - { - throw new IllegalStateException("The game is currently running!"); - } - - - /* ** Initialization of the teams ** */ - - alivePlayers.clear(); -// aliveTeams.clear(); - alivePlayersCount = 0; - aliveTeamsCount = 0; - -// // Stores the teams created on-the-fly, to unregister them if something bad happens. -// final Set<UHTeam> onTheFlyTeams = new HashSet<>(); -// -// // If there isn't any team, we add all players (startup spectators excluded) to a new solo team. -// if (tm.getTeams().isEmpty()) -// { -// gameWithTeams = false; -// -// Bukkit.getOnlinePlayers().stream().filter(player -> !spectators.contains(player.getUniqueId())).forEach(player -> -// { -// final UHTeam team = new UHTeam(player.getName(), RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); -// team.addPlayer(player, true); -// -// tm.addTeam(team); -// onTheFlyTeams.add(team); -// }); -// } -// -// // Else, every non-startup-spectator out of any team player is added to a solo team. -// else -// { -// gameWithTeams = true; -// -// Bukkit.getOnlinePlayers().stream() -// .filter(player -> !spectators.contains(player.getUniqueId())) -// .filter(player -> tm.getTeamForPlayer(player) == null) -// .forEach(player -> -// { -// // We need an unique name for the team. -// String teamName = player.getName(); -// while (tm.isTeamRegistered(teamName)) -// { -// teamName = player.getName() + " " + random.nextInt(1000000); -// } -// -// final UHTeam team = new UHTeam(teamName, RANDOM_COLORS_IN_SOLO ? TeamColor.RANDOM : null); -// -// team.addPlayer(player, true); -// -// tm.addTeam(team); -// onTheFlyTeams.add(team); -// }); -// } -// -// -// /* ** Initialization of the players ** */ -// -// tm.getTeams().forEach( -// team -> team.getPlayers().stream() -// .map(OfflinePlayer::getUniqueId) -// .filter(player -> !spectators.contains(player)) -// .forEach(player -> alivePlayers.add(player)) -// ); - - updateAliveCache(); - - - /* ** Spawns check ** */ - - Integer spawnsNeeded = ignoreTeams ? alivePlayersCount : aliveTeamsCount; - -// if (p.getSpawnsManager().getSpawnPoints().size() < spawnsNeeded) -// { -// if (sender instanceof Player) sender.sendMessage(""); -// sender.sendMessage(I.t("{ce}Unable to start the game: not enough teleportation spots.")); -// sender.sendMessage(I.t("{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to generate the missing spawns automatically.")); -// -// /// In the sentence: "Or click here to generate the spawns randomly." -// RawMessage.send(sender, new RawText(I.t("Or")) -// .then(" ") -// /// In the sentence: "Or click here to generate the spawns randomly." -// .then(I.t("click here")) -// .color(ChatColor.GREEN).style(ChatColor.BOLD) -// .command("/uh spawns generate random") -// .hover(new RawText("/uh spawns generate random")) -// .then(" ") -// /// In the sentence: "Or click here to generate the spawns randomly." -// .then(I.t("to generate the spawns randomly.")).color(ChatColor.WHITE) -// .build() -// ); -// -// // We clears the teams created on-the-fly -// onTheFlyTeams.forEach(team -> tm.removeTeam(team, true)); -// -// aliveTeamsCount = 0; -// alivePlayersCount = 0; -// -// return; -// } - - - /* ** MOTD (now the game WILL start) ** */ - - p.getMOTDManager().updateMOTDDuringStart(); - - -// /* ** Removes the teams action bar (if any) ** */ -// if (UHConfig.BEFORE_START.TEAM_IN_ACTION_BAR.get()) -// { -// tm.getTeams().stream() -// .flatMap(team -> team.getPlayers().stream()) -// .forEach(player -> ActionBar.removeMessage(player.getUniqueId(), true)); -// } - - - /* ** Initialization of the spectator mode ** */ - - Bukkit - .getOnlinePlayers() - .forEach(player -> p.getSpectatorsManager().setSpectating(player, spectators.contains(player.getUniqueId()))); - - - /* ** Teleportation ** */ - - teleporter = new Teleporter(); - - List<Location> spawnPoints = new ArrayList<>(); // (p.getSpawnsManager().getSpawnPoints()); - Collections.shuffle(spawnPoints); - -// Queue<Location> unusedTP = new ArrayDeque<>(spawnPoints); -// -// tm.getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> -// { -// if (!ignoreTeams && gameWithTeams) -// { -// final Location teamSpawn = unusedTP.poll(); -// final Cage cage = Cage.createInstanceForTeamIfEnabled(team, teamSpawn); -// -// p.getDynmapIntegration().showSpawnLocation(team, teamSpawn); -// -// team.getPlayersUUID().forEach(player -> -// { -// teleporter.setSpawnForPlayer(player, teamSpawn); -// if (cage != null) teleporter.setCageForPlayer(player, cage); -// }); -// } -// else -// { -// team.getPlayersUUID().forEach(player -> -// { -// final Location playerSpawn = unusedTP.poll(); -// final Cage cage = Cage.createInstanceForTeamIfEnabled(team, playerSpawn); -// -// teleporter.setSpawnForPlayer(player, playerSpawn); -// if (cage != null) teleporter.setCageForPlayer(player, cage); -// -// p.getDynmapIntegration().showSpawnLocation(Bukkit.getOfflinePlayer(player), playerSpawn); -// }); -// } -// }); - - if (slow) - { - slowStartInProgress = true; - slowStartTPFinished = false; - - // The players are frozen during the start (if cages are not used). - if (!UHConfig.START.SLOW.CAGES.ENABLED.get()) - p.getFreezer().setGlobalFreezeState(true, false); - - // A simple information, because this start is slower (yeah, Captain Obvious here) - p.getServer().broadcastMessage(I.t("{lightpurple}Teleportation in progress... Please wait.")); - - teleporter.whenTeleportationOccurs(new Callback<UUID>() - { - private int teleported = 0; - private final int total = alivePlayersCount; - - @Override - public void call(UUID uuid) - { - teleported++; - - if (BROADCAST_SLOW_START_PROGRESS) - { - /// Displayed in the action bar while the slow teleportation occurs. - final String message = I.t("{lightpurple}Teleporting... {gray}({0}/{1})", teleported, total); - for (Player player : Bukkit.getOnlinePlayers()) - { - ActionBar.sendPermanentMessage(player, message); - } - } - } - }); - } - - teleporter - .whenTeleportationSuccesses(uuid -> - { - final Player player = Bukkit.getPlayer(uuid); - - if (slow) - { - sender.sendMessage(I.t("{gray}Player {0}{gray} teleported.", player.getName())); - - if (!UHConfig.START.SLOW.CAGES.ENABLED.get()) - { - RunTask.nextTick(() -> - { - player.setAllowFlight(true); - player.setFlying(true); - }); - } - } - - if (UHConfig.START.SLOW.CAGES.ENABLED.get()) - player.setGameMode(GameMode.ADVENTURE); - else - player.setGameMode(GameMode.SURVIVAL); - - resetPlayer(player); - - player.getActivePotionEffects().stream().map(PotionEffect::getType).forEach(player::removePotionEffect); - player.setCompassTarget(player.getWorld().getSpawnLocation()); - }) - - .whenTeleportationFails(uuid -> sender.sendMessage(I.t("{ce}Cannot teleport player {0}!", Bukkit.getPlayer(uuid).getName()))) - - .whenTeleportationEnds(uuids -> - { - if (slow) - { - slowStartTPFinished = true; - - try - { - sender.sendMessage(I.t("{cs}All teams are teleported.")); - RawMessage.send(sender, new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) - .hover(new RawText(I.t("Click here to start the game"))) - .command("/uh start") - ); - } - catch (NullPointerException ignored) {} - - if (BROADCAST_SLOW_START_PROGRESS) - { - /// Displayed in the action bar when the slow teleportation is finished but the game not started. - String message = I.t("{lightpurple}Teleportation complete. {gray}The game will start soon..."); - Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, message)); - } - } - else - { - startEnvironment(); - startTimer(); - scheduleDamages(); - sendStartupProTips(); - finalizeStart(); - } - }) - - .startTeleportationProcess(slow); - } - - /** - * Finalizes the start of the game, with the slow mode. Removes the fly and ends the start - * (environment, timer...) - * - * @param sender The sender of the {@code /uh start slow go} command - */ - public void finalizeStartSlow(CommandSender sender) - { - if (!slowStartInProgress) - { - sender.sendMessage(I.t("{ce}Please execute {cc}/uh start slow:true{ce} before.")); - return; - } - - if (!slowStartTPFinished) - { - sender.sendMessage(I.t("{ce}Please wait while the players are teleported.")); - return; - } - - // The freeze is removed. - if (!UHConfig.START.SLOW.CAGES.ENABLED.get()) - { - p.getFreezer().setGlobalFreezeState(false, false); - - // The fly is removed to everyone - p.getServer().getOnlinePlayers().stream() - .filter(player -> alivePlayers.contains(player.getUniqueId())) - .forEach(player -> - { - player.setFlying(false); - player.setAllowFlight(false); - } - ); - } - - // The action bar is cleared - if (BROADCAST_SLOW_START_PROGRESS) - { - Bukkit.getOnlinePlayers().forEach(ActionBar::removeMessage); - } - - // The environment is initialized, the game is started. - startEnvironment(); - startTimer(); - scheduleDamages(); - sendStartupProTips(); - finalizeStart(); - - slowStartInProgress = false; - } - - /** - * Initializes the environment at the beginning of the game. - */ - private void startEnvironment() - { - World overworld = UHUtils.getOverworld(); - - if (overworld != null) - { - overworld.setGameRuleValue("doDaylightCycle", (UHConfig.DAYLIGHT_CYCLE.DO.get()).toString()); - overworld.setTime(UHConfig.DAYLIGHT_CYCLE.TIME.get()); - overworld.setStorm(false); - } - - for (World world : Bukkit.getWorlds()) - { - world.setGameRuleValue("keepInventory", Boolean.FALSE.toString()); // Just in case... - world.setGameRuleValue("naturalRegeneration", (UHConfig.GAMEPLAY_CHANGES.NATURAL_REGENERATION.get()).toString()); - world.setDifficulty(Difficulty.HARD); - } - } - - /** - * Launches the timer by launching the task that updates the scoreboard every second. - */ - private void startTimer() - { - if (UHConfig.EPISODES.ENABLED.get()) - { - this.episode = 1; - - // An empty string is used for the name of the main timer, because - // such a name can't be used by players. - Timer mainTimer = new Timer(""); - mainTimer.setDuration(this.getEpisodeLength()); - -// p.getTimerManager().registerMainTimer(mainTimer); - - mainTimer.start(); - } - } - - /** - * Enables the damages 30 seconds (600 ticks) later, the PvP after if needed, and the mobs spawns. - */ - private void scheduleDamages() - { - // When the grace period is over, damages are enabled. - RunTask.later(() -> { - damagesEnabled = true; - - if (UHConfig.START.BROADCAST_GRACE_END.get()) - { - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); - } - }, GRACE_PERIOD); - - // When the peace period is over, PVP is enabled - if (PEACE_PERIOD > 0) - { - Bukkit.getWorlds().forEach(world -> world.setPVP(false)); - - RunTask.later(() -> - { - Bukkit.getWorlds().forEach(world -> world.setPVP(true)); - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); - }, PEACE_PERIOD); - } - - // Allows mobs to spawn on the surface after the mobs-free period - RunTask.later(() -> mobsOnSurface = true, SURFACE_MOBS_FREE_PERIOD); - } - - /** - * Sends two ProTips: - * - about the team chat, to all players, 20 seconds after the beginning of the game; - * - about the invincibility, 5 seconds after the beginning of the game. - */ - private void sendStartupProTips() - { - // Team chat - 20 seconds after - if (isGameWithTeams()) - { - Bukkit.getScheduler().runTaskLater(p, () -> getOnlineAlivePlayers().forEach(ProTips.USE_T_COMMAND::sendTo), 400L); - } - - // Invincibility - 5 seconds after - Bukkit.getScheduler().runTaskLater(p, () -> getOnlineAlivePlayers().forEach(ProTips.STARTUP_INVINCIBILITY::sendTo), 100L); - } - - /** - * Changes the state of the game. Also, forces the global freeze start to false, to avoid toggle - * bugs (like inverted state). - */ - private void finalizeStart() - { - p.getFreezer().setGlobalFreezeState(false); - -// teleporter.cleanup(); - - gameStarted = true; - gameFinished = false; - - updateAliveCache(); - - // Survival gamemode for everyone - p.getServer().getOnlinePlayers().stream() - .filter(player -> alivePlayers.contains(player.getUniqueId())) - .forEach(player -> - { - player.setGameMode(GameMode.SURVIVAL); - resetPlayer(player); - } - ); - - // Fires the event - p.getServer().getPluginManager().callEvent(new UHGameStartsEvent()); - } - - /** - * Reinitializes a player (health, XP, inventory...). - * - * @param player The player - */ - private void resetPlayer(Player player) - { - player.setHealth(20D); - player.setFoodLevel(20); - player.setSaturation(20); - player.getInventory().clear(); - player.getInventory().setArmorContents(null); - player.setExp(0L); - player.setLevel(0); - player.closeInventory(); - } - - /** - * @return true if the slow start is in progress. - */ - public boolean isSlowStartInProgress() - { - return slowStartInProgress; - } - - /** - * Updates the cached values of the alive players and teams. - */ - public void updateAliveCache() - { -// // Alive teams -// aliveTeams.clear(); -// for (UHTeam t : tm.getTeams()) -// { -// for (UUID pid : t.getPlayersUUID()) -// { -// if (!this.isPlayerDead(pid)) aliveTeams.add(t); -// } -// } -// -// // Counters -// this.alivePlayersCount = alivePlayers.size(); -// this.aliveTeamsCount = aliveTeams.size(); -// -// if (isGameRunning()) -// p.getMOTDManager().updateMOTDDuringGame(); - } - - /** - * Updates the cached values of the alive players and teams. - * - * @deprecated Use {@link #updateAliveCache()} instead. - */ - @Deprecated - public void updateAliveCounters() { updateAliveCache(); } - - - /** - * Shifts an episode. - * - * @param shifter The player who shifts the episode, an empty string if the episode is shifted - * because the timer is up. - */ - public void shiftEpisode(String shifter) - { - if (UHConfig.EPISODES.ENABLED.get()) - { - this.episode++; - - final EpisodeChangedEvent.EpisodeChangedCause cause; - if (shifter == null || shifter.equals("")) cause = EpisodeChangedEvent.EpisodeChangedCause.FINISHED; - else cause = EpisodeChangedEvent.EpisodeChangedCause.SHIFTED; - - // Restarts the timer. - // Useless for a normal start (restarted in the event), but needed if the episode was shifted. - if (cause == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) - { -// p.getTimerManager().getMainTimer().start(); - } - -// p.getServer().getPluginManager().callEvent(new EpisodeChangedEvent(episode, cause, shifter)); - } - } - - /** - * Shift an episode because the timer is up. - */ - public void shiftEpisode() - { - shiftEpisode(""); - } - - - /** - * Resurrects an offline player. The tasks that needed to be executed when the player is online - * are delayed and executed when the player joins. - * - * @param playerName The name of the player to resurrect - * - * @return true if the player was dead, false otherwise. - */ - public boolean resurrect(String playerName) - { - Player playerOnline = Bukkit.getPlayer(playerName); - - if (playerOnline != null && playerOnline.isOnline()) - { - return resurrectPlayerOnlineTask(playerOnline); - } - else - { - // We checks if the player was a player - if (!this.players.contains(playerName)) - { - return false; - } - } - - // So, now, we are sure that the player is really offline. - // The task needed to be executed will be executed when the player join. - this.deadPlayersToBeResurrected.add(playerName); - - return true; - } - - /** - * The things that have to be done in order to resurrect the players and that needs the player - * to be online. - * - * @param player The player to resurrect - * - * @return true if the player was dead, false otherwise. - */ - public boolean resurrectPlayerOnlineTask(Player player) - { - if (alivePlayers.contains(player.getUniqueId())) - { - return false; - } - - // Player registered as alive - alivePlayers.add(player.getUniqueId()); - updateAliveCache(); - - // This method can be used to add a player after the game start. - players.add(player.getName()); - - // Event - p.getServer().getPluginManager().callEvent(new PlayerResurrectedEvent(player)); - - return true; - } - - /** - * Returns true if a player need to be resurrected. - * - * @param player - * - * @return - */ - public boolean isDeadPlayersToBeResurrected(Player player) - { - return deadPlayersToBeResurrected.contains(player.getName()); - } - - /** - * Registers a player as resurrected. - * - * @param player - */ - public void markPlayerAsResurrected(Player player) - { - deadPlayersToBeResurrected.remove(player.getName()); - } - - - /** - * This method saves the location of the death of a player. - * - * @param player - * @param location - */ - public void addDeathLocation(Player player, Location location) - { - deathLocations.put(player.getUniqueId(), location); - } - - /** - * This method removes the stored death location. - * - * @param player - */ - public void removeDeathLocation(Player player) - { - deathLocations.remove(player.getUniqueId()); - } - - /** - * This method returns the stored death location. - * - * @param player The player to retrieve the death location of. - * - * @return The death location, or {@code null} if not defined. - */ - public Location getDeathLocation(Player player) - { - if (deathLocations.containsKey(player.getUniqueId())) - { - return deathLocations.get(player.getUniqueId()); - } - - return null; - } - - /** - * This method returns true if a death location is stored for the given player. - * - * @param player The player to check the death location of. - * - * @return {@code true} if a death location is set. - */ - public boolean hasDeathLocation(Player player) - { - return deathLocations.containsKey(player.getUniqueId()); - } - - /** - * Adds a spectator. When the game is started, spectators are ignored and the spectator mode is - * enabled if SpectatorPlus is present. - * - * @param player The player to register as a spectator. - */ - public void addStartupSpectator(OfflinePlayer player) - { - spectators.add(player.getUniqueId()); -// tm.removePlayerFromTeam(player); - } - - /** - * Removes a spectator. - * - * @param player The spectator to remove. - */ - public void removeStartupSpectator(OfflinePlayer player) - { - spectators.remove(player.getUniqueId()); - } - - /** - * Returns a list of the current registered spectators. - * - * This returns only a list of the <em>initial</em> spectators. Use {@link #getAlivePlayers()} - * to get the alive players, and remove the elements of this list from the online players to get - * the spectators. - * - * @return The initial spectators. - */ - public HashSet<String> getStartupSpectators() - { - HashSet<String> spectatorNames = new HashSet<>(); - - for (UUID id : spectators) - { - final OfflinePlayer player = OfflinePlayersLoader.getOfflinePlayer(id); - final String playerName = player.getName(); - - if (playerName != null) - spectatorNames.add(playerName); - else - /// Spectators list item if the nick cannot be found - spectatorNames.add(I.t("Unknown player with UUID {0}", player.getUniqueId())); - } - - return spectatorNames; - } - - /** - * @return true if the game was launched and is not finished. - */ - public boolean isGameRunning() - { - return gameStarted && !gameFinished; - } - - /** - * @return true if the game is started. - */ - public boolean isGameStarted() - { - return gameStarted; - } - - /** - * @return true if the game is finished. - */ - public boolean isGameFinished() - { - return gameFinished; - } - - /** - * Registers the state of the game. - * - * @param finished If true, the game will be marked as finished. - */ - public void setGameFinished(boolean finished) - { - gameFinished = finished; - } - - /** - * @return true if the game is a game with teams, and false if the game is a solo game. - */ - public boolean isGameWithTeams() - { - return gameWithTeams; - } - - /** - * @return true if damages are enabled. Damages are enabled 30 seconds after the beginning of - * the game. - */ - public boolean isTakingDamage() - { - return damagesEnabled; - } - - public boolean isSurfaceSpawnEnabled() - { - return mobsOnSurface; - } - - /** - * Returns true if the given player is dead. - * - * @param player The player. - * - * @return True if the player is dead. - */ - public boolean isPlayerDead(Player player) - { - return !alivePlayers.contains(player.getUniqueId()); - } - - /** - * Returns true if the given player is dead. - * - * @param player The UUID of the player. - * - * @return True if the player is dead. - */ - public boolean isPlayerDead(UUID player) - { - return !alivePlayers.contains(player); - } - - /** - * Registers a player as dead. - * - * @param player The player to mark as dead. - */ - public void addDead(Player player) - { - alivePlayers.remove(player.getUniqueId()); - updateAliveCache(); - } - - /** - * Registers a player as dead. - * - * @param player The UUID of the player to mark as dead. - */ - public void addDead(UUID player) - { - alivePlayers.remove(player); - updateAliveCache(); - } - - - /** - * Broadcasts the winner(s) of the game and launches some fireworks - * - * @throws IllegalStateException if the game is not started or not finished (use the message to - * distinguish these cases, {@link #FINISH_ERROR_NOT_STARTED} or - * {@link #FINISH_ERROR_NOT_FINISHED}). - */ - public void finishGame() - { - if (!p.getGameManager().isGameStarted()) - { - throw new IllegalStateException(FINISH_ERROR_NOT_STARTED); - } - - if (p.getGameManager().getAliveTeamsCount() != 1) - { - throw new IllegalStateException(FINISH_ERROR_NOT_FINISHED); - } - - // There's only one team. -// UHTeam winnerTeam = p.getGameManager().getAliveTeams().iterator().next(); -// Set<OfflinePlayer> listWinners = winnerTeam.getPlayers(); -// -// if (UHConfig.FINISH.MESSAGE.get()) -// { -// if (isGameWithTeams()) -// { -// StringBuilder winners = new StringBuilder(); -// int j = 0; -// -// for (OfflinePlayer winner : listWinners) -// { -// if (j != 0) -// { -// if (j == listWinners.size() - 1) -// { -// /// The "and" in the winners players list (like "player1, player2 and player3"). -// winners.append(" ").append(I.tc("winners_list", "and")).append(" "); -// } -// else -// { -// winners.append(", "); -// } -// } -// -// winners.append(winner.getName()); -// j++; -// } -// -// p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", winners.toString(), winnerTeam.getDisplayName())); -// } -// else -// { -// p.getServer().broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", winnerTeam.getName())); -// } -// } -// -// if (UHConfig.FINISH.TITLE.get()) -// { -// final String title; -// final String subtitle; -// -// if (isGameWithTeams()) -// { -// /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). -// title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); -// /// The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). -// subtitle = I.t("{green}This team wins the game!", winnerTeam.getDisplayName()); -// } -// else -// { -// /// The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). -// title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); -// /// The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). -// subtitle = I.t("{green}wins the game!", winnerTeam.getDisplayName()); -// } -// -// Titles.broadcastTitle(5, 142, 21, title, subtitle); -// } -// -// if (UHConfig.FINISH.FIREWORKS.ENABLED.get()) -// { -// new FireworksOnWinnersTask(listWinners).runTaskTimer(p, 0L, 15L); -// } - } - - /** - * Returns the names of the players of this game. - * - * @return The set. - */ - public Set<String> getPlayers() - { - return players; - } - - /** - * Returns a list of the currently alive teams. - * - * @return The set. - */ -// public Set<UHTeam> getAliveTeams() -// { -// return aliveTeams; -// } - - /** - * Returns a list of the currently alive players. - * - * @return The set. - */ - public Set<OfflinePlayer> getAlivePlayers() - { - return alivePlayers.stream() - .map(id -> p.getServer().getOfflinePlayer(id)) - .collect(Collectors.toCollection(HashSet::new)); - } - - /** - * Returns a list of the currently alive and online players. - * - * @return The list. - */ - public HashSet<Player> getOnlineAlivePlayers() - { - return alivePlayers.stream() - .map(id -> p.getServer().getPlayer(id)) - .filter(Objects::nonNull) - .filter(Player::isOnline) - .collect(Collectors.toCollection(HashSet::new)); - } - - /** - * @return the death sound, or null if no death sound is registered. - */ - public UHSound getDeathSound() - { - return DEATH_SOUND; - } - - /** - * @return the length of one episode, in seconds. - */ - public Integer getEpisodeLength() - { - return UHUtils.string2Time(UHConfig.EPISODES.LENGTH.get(), 20*60); - } - - /** - * @return the (cached) number of alive players. - */ - public Integer getAlivePlayersCount() - { - return alivePlayersCount; - } - - /** - * @return the (cached) number of alive teams. - */ - public Integer getAliveTeamsCount() - { - return aliveTeamsCount; - } - - /** - * @return the number of the current episode. - */ - public Integer getEpisode() - { - return episode; - } - - - /** - * @return the teleporter instance used to start the game, containing the spawn points of each - * player. - */ - public Teleporter getTeleporter() - { - return teleporter; - } - - - - /* *** Deprecated methods *** */ - - /** - * Adds a spectator. When the game is started, spectators are ignored and the spectator mode is - * enabled if SpectatorPlus is present. - * - * @param player The player to register as a spectator. - * - * @deprecated Use {@link #addStartupSpectator(OfflinePlayer)} instead. - */ - @Deprecated - public void addSpectator(Player player) - { - addStartupSpectator(player); - } - - /** - * Removes a spectator. - * - * @param player The player to remove. - * - * @deprecated Use {@link #removeStartupSpectator(OfflinePlayer)} instead. - */ - @Deprecated - public void removeSpectator(Player player) - { - removeStartupSpectator(player); - } - - /** - * Returns a list of the current registered spectators. - * - * This returns only a list of the <em>initial</em> spectators. Use {@link #getAlivePlayers()} - * to get the alive players, and remove the elements of this list from the online players to get - * the spectators. - * - * @return The initial spectators. - * @deprecated Use {@link #getStartupSpectators()} instead. - */ - @Deprecated - public HashSet<String> getSpectators() - { - return getStartupSpectators(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java index f02a54a..f94c1d6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java @@ -31,8 +31,8 @@ */ package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import fr.zcraft.zteams.ZTeam; +import fr.zcraft.zteams.colors.ColorsUtils; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 9d45329..8d46038 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -47,6 +47,7 @@ import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.Titles; import org.bukkit.Bukkit; @@ -78,6 +79,8 @@ public class BorderModule extends UHModule private MapShape mapShape = null; private WorldBorder border = null; + private WorldBorderDependency worldBorderDependency = null; + /** * The lines in the sidebar, calculated once for every player. Caching purposes. */ @@ -86,6 +89,8 @@ public class BorderModule extends UHModule @Override public void onEnable() { + worldBorderDependency = ZLib.loadComponent(WorldBorderDependency.class); + mapShape = Config.SHAPE.get(); final World world = UHCReloaded.get().getWorld(World.Environment.NORMAL); @@ -193,6 +198,11 @@ public WorldBorder getBorderProxy() return border; } + public WorldBorderDependency getWorldBorderDependency() + { + return worldBorderDependency; + } + /** * Checks if a given location is inside the border with the given diameter. * The check is performed for a circular or squared border, following the configuration. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java index b31b51c..9553ae1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHWorldBorderIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java @@ -30,29 +30,23 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.integration; +package eu.carrade.amaury.UHCReloaded.modules.core.border; import com.wimbli.WorldBorder.WorldBorder; +import fr.zcraft.zlib.external.ExternalPluginComponent; import fr.zcraft.zlib.tools.PluginLogger; -import org.bukkit.Bukkit; -import org.bukkit.plugin.Plugin; -public class UHWorldBorderIntegration +public class WorldBorderDependency extends ExternalPluginComponent<WorldBorder> { - private WorldBorder wb = null; - - public UHWorldBorderIntegration() + public WorldBorderDependency() { - Plugin wbTest = Bukkit.getServer().getPluginManager().getPlugin("WorldBorder"); - if (wbTest == null || !wbTest.isEnabled()) - { - PluginLogger.warning("WorldBorder is not present, so the integration was disabled."); - return; - } - - this.wb = (WorldBorder) wbTest; + super("WorldBorder"); + } + @Override + protected void onLoad() + { try { Class.forName("com.wimbli.WorldBorder.BorderData"); @@ -63,20 +57,15 @@ public UHWorldBorderIntegration() PluginLogger.warning("WorldBorder is available, but the version you are using is too old."); PluginLogger.warning("This plugin is tested and works with WorldBorder 1.8.0 or later."); - this.wb = null; + setEnabled(false); return; } PluginLogger.info("Successfully hooked into WorldBorder."); } - public boolean isWBIntegrationEnabled() - { - return !(this.wb == null); - } - public WorldBorder getWorldBorder() { - return wb; + return get(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java index f48b33a..c1e771e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -33,8 +33,9 @@ import com.wimbli.WorldBorder.BorderData; import com.wimbli.WorldBorder.Config; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Location; import org.bukkit.World; @@ -67,10 +68,9 @@ public BrettflanWorldBorder(final World world) { this.world = world; - com.wimbli.WorldBorder.WorldBorder wb = UHCReloaded.get().getWorldBorderIntegration().getWorldBorder(); - if (wb != null) + if (UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - border = wb.getWorldBorder(world.getName()); + border = UR.module(BorderModule.class).getWorldBorderDependency().getWorldBorder().getWorldBorder(world.getName()); if (border == null) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java index ed6887c..dcb969d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java @@ -31,9 +31,10 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import org.bukkit.Location; import org.bukkit.World; @@ -175,7 +176,7 @@ public static WorldBorder getInstance(final World world, final WorldBorderMotor // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). if (shape == MapShape.CIRCULAR) { - if (UHCReloaded.get().getWorldBorderIntegration().isWBIntegrationEnabled()) + if (UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { return new BrettflanWorldBorder(world); } @@ -186,7 +187,7 @@ public static WorldBorder getInstance(final World world, final WorldBorderMotor } else { - if (motor == WorldBorderMotor.VANILLA || !UHCReloaded.get().getWorldBorderIntegration().isWBIntegrationEnabled()) + if (motor == WorldBorderMotor.VANILLA || !UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { return new VanillaWorldBorder(world); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java index 54c5527..081ff97 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java @@ -36,13 +36,13 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.ColorsUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.gui.ExplorerGui; import fr.zcraft.zlib.components.gui.Gui; import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zteams.colors.ColorsUtils; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.inventory.ClickType; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java similarity index 76% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java index 1b614a7..4488f91 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHSpectatorPlusIntegration.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java @@ -30,38 +30,31 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.integration; +package eu.carrade.amaury.UHCReloaded.modules.core.spectators; import com.pgcraft.spectatorplus.SpectateAPI; import com.pgcraft.spectatorplus.SpectatorPlus; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import fr.zcraft.zlib.external.ExternalPluginComponent; import fr.zcraft.zlib.tools.PluginLogger; -import org.bukkit.Bukkit; -import org.bukkit.plugin.Plugin; -public class UHSpectatorPlusIntegration +public class SpectatorPlusDependency extends ExternalPluginComponent<SpectatorPlus> { - private SpectatorPlus sp = null; private SpectateAPI spAPI = null; - public UHSpectatorPlusIntegration() + public SpectatorPlusDependency() { - Plugin spTest = Bukkit.getServer().getPluginManager().getPlugin("SpectatorPlus"); - if (spTest == null || !spTest.isEnabled()) - { - UHCReloaded.get().getLogger().warning("SpectatorPlus is not present, so the integration was disabled."); - return; - } - - this.sp = (SpectatorPlus) spTest; - + super("SpectatorPlus"); + } + @Override + public void onLoad() + { try { Class.forName("com.pgcraft.spectatorplus.SpectateAPI"); - if (sp.getDescription().getVersion().equals("1.9.1")) + if (get().getDescription().getVersion().equals("1.9.1")) { // The API of SpectatorPlus 1.9.1 was not working. throw new ClassNotFoundException(); @@ -72,7 +65,7 @@ public UHSpectatorPlusIntegration() PluginLogger.warning("SpectatorPlus is available, but the version you are using is too old."); PluginLogger.warning("This plugin is tested and works with SpectatorPlus 1.9.2 or later. The SpectateAPI is needed."); - this.sp = null; + setEnabled(false); return; } @@ -80,7 +73,7 @@ public UHSpectatorPlusIntegration() // All is OK, let's integrate. try { - spAPI = sp.getAPI(); + spAPI = get().getAPI(); PluginLogger.info("Successfully hooked into SpectatorPlus."); } @@ -90,20 +83,13 @@ public UHSpectatorPlusIntegration() catch (Throwable e) { PluginLogger.error("Cannot hook into SpectatorPlus, is this version compatible?", e); - - spAPI = null; - sp = null; + setEnabled(false); } } - public boolean isSPIntegrationEnabled() - { - return !(this.sp == null); - } - public SpectatorPlus getSP() { - return this.sp; + return get(); } public SpectateAPI getSPAPI() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java index 3eb4e68..ee76141 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java @@ -73,6 +73,7 @@ public class SpectatorsModule extends UHModule { private SpectatorsManager manager; + private SpectatorPlusDependency spectatorPlusDependency; /** * Lists players allowed to spectate. Also used for initial spectators: players who will diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java index bce76f4..6095dbe 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java @@ -31,36 +31,32 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import com.pgcraft.spectatorplus.SpectateAPI; import org.bukkit.entity.Player; /** * Spectators managed through the SpectatorsPlus Bukkit plugin by PGMann and AmauryPi. - * - * TODO fix integration */ public class SPlusSpectatorsManager extends SpectatorsManager { - private UHCReloaded p; + private final SpectateAPI api; - public SPlusSpectatorsManager() + public SPlusSpectatorsManager(final SpectateAPI api) { - p = UHCReloaded.get(); + + this.api = api; } @Override public void setSpectating(final Player player, final boolean spectating) { - if (player != null && p.getSpectatorPlusIntegration().isSPIntegrationEnabled()) - p.getSpectatorPlusIntegration().getSPAPI().setSpectating(player, spectating); + if (player != null) api.setSpectating(player, spectating); } @Override - public boolean isSpectating(Player player) + public boolean isSpectating(final Player player) { - return player != null - && p.getSpectatorPlusIntegration().isSPIntegrationEnabled() - && p.getSpectatorPlusIntegration().getSPAPI().isSpectator(player); + return player != null && api.isSpectator(player); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java index 79824db..403b012 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java @@ -31,7 +31,8 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorPlusDependency; +import fr.zcraft.zlib.core.ZLib; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -43,6 +44,13 @@ */ public abstract class SpectatorsManager { + private final static SpectatorPlusDependency spectatorPlusDependency; + + static + { + spectatorPlusDependency = ZLib.loadComponent(SpectatorPlusDependency.class); + } + /** * Changes the spectating mode of a player. * @@ -90,9 +98,8 @@ public boolean isSpectating(final UUID playerID) */ public static SpectatorsManager getInstance() { - // TODO re-add SP integration - if (false && UHCReloaded.get().getSpectatorPlusIntegration().isSPIntegrationEnabled()) - return new SPlusSpectatorsManager(); + if (spectatorPlusDependency.isEnabled()) + return new SPlusSpectatorsManager(spectatorPlusDependency.getSPAPI()); else return new VanillaSpectatorsManager(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java index 9e299d1..17793b9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java @@ -33,7 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.other.about; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index 87c4e4c..91e5baa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -43,7 +43,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.events.FutureEventHandler; import fr.zcraft.zlib.components.events.WrappedEvent; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java deleted file mode 100644 index bce0a1e..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/UHCommandExecutor.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.GlobalMessageCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.TeamMessageCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.ToggleChatCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.UHRootCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommandExecutor; - - -public class UHCommandExecutor extends AbstractCommandExecutor -{ - public UHCommandExecutor(UHCReloaded p) - { - super(p); - - registerCommand(new UHRootCommand(p)); // /uh - - registerCommand(new TeamMessageCommand(p)); // /t - registerCommand(new GlobalMessageCommand(p)); // /g - registerCommand(new ToggleChatCommand(p)); // /togglechat - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java deleted file mode 100644 index 179d584..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/GlobalMessageCommand.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -/** - * This command, /g <message>, is used to send a global message while being in - * the locked team-chat. - */ -@Command (name = "g", noPermission = true) -public class GlobalMessageCommand extends AbstractCommand -{ - private UHCReloaded p; - - public GlobalMessageCommand(UHCReloaded p) - { - this.p = p; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - - // /t - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - StringBuilder message = new StringBuilder(); - for (String arg : args) - { - message.append(arg).append(" "); - } - -// p.getTeamChatManager().sendGlobalMessage((Player) sender, message.toString()); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - - @Override - public List<String> help(CommandSender sender) - { - /// Usage of the /g and /t commands - return Collections.singletonList(I.t("{ce}Usage: /{0} <message>", "g")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return null; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java deleted file mode 100644 index 87a66a2..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/TeamMessageCommand.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - - -/** - * This command, /t <message>, is used to send a team-message. - */ -@Command (name = "t", noPermission = true) -public class TeamMessageCommand extends AbstractCommand -{ - private UHCReloaded p; - - public TeamMessageCommand(UHCReloaded p) - { - this.p = p; - } - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - - // /t - if (args.length == 0) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); - } - - StringBuilder message = new StringBuilder(); - for (final String arg : args) - { - message.append(arg).append(" "); - } - -// p.getTeamChatManager().sendTeamMessage((Player) sender, message.toString()); - } - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * @return A list of suggestions. - */ - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - - @Override - public List<String> help(CommandSender sender) - { - /// Usage of the /g and /t commands - return Collections.singletonList(I.t("{ce}Usage: /{0} <message>", "t")); - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return null; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java deleted file mode 100644 index 9bec7c7..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/ToggleChatCommand.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - - -/** - * This command, /togglechat, is used to toggle the chat between the global chat and - * the team chat. - */ -@Command (name = "togglechat", noPermission = true) -public class ToggleChatCommand extends AbstractCommand -{ - private UHCReloaded p; - - public ToggleChatCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (!(sender instanceof Player)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); - } - -// // /togglechat -// if (args.length == 0) -// { -// if (p.getTeamChatManager().toggleChatForPlayer((Player) sender)) -// { -// sender.sendMessage(I.t("{cs}You are now chatting with your team only.")); -// } -// else -// { -// sender.sendMessage(I.t("{cs}You are now chatting with everyone.")); -// } -// } -// -// // /togglechat <another team> -// else -// { -// String teamName = UHUtils.getStringFromCommandArguments(args, 0); -// UHTeam team = p.getTeamManager().getTeam(teamName); -// -// if (team != null) -// { -// if (p.getTeamChatManager().toggleChatForPlayer((Player) sender, team)) -// { -// sender.sendMessage(I.t("{cs}You are now chatting with the team {0}{cs}.", team.getDisplayName())); -// } -// } -// else -// { -// sender.sendMessage(I.t("{ce}This team does not exists.")); -// } -// } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - if (sender instanceof Player && sender.hasPermission("uh.teamchat.others")) - { - ArrayList<String> teamNames = new ArrayList<>(); - -// for (UHTeam team : p.getTeamManager().getTeams()) -// { -// teamNames.add(team.getName()); -// } - - return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), teamNames, args.length - 1); - } - - else return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return null; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java deleted file mode 100644 index 719ca40..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/UHRootCommand.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.uh.*; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import org.bukkit.command.CommandSender; - -import java.util.List; - - -@Command (name = "uh") -public class UHRootCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHRootCommand(UHCReloaded plugin) - { - p = plugin; - - // Misc - registerSubCommand(new UHFinishCommand(p)); - registerSubCommand(new UHFreezeCommand(p)); - registerSubCommand(new UHInfosCommand(p)); - registerSubCommand(new UHRulesCommand(p)); - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return null; - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java deleted file mode 100644 index 328df5d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/categories/Category.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.categories; - -import fr.zcraft.zlib.components.i18n.I; - - -public enum Category -{ - GAME(I.t("{aqua}------ Game-related commands ------")), - BUGS(I.t("{aqua}------ Bugs-related commands ------")), - MISC(I.t("{aqua}------ Miscellaneous commands ------")); - - - private String title; - - Category(String title) - { - this.title = title; - } - - public String getTitle() - { - return title; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java deleted file mode 100644 index c1627bb..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFinishCommand.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; - -import java.util.Collections; -import java.util.List; - -/** - * This commands broadcast the winner(s) of the game and sends some fireworks at these players. - * It fails if there is more than one team alive. - * - * Usage: /uh finish - */ -@Command (name = "finish") -public class UHFinishCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHFinishCommand(UHCReloaded plugin) - { - this.p = plugin; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - try - { - p.getGameManager().finishGame(); - - } - catch (IllegalStateException e) - { - switch (e.getMessage()) - { - case UHGameManager.FINISH_ERROR_NOT_STARTED: - sender.sendMessage(I.t("{ce}The game is not started!")); - break; - - case UHGameManager.FINISH_ERROR_NOT_FINISHED: - sender.sendMessage(I.t("{ce}There's not one team alive!")); - break; - - default: - throw e; - } - } - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh finish {ci}: displays the name of the winner(s) and launches some fireworks.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java index f6014c2..22d05aa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java @@ -32,11 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -56,8 +52,7 @@ * - none: unfreezes all the alive players (even if there where frozen before using * /uh freeze all), the mobs and the timer. */ -@Command (name = "freeze") -public class UHFreezeCommand extends AbstractCommand +public class UHFreezeCommand// extends AbstractCommand { private UHCReloaded p; @@ -66,12 +61,11 @@ public UHFreezeCommand(UHCReloaded plugin) p = plugin; } - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException + public void run(CommandSender sender, String[] args)// throws CannotExecuteCommandException { if (args.length == 0) { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); + //throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); } String subCommand = args[0]; @@ -98,7 +92,7 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand } else { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); + //throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); } } @@ -145,7 +139,6 @@ else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none } } - @Override public List<String> tabComplete(CommandSender sender, String[] args) { if (args.length == 1) @@ -175,7 +168,6 @@ else if (args.length == 2) else return null; } - @Override public List<String> help(CommandSender sender) { return Arrays.asList( @@ -187,15 +179,8 @@ public List<String> help(CommandSender sender) ); } - @Override public List<String> onListHelp(CommandSender sender) { return Collections.singletonList(I.t("{cc}/uh freeze {ci}: (un)freezes the entire game, or a player. See /uh freeze for details.")); } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java deleted file mode 100644 index 775bab9..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHInfosCommand.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.text.RawMessage; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -@Command (name = "infos") -public class UHInfosCommand extends AbstractCommand -{ - private UHCReloaded p; - - public UHInfosCommand(UHCReloaded p) - { - this.p = p; - } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - CommandUtils.displaySeparator(sender); - - if (p.getGameManager().isGameStarted()) - { - /// Header of the /uh infos command. Plural based on the players count. - sender.sendMessage(I.tn("{ci}{0} player alive in {1} team.", "{ci}{0} players alive in {1} teams.", p.getGameManager().getAlivePlayersCount(), p.getGameManager().getAlivePlayersCount(), p.getGameManager().getAliveTeamsCount())); - } - else - { - sender.sendMessage(I.t("{ci}The game is not started.")); - } - - for (ZTeam team : ZTeams.get().getTeams()) - { - for (OfflinePlayer player : team.getPlayers()) - { - if (sender instanceof Player) - { - /* We can use a JSON-based message */ - - String json = "{\"text\":\"\",\"extra\":["; - - - // Online/offline bullet - json += "{"; - if (player.isOnline()) - { - /// Online status dot in /uh infos - json += "\"text\":\"" + I.t("{green} • ") + "\","; - json += "\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + I.t("Currently online") + "\"}"; - } - else - { - /// Offline status dot in /uh infos - json += "\"text\":\"" + I.t("{red} • ") + "\","; - json += "\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + I.t("Currently offline") + "\"}"; - } - json += "},"; - - - // Name and team - json += "{"; - json += "\"text\":\"" + team.getColorOrWhite().toChatColor() + player.getName() + ChatColor.RESET + "\","; - /// Team name in tooltip in /uh infos - json += "\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + I.t("Team: {0}", team.getDisplayName()) + "\"}"; - json += "}"; - - - if (p.getGameManager().isGameStarted()) - { - /// Separator in /uh infos - json += ",{\"text\":\"" + I.t("{gray} - ") + "\"},"; - - // Alive state - json += "{"; - if (!p.getGameManager().isPlayerDead(player.getUniqueId())) - { - /// Alive state in /uh infos - json += "\"text\":\"" + I.t("{green}alive") + "\","; - if (player.isOnline()) - { - json += "\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + I.t("{0} half-hearts", String.valueOf((int) ((Player) player).getHealth())) + "\"}"; - } - } - else - { - /// Alive state in /uh infos - json += "\"text\":\"" + I.t("{red}dead") + "\""; - } - json += "}"; - } - - // End - json += "]}"; - - RawMessage.send((Player) sender, json); - } - else - { - /* Fallback to a simple display for the console */ - - String info; - - if (player.isOnline()) - { - info = I.t("{green} • "); - } - else - { - info = I.t("{red} • "); - } - - info += team.getColorOrWhite().toChatColor() + player.getName() + ChatColor.RESET; - - if (p.getGameManager().isGameStarted()) - { - info += I.t("{gray} - "); - - if (!p.getGameManager().isPlayerDead(player.getUniqueId())) - { - info += I.t("{green}alive"); - } - else - { - info += I.t("{red}dead"); - } - } - - sender.sendMessage(info); - } - } - } - - - CommandUtils.displaySeparator(sender); - } - - @Override - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - @Override - public List<String> help(CommandSender sender) - { - return null; - } - - @Override - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh infos {ci}: prints some infos about the current game.")); - } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java index 3653fd6..4aaf10f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java @@ -32,10 +32,6 @@ package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.commands.categories.Category; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -44,8 +40,7 @@ import java.util.Collections; import java.util.List; -@Command (name = "rules") -public class UHRulesCommand extends AbstractCommand +public class UHRulesCommand// extends AbstractCommand { private UHCReloaded p; @@ -54,9 +49,7 @@ public UHRulesCommand(UHCReloaded plugin) p = plugin; } - - @Override - public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException + public void run(CommandSender sender, String[] args)// throws CannotExecuteCommandException { if (!p.getRulesManager().isEnabled()) { @@ -85,27 +78,18 @@ public void run(CommandSender sender, String[] args) throws CannotExecuteCommand } } - @Override public List<String> tabComplete(CommandSender sender, String[] args) { return null; } - @Override public List<String> help(CommandSender sender) { return null; } - @Override public List<String> onListHelp(CommandSender sender) { return Collections.singletonList(I.t("{cc}/uh rules [player] {ci}: sends the server rules to the server or the given player.")); } - - @Override - public String getCategory() - { - return Category.MISC.getTitle(); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java deleted file mode 100644 index aad7634..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommand.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.core; - -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import org.bukkit.command.CommandSender; - -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - - -/** - * Represents a command with subcommands (or not). - * - * <p> - * Add the subcommands with the {@link #registerSubCommand} method in the constructor.<br /> - * A subcommand is simply an {@link AbstractCommand} object. - * </p> - * - * @version 1.0 - * @author Amaury Carrade - */ -public abstract class AbstractCommand -{ - /** - * Stores the sub-commands of this complex command. - * - * <p>name → command.</p> - */ - private Map<String, AbstractCommand> subcommands = new LinkedHashMap<>(); - - /** - * Stores the permissions of the sub-commands. - * - * <p>name → permission.</p> - */ - private Map<String, String> permissions = new LinkedHashMap<>(); - - /** - * Stores the sub-commands per category. - * - * <p>name → category.</p> - */ - private Map<String, String> subcommandsCategories = new LinkedHashMap<>(); - - /** - * The parent command. - * - * <p> - * Example, for {@code /cmd foo bar}, the parent command of {@code bar} - * is the command {@code foo}. - * </p> - * <p> - * Without parent (root command), {@code null}. - * </p> - */ - private AbstractCommand parent = null; - - - /** - * Runs the command. - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - * - * @throws eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. - */ - public abstract void run(CommandSender sender, String[] args) throws CannotExecuteCommandException; - - /** - * Tab-completes this command. - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - public abstract List<String> tabComplete(CommandSender sender, String[] args); - - /** - * Returns the help of this command. - * - * <p> - * These lines will only be displayed if the {@link CannotExecuteCommandException} is - * caught by the command executor, with the reasons {@code BAD_USE} or {@code NEED_DOC}. - * </p> - * <p> - * If this returns null, fallsback to {@link #onListHelp}. - * </p> - * - * - * @param sender The sender. - * - * @return The help. One line per entry in the list. - */ - public abstract List<String> help(CommandSender sender); - - /** - * Returns the help displayed in the list of the commands, in the help - * of the parent command. - * - * <p> - * You should return one single line here, except for special cases. - * </p> - * - * @param sender The sender. - * - * @return The help. One line displayed per entry in the list. - */ - public abstract List<String> onListHelp(CommandSender sender); - - /** - * Returns the title of the category of the command. - * - * <p> - * This category will be displayed as a title in the commands' list.<br /> - * If the value defined is empty, or null, or the method not overwritten, - * the command will be not categorized. - * </p> - * - * <p> - * This category must be unique in the sub-commands of a command. - * </p> - * - * <p> - * You should either use a category for all subcommands of a command, either no categories - * at all for these commands. Else, the non-categorized commands will be displayed somewhere, - * and this place may vary. - * </p> - */ - public String getCategory() - { - return null; - } - - - /** - * Sets the parent command of this command. Can be set only one time. - * - * @param parent The parent. - * - * @throws IllegalArgumentException If the parent command is already set. - */ - public void setParent(AbstractCommand parent) - { - if (this.parent != null) - { - throw new IllegalArgumentException("The parent command is already set!"); - } - - this.parent = parent; - } - - /** - * Returns the parent command. - * - * @return The parent; {@code null} if this command is a root one. - */ - public AbstractCommand getParent() - { - return parent; - } - - - /** - * Registers a subcommand of this command. - * - * @param command The command to register. - * - * @throws IllegalArgumentException If the command object don't have the {@link eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command} annotation. - */ - public void registerSubCommand(AbstractCommand command) - { - Command commandAnnotation = command.getClass().getAnnotation(Command.class); - - if (commandAnnotation == null) - { - throw new IllegalArgumentException("Cannot register a command without @Command annotation. Class: " + command.getClass().getCanonicalName() + "."); - } - - command.setParent(this); - - String name = commandAnnotation.name(); - String permission = commandAnnotation.permission(); - - if (permission == null && !commandAnnotation.useParentPermission()) - { - permission = commandAnnotation.name(); - } - - if (permission != null && permission.isEmpty() || commandAnnotation.noPermission()) - { - permission = null; - } - - if (commandAnnotation.inheritPermission() || commandAnnotation.useParentPermission()) - { - - AbstractCommand parent = this; - if (commandAnnotation.useParentPermission()) - { - // We starts at the parent to get the parent's permission. - parent = this.getParent(); - } - - while (parent != null) - { - // The parent will always have the @Command annotation, because it is always - // added in this method and the presence of the annotation is checked. - Command parentAnnotation = parent.getClass().getAnnotation(Command.class); - if (parentAnnotation.permission() != null && !parentAnnotation.permission().isEmpty()) - { - permission = parentAnnotation.permission(); - if (permission != null && !permission.isEmpty()) - { - permission += "." + permission; - } - } - parent = parent.getParent(); - } - } - - // Let's save these permissions and executors. - subcommands.put(name, command); - permissions.put(name, permission); - - // Categories - if (command.getCategory() != null && !command.getCategory().isEmpty()) - { - subcommandsCategories.put(name, command.getCategory()); - } - } - - /** - * Routes the command, to a sub command, with a fallback to the - * {@link #run} method of this command if no subcommand matches - * or if there isn't any argument passed to this command. - * - * <p> - * Internal use. Do not override this. Ignore this. - * </p> - * - * @param sender The sender of the command. - * @param args The arguments passed to the command. - */ - public void routeCommand(CommandSender sender, String[] args) throws CannotExecuteCommandException - { - if (args.length == 0) - { - run(sender, new String[0]); - } - else - { - AbstractCommand cmd = subcommands.get(args[0]); - if (cmd != null) - { - // Allowed? - String permission = permissions.get(args[0]); - if (permission == null || sender.hasPermission(permission)) - { - cmd.routeCommand(sender, CommandUtils.getSubcommandArguments(args)); - } - else - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED); - } - } - else - { - run(sender, args); - } - } - } - - /** - * Routes to the autocompleter of this command. - * - * <p> - * Internal use. Do not override this. Ignore this. - * </p> - * - * @param sender The sender. - * @param args The arguments passed to the command. - * - * @return A list of suggestions. - */ - public List<String> routeTabComplete(CommandSender sender, String[] args) - { - // Autocompletion for this command - if (args.length == 1) - { - List<String> suggestions = new LinkedList<>(); - - for (String command : subcommands.keySet()) - { - String permission = permissions.get(command); - if (permission == null || sender.hasPermission(permission)) - { - suggestions.add(command); - } - } - - suggestions = CommandUtils.getAutocompleteSuggestions(args[0], suggestions); - - List<String> suggestionsFromThisCommand = tabComplete(sender, args); - if (suggestionsFromThisCommand != null) - { - suggestions.addAll(suggestionsFromThisCommand); - } - - return suggestions; - } - - // Autocompletion for a subcommand - else - { - AbstractCommand subcommand = subcommands.get(args[0]); - if (subcommand != null) - { - return subcommand.routeTabComplete(sender, CommandUtils.getSubcommandArguments(args)); - } - else - { - return tabComplete(sender, args); - } - } - } - - /** - * Returns the subcommands. - * - * <p> - * Map: name of the command → UHCommand object. - * </p> - * - * @return the subcommands. - */ - public Map<String, AbstractCommand> getSubcommands() - { - return subcommands; - } - - /** - * Returns the permissions of the subcommands. - * - * <p> - * Map: name of the command → raw permission of this command. - * </p> - * - * @return the permissions of the subcommands. - */ - public Map<String, String> getSubcommandsPermissions() - { - return permissions; - } - - /** - * Returns true if this command has subcommands. - */ - public boolean hasSubCommands() - { - return subcommands.size() > 0; - } - - /** - * Returns the categories of the subcommands. - * - * <p> - * Map: name of the command → title of the category of this command. - * </p> - */ - public Map<String, String> getSubcommandsCategories() - { - return subcommandsCategories; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java deleted file mode 100644 index 892d547..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/AbstractCommandExecutor.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.core; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions.CannotExecuteCommandException; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; - -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - - -/** - * The base of every command executor. - * - * <p> - * The command executors needs to extend this class and to register the commands in the constructor - * with the method {@link #registerCommand}. - * </p> - * - * @version 1.0 - * @author Amaury Carrade - */ -public abstract class AbstractCommandExecutor implements TabExecutor -{ - private UHCReloaded p; - - /** - * Stores the main commands, i.e. the commands registered in the {@code plugin.yml} file. - */ - private Map<String, AbstractCommand> mainCommands = new LinkedHashMap<>(); - - /** - * Stores the base permissions of these commands. - */ - private Map<String, String> mainCommandsPermissions = new LinkedHashMap<>(); - - - public AbstractCommandExecutor(UHCReloaded plugin) - { - p = plugin; - } - - - /** - * Registers a main, root command. This command must be in the {@code plugin.yml}, or - * it will never be called. - * - * @param command The command. - * - * @throws IllegalArgumentException If the command class doesn't have the @Command - * annotation. - */ - public void registerCommand(AbstractCommand command) - { - Command commandAnnotation = command.getClass().getAnnotation(Command.class); - if (commandAnnotation == null) - { - throw new IllegalArgumentException("Cannot register a command without @Command annotation. Class: " + command.getClass().getCanonicalName() + "."); - } - - mainCommands.put(commandAnnotation.name(), command); - - String permission = commandAnnotation.permission(); - - if (commandAnnotation.noPermission()) - { - permission = null; - } - else if (permission != null && permission.isEmpty()) - { - if (commandAnnotation.useParentPermission()) - { - permission = null; - } - else - { - permission = commandAnnotation.name(); - } - } - - mainCommandsPermissions.put(commandAnnotation.name(), permission); - } - - - /** - * Displays the help of a command. - * - * <p> - * If the command is a complex command, this will display the help of the complex command, - * first line excepted, ath then the short help of all sub-commands.<br /> - * Else, this will display the full help for the command. - * </p> - * - * @param sender The sender. - * @param command The command. - * @param isAnError {@code true} if this is displayed due to an error. - */ - public void displayHelp(CommandSender sender, AbstractCommand command, boolean isAnError) - { - if (command.hasSubCommands()) - { - List<String> help = new LinkedList<>(); - - // Root help - List<String> rootHelp = command.help(sender); - if (rootHelp != null) - { - help.addAll(rootHelp); - } - - // Then, the help of the sub-commands sorted by category. - // We first organize the commands per-category. - Map<String, LinkedList<String>> helpPerCategory = new LinkedHashMap<>(); - - for (Map.Entry<String, AbstractCommand> subCommand : command.getSubcommands().entrySet()) - { - List<String> subHelp = subCommand.getValue().onListHelp(sender); - String permission = command.getSubcommandsPermissions().get(subCommand.getKey()); - String category = command.getSubcommandsCategories().get(subCommand.getKey()); - - if (category == null) category = ""; - - if (subHelp != null && subHelp.size() > 0 && (permission == null || sender.hasPermission(permission))) - { - - LinkedList<String> helpForThisCategory = helpPerCategory.get(category); - if (helpForThisCategory != null) - { - helpForThisCategory.addAll(subHelp); - } - else - { - helpForThisCategory = new LinkedList<>(); - helpForThisCategory.addAll(subHelp); - helpPerCategory.put(category, helpForThisCategory); - } - } - } - - // After, we add to the help to display these commands, with the titles of the - // categories. - for (Map.Entry<String, LinkedList<String>> category : helpPerCategory.entrySet()) - { - help.add(category.getKey()); - help.addAll(category.getValue()); - } - - displayHelp(sender, help, isAnError); - } - else - { - List<String> help = command.help(sender); - if (help == null) help = command.onListHelp(sender); - - displayHelp(sender, help, isAnError); - } - } - - /** - * Displays the help of a command. - * - * @param sender The sender; this user will receive the help. - * @param help The help to display (one line per entry; raw display). - * @param isAnError {@code true} if this is displayed due to an error. - */ - public void displayHelp(CommandSender sender, List<String> help, boolean isAnError) - { - CommandUtils.displaySeparator(sender); - - if (!isAnError) - { - sender.sendMessage(I.t("{yellow}{0} - version {1}", p.getDescription().getDescription(), p.getDescription().getVersion())); - sender.sendMessage(I.t("{ci}Legend: {cc}/uh command <required> [optional=default] <spaces allowed ...>{ci}.")); - } - - if (help != null) - { - for (String line : help) - { - if (line != null && !line.isEmpty()) - sender.sendMessage(line); - } - } - - CommandUtils.displaySeparator(sender); - - if (isAnError) - { - sender.sendMessage(I.t("{ce}{bold}You cannot execute this command this way.")); - sender.sendMessage(I.t("{ce}The help is displayed above.")); - CommandUtils.displaySeparator(sender); - } - } - - - @Override - public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String alias, String[] args) - { - AbstractCommand abstractCommand = mainCommands.get(command.getName()); - if (abstractCommand == null) - { - return false; - } - - try - { - String permission = mainCommandsPermissions.get(command.getName()); - if (permission != null && !sender.hasPermission(permission)) - { - throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NOT_ALLOWED); - } - - abstractCommand.routeCommand(sender, args); - - } - catch (CannotExecuteCommandException e) - { - switch (e.getReason()) - { - case NOT_ALLOWED: - sender.sendMessage(I.t("{ce}You are not allowed to execute this command.")); - break; - - case ONLY_AS_A_PLAYER: - sender.sendMessage(I.t("{ce}This can only be executed as a player.")); - break; - - case BAD_USE: - case NEED_DOC: - displayHelp(sender, e.getOrigin() != null ? e.getOrigin() : abstractCommand, e.getReason() == CannotExecuteCommandException.Reason.BAD_USE); - break; - - case UNKNOWN: - break; - } - } - - return true; - } - - @Override - public List<String> onTabComplete(CommandSender sender, org.bukkit.command.Command command, String alias, String[] args) - { - AbstractCommand abstractCommand = mainCommands.get(command.getName()); - return abstractCommand.routeTabComplete(sender, args); - } - - public Map<String, AbstractCommand> getMainCommands() - { - return mainCommands; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java deleted file mode 100644 index 9e00a29..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/annotations/Command.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.commands.core.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * This annotation needs to be applied to every command class. It is used to define the - * name and the permission of the command. - * - * @version 1.0 - * @author Amaury Carrade - */ -@Retention (RetentionPolicy.RUNTIME) -@Target (ElementType.TYPE) -public @interface Command -{ - - /** - * The name of the command, needed to type in the console/chat to execute - * the (sub-)command. - */ - String name(); - - /** - * The permission needed to execute this command. - * - * <p> - * Please note that with the current version of this API, the user will need to have the right to - * access the parent commands, to access this command.<br /> - * This situation may evolve in the future. - * </p> - * <p> - * If the {@code inheritPermission} option is unset or set to {@code true}, - * this permission is <strong>concatened to the parent permissions</strong>.<br /> - * As example, if the permission is set to {@code sb}, and if the parent command - * have the permission {@code cmd.norris}, the real permission of the command will - * be {@code cmd.norris.sb}. - * </p> - * <p> - * If this is left empty, or not set, the permission will be the name of the command, excepted - * if {@link #useParentPermission} is set to true. - * </p> - */ - String permission() default ""; - - /** - * If this is set to {@code false}, the permission will be interpreted <em>as-is</em>, - * without concatenation with the permissions of the parent commands. - * - * <p> - * You should not set this to {@code false} if the command have sub-commands with this - * set to {@code true}, or weired behavior may happens. - * </p> - */ - boolean inheritPermission() default true; - - /** - * If this is set to {@code true}, the permission of the parent command will be used. - * - * <p> - * If the parent command is {@code null} (i.e. this command is a root one), the command will be - * accessible to everyone. - * </p> - */ - boolean useParentPermission() default false; - - /** - * If this is set to true, no permissions check will be done when someone - * executes this command. - */ - boolean noPermission() default false; -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java deleted file mode 100644 index 77e3df8..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/exceptions/CannotExecuteCommandException.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.commands.core.exceptions; - -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; - - -/** - * This exception is fired when a command cannot be executed, for whatever reason. - * - * @version 1.0 - * @author Amaury Carrade - */ -public class CannotExecuteCommandException extends Exception -{ - - public enum Reason - { - /** - * Use this if the player is not allowed to execute the command. - */ - NOT_ALLOWED, - - /** - * Use this if the command can only be executed as a player, and - * the sender is not a player. - */ - ONLY_AS_A_PLAYER, - - /** - * Use this if the sender used the command badly. - * - * <p> - * This will display the documentation and an error message. - * </p> - */ - BAD_USE, - - /** - * Use this to have the documentation of the command displayed. - */ - NEED_DOC, - - /** - * Use this in other cases. - */ - UNKNOWN - } - - private Reason reason; - private AbstractCommand origin; - - public CannotExecuteCommandException(Reason reason, AbstractCommand origin) - { - this.reason = reason; - this.origin = origin; - } - - public CannotExecuteCommandException(Reason reason) - { - this(reason, null); - } - - public Reason getReason() - { - return reason; - } - - public AbstractCommand getOrigin() - { - return origin; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java deleted file mode 100644 index eac5a97..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameEndsEvent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.events; - -import fr.zcraft.zteams.ZTeam; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - - -public class UHGameEndsEvent extends Event implements Cancellable -{ - private ZTeam winner; - private boolean cancelled = false; - - public UHGameEndsEvent(ZTeam winner) - { - this.winner = winner; - } - - /** - * Returns the last team alive. - * - * @return The team. - */ - public ZTeam getWinnerTeam() - { - return winner; - } - - - @Override - public boolean isCancelled() - { - return cancelled; - } - - /** - * Cancels the game ends. If cancelled, the end message / effects will not be broadcasted. - * - * @param cancelled {@code true} to cancel. - */ - @Override - public void setCancelled(boolean cancelled) - { - this.cancelled = cancelled; - } - - - - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java deleted file mode 100644 index befefae..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/events/UHGameStartsEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.events; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - - -/** - * This event is fired when the UHC game is started. - */ -public class UHGameStartsEvent extends Event -{ - private static final HandlerList handlers = new HandlerList(); - - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java index dfb6b6b..30d2a83 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java @@ -33,337 +33,29 @@ package eu.carrade.amaury.UHCReloaded.old.listeners; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameEndsEvent; -import eu.carrade.amaury.UHCReloaded.old.events.UHGameStartsEvent; -import eu.carrade.amaury.UHCReloaded.old.misc.RuntimeCommandsExecutor; -import eu.carrade.amaury.UHCReloaded.old.protips.ProTips; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.Titles; -import org.bukkit.*; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.*; -import org.bukkit.event.player.PlayerLoginEvent.Result; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; +import org.bukkit.event.player.PlayerAchievementAwardedEvent; +import org.bukkit.event.player.PlayerStatisticIncrementEvent; public class GameListener implements Listener { private final UHCReloaded p; - private final Set<UUID> enableSpectatorModeOnRespawn = new HashSet<>(); - public GameListener() { this.p = UHCReloaded.get(); } - - /** - * Used to: - * - call events (UHPlayerDeathEvent, UHTeamDeathEvent, UHGameEndsEvent); - * - play the death sound; - * - update the scoreboard; - * - kick the player (if needed); - * - broadcast a team-death message (if needed); - * - highlight the death message in the console; - * - increase visibility of the death message (if needed); - * - drop the skull of the dead player (if needed); - * - send a ProTip to the killer about the "golden heads" (if needed); - * - update the number of alive players/teams; - * - save the location of the death of the player, to allow a teleportation later; - * - show the death location on the dynmap (if needed); - * - give XP to the killer (if needed); - * - notify the player about the possibility of respawn if hardcore hearts are enabled; - * - update the MOTD if needed; - * - disable the team-chat-lock if needed. - */ - @EventHandler - public void onPlayerDeath(final PlayerDeathEvent ev) - { - // This needs to be executed only if the player die as a player, not a spectator. - // Also, the game needs to be started. - if (p.getGameManager().isPlayerDead(ev.getEntity()) || !p.getGameManager().isGameStarted()) - { - return; - } - - // p.getServer().getPluginManager().callEvent(new AlivePlayerDeathEvent(ev)); - - // Plays sound. - p.getGameManager().getDeathSound().broadcast(); - - // Send lightning strike if needed. - if (UHConfig.DEATH.ANNOUNCEMENTS.LIGHTNING_STRIKE.get()) - { - ev.getEntity().getLocation().getWorld().strikeLightningEffect(ev.getEntity().getLocation()); - } - - // Removes the player from the alive players. - this.p.getGameManager().addDead(ev.getEntity()); - - // Remember to enable spectator mode on respawn - enableSpectatorModeOnRespawn.add(ev.getEntity().getUniqueId()); - - // Kicks the player if needed. - if (UHConfig.DEATH.KICK.DO.get()) - { - RunTask.later(() -> - { - /// The kick message of a player when death.kick.do = true in config - ev.getEntity().kickPlayer(I.t("jayjay")); - }, 20L * UHConfig.DEATH.KICK.TIME.get()); - } - - // Drops the skull of the player. - if (UHConfig.DEATH.HEAD.DROP.get()) - { - if (!UHConfig.DEATH.HEAD.PVP_ONLY.get() || (UHConfig.DEATH.HEAD.PVP_ONLY.get() && ev.getEntity().getKiller() != null)) - { - Location l = ev.getEntity().getLocation(); - ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal()); - SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); - skullMeta.setOwner(ev.getEntity().getName()); - skullMeta.setDisplayName(ChatColor.RESET + ev.getEntity().getDisplayName()); - skull.setItemMeta(skullMeta); - l.getWorld().dropItem(l, skull); - - // Protip - if (ev.getEntity().getKiller() != null) - { - final Player killer = ev.getEntity().getKiller(); - RunTask.later(() -> ProTips.CRAFT_GOLDEN_HEAD.sendTo(killer), 200L); - } - } - } - - // Give XP to the killer (if needed) - if (UHConfig.DEATH.GIVE_XP_TO_KILLER.LEVELS.get() > 0) - { - Player killer = ev.getEntity().getKiller(); - if (killer != null) - { - boolean inSameTeam = true; // TODO p.getTeamManager().inSameTeam(ev.getEntity(), killer); - boolean onlyOtherTeam = UHConfig.DEATH.GIVE_XP_TO_KILLER.ONLY_OTHER_TEAM.get(); - - if (!onlyOtherTeam || !inSameTeam) - { - killer.giveExpLevels(UHConfig.DEATH.GIVE_XP_TO_KILLER.LEVELS.get()); - } - } - } - - // Sends a team-death message & event if needed. -// final UHTeam team = p.getTeamManager().getTeamForPlayer(ev.getEntity()); -// if (team != null) -// { -// boolean isAliveTeam = false; -// -// for (UUID playerID : team.getPlayersUUID()) -// { -// if (!p.getGameManager().isPlayerDead(playerID)) -// { -// isAliveTeam = true; -// break; -// } -// } -// -// if (!isAliveTeam) -// { -// p.getServer().getPluginManager().callEvent(new UHTeamDeathEvent(team)); -// -// if (UHConfig.DEATH.MESSAGES.NOTIFY_IF_TEAM_HAS_FALLEN.get()) -// { -// // Used to display this message after the death message. -// RunTask.later(() -> { -// String format = ChatColor.translateAlternateColorCodes('&', UHConfig.DEATH.MESSAGES.TEAM_DEATH_MESSAGES_FORMAT.get()); -// p.getServer().broadcastMessage(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)); -// }, 1L); -// } -// } -// } - - // Highlights the death message in the console - p.getServer().getConsoleSender().sendMessage(ChatColor.GOLD + "-- Death of " + ev.getEntity().getDisplayName() + ChatColor.GOLD + " (" + ev.getDeathMessage() + ") --"); - - // Customizes the death message - String dmFormat = ChatColor.translateAlternateColorCodes('&', UHConfig.DEATH.MESSAGES.DEATH_MESSAGES_FORMAT.get()); - String deathMessage = dmFormat + ev.getDeathMessage(); - deathMessage = deathMessage.replace(ev.getEntity().getName(), ev.getEntity().getDisplayName() + dmFormat); - if (ev.getEntity().getKiller() != null) - { - deathMessage = deathMessage.replace(ev.getEntity().getKiller().getName(), ev.getEntity().getKiller().getDisplayName() + dmFormat); - } - ev.setDeathMessage(deathMessage); - - // Saves the location of the death - p.getGameManager().addDeathLocation(ev.getEntity(), ev.getEntity().getLocation()); - - // Shows the death location on the dynmap - // p.getDynmapIntegration().showDeathLocation(ev.getEntity()); - - // Is the game ended? If so, we need to call an event. - if (p.getGameManager().isGameRunning() && p.getGameManager().getAliveTeamsCount() == 1) - { - p.getGameManager().setGameFinished(true); - - // There's only one team alive, so the winner team is the first one. -// p.getServer().getPluginManager().callEvent(new UHGameEndsEvent(p.getGameManager().getAliveTeams().iterator().next())); - } - - // Disables the team-chat-lock if needed -// if (UHConfig.TEAMS_OPTIONS.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) -// { -// if (p.getTeamChatManager().isTeamChatEnabled(ev.getEntity())) -// { -// p.getTeamChatManager().toggleChatForPlayer(ev.getEntity()); -// } -// } - - // Updates the list headers & footers. - p.getPlayerListHeaderFooterManager().updateHeadersFooters(); - } - - - /** - * Used to enable the spectator mode when the player respawns. - */ - @EventHandler - public void onPlayerRespawn(final PlayerRespawnEvent ev) - { - if (enableSpectatorModeOnRespawn.remove(ev.getPlayer().getUniqueId())) - { - RunTask.nextTick(() -> p.getSpectatorsManager().setSpectating(ev.getPlayer(), true)); - } - } - - - /** - * Used to display our custom state-based MOTD (if needed). - */ - @EventHandler - public void onServerListPing(final ServerListPingEvent ev) - { - if (p.getMOTDManager().isEnabled()) - { - ev.setMotd(p.getMOTDManager().getCurrentMOTD()); - } - } - - - /** - * Used to prevent the player to login after his death (if needed). - */ - @EventHandler - public void onPlayerLogin(final PlayerLoginEvent ev) - { - if (p.getGameManager().isGameStarted() - && p.getGameManager().isPlayerDead(ev.getPlayer()) - && !p.getGameManager().isDeadPlayersToBeResurrected(ev.getPlayer()) - && !p.getGameManager().getStartupSpectators().contains(ev.getPlayer().getName()) - && !UHConfig.DEATH.KICK.ALLOW_RECONNECT.get()) - { - - ev.setResult(Result.KICK_OTHER); - /// The kick message displayed if a player tries to relog after his death and it's forbidden by the config. - ev.setKickMessage(I.t("You are dead!")); - } - } - - - /** - * Used to: - * - change the gamemode of the player, if the game is not running; - * - teleport the player to the spawn, if the game is not running; - * - update the scoreboard; - * - put a new player in spectator mode if the game is started (following the config); - * - resurrect a player (if the player was offline). - */ - @EventHandler (priority = EventPriority.HIGHEST) - public void onPlayerJoin(final PlayerJoinEvent ev) - { - if (!this.p.getGameManager().isGameStarted()) - { - if (!p.getGameManager().isSlowStartInProgress()) - { - // Initialization of the player (teleportation, life, health objective score...). - p.getGameManager().initPlayer(ev.getPlayer()); - - // Teams selector. -// if (UHConfig.TEAMS_OPTIONS.GUI.AUTO_DISPLAY.get() && p.getTeamManager().getTeams().size() != 0) -// { -// RunTask.later(() -> { -// if (p.getTeamManager().getTeamForPlayer(ev.getPlayer()) == null) -// { -// p.getTeamManager().displayTeamChooserChatGUI(ev.getPlayer()); -// } -// }, 20L * UHConfig.TEAMS_OPTIONS.GUI.DELAY.get()); -// } - - // Rules - if (p.getRulesManager().displayOnJoin()) - { - RunTask.later(() -> p.getRulesManager().displayRulesTo(ev.getPlayer()), 15 * 20L); - } - } - else - { - // Without that the player will be kicked for flying. - ev.getPlayer().setAllowFlight(true); - ev.getPlayer().setFlying(true); - } - } - - // Mainly useful on the first join. - p.getScoreboardManager().setScoreboardForPlayer(ev.getPlayer()); - - // The headers & footers needs to be (re)sent. - p.getPlayerListHeaderFooterManager().sendTo(ev.getPlayer()); - - // The display name is reset when the player logs off. -// p.getTeamManager().colorizePlayer(ev.getPlayer()); - - // If the player needs to be resurrected... - if (p.getGameManager().isDeadPlayersToBeResurrected(ev.getPlayer())) - { - p.getGameManager().resurrectPlayerOnlineTask(ev.getPlayer()); - p.getGameManager().markPlayerAsResurrected(ev.getPlayer()); - } - - // If the player is a new one, the game is started, and the option is set to true... - if (p.getGameManager().isGameRunning() && UHConfig.SPECTATOR_MODE_WHEN_NEW_PLAYER_JOIN_AFTER_START.get() - && !p.getGameManager().getAlivePlayers().contains(ev.getPlayer())) - { - p.getSpectatorsManager().setSpectating(ev.getPlayer(), true); - } - } - /** * Used to disable the achievements before the game. */ @EventHandler public void onPlayerAchievementAwarded(final PlayerAchievementAwardedEvent ev) { - if (!p.getGameManager().isGameStarted() && UHConfig.ACHIEVEMENTS.DISABLE_ACHIEVEMENTS_BEFORE_START.get()) + //if (!p.getGameManager().isGameStarted() && UHConfig.ACHIEVEMENTS.DISABLE_ACHIEVEMENTS_BEFORE_START.get()) { ev.setCancelled(true); } @@ -375,292 +67,9 @@ public void onPlayerAchievementAwarded(final PlayerAchievementAwardedEvent ev) @EventHandler public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) { - if (!p.getGameManager().isGameStarted() && UHConfig.STATISTICS.DISABLE_STATISTICS_BEFORE_START.get()) - { - ev.setCancelled(true); - } - } - - - /** - * Used to prevent players from breaking blocks if the game is not currently running. - */ - @EventHandler - public void onBlockBreakEvent(final BlockBreakEvent ev) - { - if (!this.p.getGameManager().isGameStarted() && !ev.getPlayer().hasPermission("uh.build")) - { - ev.setCancelled(true); - } - } - - /** - * Used to prevent players from placing blocks if the game is not currently running. - */ - @EventHandler - public void onBlockPlaceEvent(final BlockPlaceEvent ev) - { - if (!this.p.getGameManager().isGameStarted() && !ev.getPlayer().hasPermission("uh.build")) + //if (!p.getGameManager().isGameStarted() && UHConfig.STATISTICS.DISABLE_STATISTICS_BEFORE_START.get()) { ev.setCancelled(true); } } - - - /** - * Used to send the chat to the team-chat if this team-chat is enabled. - */ - // Priority LOWEST to be able to cancel the event before all other plugins - @EventHandler (priority = EventPriority.LOWEST) - public void onAsyncPlayerChat(final AsyncPlayerChatEvent ev) - { - // If the event is asynchronous, the message was sent by a "real" player. - // Else, the message was sent by a plugin (like our /g command, or another plugin), and - // the event is ignored. - if (ev.isAsynchronous()) - { -// if (p.getTeamChatManager().isTeamChatEnabled(ev.getPlayer())) -// { -// ev.setCancelled(true); -// p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage()); -// } -// else if (p.getTeamChatManager().isOtherTeamChatEnabled(ev.getPlayer())) -// { -// ev.setCancelled(true); -// p.getTeamChatManager().sendTeamMessage(ev.getPlayer(), ev.getMessage(), p.getTeamChatManager().getOtherTeamEnabled(ev.getPlayer())); -// } - } - } - - /** - * Used to: - * - update the internal list of running timers; - * - shift the episode if the main timer is up (and restart this main timer); - * - hide an other timer when it is up. - */ - @EventHandler - public void onTimerEnds(final TimerEndsEvent ev) - { -// p.getTimerManager().updateStartedTimersList(); -// -// if (ev.getTimer().equals(p.getTimerManager().getMainTimer())) -// { -// // If this timer is the main one, we shifts an episode. -// p.getGameManager().shiftEpisode(); -// ev.setRestart(true); -// } -// else -// { -// ev.getTimer().setDisplayed(false); -// } -// -// if (ev.getTimer().equals(p.getBorderManager().getWarningTimer()) && ev.wasTimerUp()) -// { -// p.getBorderManager().getWarningSender().sendMessage(I.t("{cs}The timer before the new border is up!")); -// p.getBorderManager().sendCheckMessage(p.getBorderManager().getWarningSender(), p.getBorderManager().getWarningSize()); -// } - } - - /** - * Used to: - * - update the internal list of running timers; - * - display a timer when it is started. - */ - @EventHandler - public void onTimerStarts(final TimerStartsEvent ev) - { -// p.getTimerManager().updateStartedTimersList(); -// -// if (!ev.getTimer().equals(p.getTimerManager().getMainTimer())) -// { -// ev.getTimer().setDisplayed(true); -// } - } - - - /** - * Used to broadcast the episode change. - */ - @EventHandler - public void onEpisodeChange(final EpisodeChangedEvent ev) - { - String message; - - if (ev.getCause() == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) - { - message = I.t("{aqua}-------- End of episode {0} [forced by {1}] --------", String.valueOf(ev.getNewEpisode() - 1), ev.getShifter()); - } - else - { - message = I.t("{aqua}-------- End of episode {0} --------", String.valueOf(ev.getNewEpisode() - 1)); - } - - p.getServer().broadcastMessage(message); - - - // Broadcasts title - if (UHConfig.EPISODES.TITLE.get()) - { - Titles.broadcastTitle( - 5, 32, 8, - /// The title displayed when the episode change. {0} = new episode number; {1} = old. - I.t("{darkaqua}Episode {aqua}{0}", ev.getNewEpisode(), ev.getNewEpisode() - 1), - "" - ); - } - - - // Updates the list headers & footers. - p.getPlayerListHeaderFooterManager().updateHeadersFooters(); - } - - - /** - * Used to: - * - broadcast the beginning of a game, with sound & message; - * - schedule the commands executed after the beginning of the game. - */ - @EventHandler - public void onGameStarts(final UHGameStartsEvent ev) - { - // Start sound - new UHSound(UHConfig.START.SOUND).broadcast(); - - // Broadcast - /// Start message broadcasted in chat - Bukkit.getServer().broadcastMessage(I.t("{green}--- GO ---")); - - // Title - if (UHConfig.START.DISPLAY_TITLE.get()) - { - Titles.broadcastTitle( - 5, 40, 8, - /// Title of title displayed when the game starts. - I.t("{darkgreen}Let's go!"), - /// Subtitle of title displayed when the game starts. - I.t("{green}Good luck, and have fun") - ); - } - - // Commands - p.getRuntimeCommandsExecutor().registerCommandsInScheduler(RuntimeCommandsExecutor.AFTER_GAME_START); - - // Border shrinking -// p.getBorderManager().scheduleBorderReduction(); - - // MOTD - p.getMOTDManager().updateMOTDDuringGame(); - - // List headers & footers. - p.getPlayerListHeaderFooterManager().updateHeadersFooters(); - - // Rules - if (p.getRulesManager().displayOnStart()) - { - RunTask.later(() -> p.getRulesManager().broadcastRules(), 15 * 20L); - } - - // Banners - if (p.getGameManager().START_GIVE_BANNER || p.getGameManager().START_PLACE_BANNER_HEAD || p.getGameManager().START_PLACE_BANNER_SPAWN) - { -// RunTask.later(() -> -// { -// for (UHTeam team : p.getTeamManager().getTeams()) -// { -// if (!team.isEmpty()) -// { -// final ItemStack banner = team.getBanner(); -// for (Player player : team.getOnlinePlayers()) -// { -// if (p.getGameManager().START_GIVE_BANNER) -// player.getInventory().setItem(8, banner); -// -// if (p.getGameManager().START_PLACE_BANNER_HEAD) -// player.getInventory().setHelmet(banner); -// -// if (p.getGameManager().START_PLACE_BANNER_SPAWN) -// { -// final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); -// final Block under = place.getRelative(BlockFace.DOWN); -// -// // We don't want a stack of banners -// if (under.getType() != Material.STANDING_BANNER) -// { -// if (!under.getType().isSolid()) -// under.setType(Material.WOOD); -// -// place.setType(Material.STANDING_BANNER); -// -// Banner bannerBlock = (Banner) place.getState(); -// BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); -// -// bannerBlock.setBaseColor(bannerMeta.getBaseColor()); -// bannerBlock.setPatterns(bannerMeta.getPatterns()); -// -// bannerBlock.update(); -// } -// } -// } -// } -// } -// }, 5L); - } - } - - /** - * Used to: - * - broadcast the winner(s) and launch some fireworks if needed, a few seconds later; - * - schedule the commands executed after the end of the game. - */ - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onGameEnd(final UHGameEndsEvent ev) - { - if (UHConfig.FINISH.AUTO.DO.get()) - { - RunTask.later(() -> - { - try - { - p.getGameManager().finishGame(); - } - catch (IllegalStateException e) - { - // The game is not finished (...what?). - e.printStackTrace(); - } - }, UHConfig.FINISH.AUTO.TIME_AFTER_LAST_DEATH.get() * 20L); - } - - // Commands - p.getRuntimeCommandsExecutor().registerCommandsInScheduler(RuntimeCommandsExecutor.AFTER_GAME_END); - - // Updates the MOTD. - p.getMOTDManager().updateMOTDAfterGame(ev.getWinnerTeam()); - } - - - /** - * Used to: - * - disable the spectator mode; - * - hide the death point from the dynmap; - * - broadcast this resurrection to all players; - * - update the MOTD. - */ - @EventHandler - public void onPlayerResurrected(final PlayerResurrectedEvent ev) - { - // Spectator mode disabled - // p.getSpectatorsManager().setSpectating(ev.getPlayer(), false); - - // TODO Death point removed on the dynmap - // p.getDynmapIntegration().hideDeathLocation(ev.getPlayer()); - - // All players are notified - - // Updates the MOTD. - p.getMOTDManager().updateMOTDDuringGame(); - - // Updates the list headers & footers. - p.getPlayerListHeaderFooterManager().updateHeadersFooters(); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java deleted file mode 100644 index 187f69e..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.listeners; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.gameplay.potions.CancelBrewTask; -import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.inventory.BrewerInventory; - - -public class GameplayListener implements Listener -{ - private final UHCReloaded p; - - public GameplayListener() - { - this.p = UHCReloaded.get(); - } - - - /** - * Used to disable power-II potions. - */ - @EventHandler - public void onInventoryDrag(InventoryDragEvent ev) - { - if (UHConfig.GAMEPLAY_CHANGES.DISABLE_LEVEL_II_POTIONS.get() && ev.getInventory() instanceof BrewerInventory) - { - RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); - } - } - - /** - * Used to disable power-II potions. - */ - @EventHandler - public void onInventoryClick(InventoryClickEvent ev) - { - if (UHConfig.GAMEPLAY_CHANGES.DISABLE_LEVEL_II_POTIONS.get() && ev.getInventory() instanceof BrewerInventory) - { - RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java index 359c0e3..a7f6fbe 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java @@ -107,9 +107,9 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) if (frozen) { - p.getGameManager() - .getOnlineAlivePlayers() - .forEach(player -> this.setPlayerFreezeState(player, true)); +// p.getGameManager() +// .getOnlineAlivePlayers() +// .forEach(player -> this.setPlayerFreezeState(player, true)); // Freezes the mobs by applying a Slowness effect. There isn't any EntityMoveEvent, so... p.getServer().getWorlds().stream() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java deleted file mode 100644 index f072314..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/MOTDManager.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.misc; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import org.bukkit.ChatColor; - - -public class MOTDManager -{ - private UHCReloaded p; - - private boolean enabled; - private String matchName = ""; - - private String currentMOTD; - - public MOTDManager(UHCReloaded plugin) - { - p = plugin; - - enabled = UHConfig.MOTD.ENABLED.get(); - - if (enabled && UHConfig.MOTD.DISPLAY_MATCH_NAME.get()) - { - matchName = ChatColor.translateAlternateColorCodes('&', UHConfig.MOTD.MATCH_NAME_PREFIX.get()) - + p.getScoreboardManager().getScoreboardName() - + ChatColor.RESET + "\n"; - } - } - - /** - * Returns the current MOTD. - * - * @return The MOTD. - */ - public String getCurrentMOTD() - { - return currentMOTD; - } - - /** - * Returns true if the state-based MOTDs are enabled. - * - * @return true if enabled. - */ - public boolean isEnabled() - { - return enabled; - } - - - /** - * Updates the MOTD to the one displayed before the game start. - */ - public void updateMOTDBeforeStart() - { - /// MOTD when the game is not started. - if (enabled) currentMOTD = matchName + I.t("Waiting for players..."); - } - - /** - * Updates the MOTD to the one displayed during the start. - */ - public void updateMOTDDuringStart() - { - /// MOTD when the game is starting (slow TP in progress). - if (enabled) currentMOTD = matchName + I.t("Starting in progress..."); - } - - /** - * Updates the MOTD to the one displayed during the game (includes alive counts). - * <p> - * This need to be called on each death, to update alive counts. - */ - public void updateMOTDDuringGame() - { - if (enabled) - { - if (!p.getGameManager().isGameWithTeams()) - { - /// Solo game running MOTD. {0} = players alive count. - currentMOTD = matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", p.getGameManager().getAlivePlayersCount(), p.getGameManager().getAlivePlayersCount()); - } - else - { - /// Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. - currentMOTD = matchName + I.tn("Game running! {0} player alive in {1} team.", "Game running! {0} players alive in {1} teams.", p.getGameManager().getAlivePlayersCount(), p.getGameManager().getAlivePlayersCount(), p.getGameManager().getAliveTeamsCount()); - } - } - } - - /** - * Updates the MOTD after the game. - * - * @param winner The winner. - */ - public void updateMOTDAfterGame(ZTeam winner) - { - if (enabled) - { - if (!p.getGameManager().isGameWithTeams()) - { - /// Game finished MOTD with solo winner ({0} = winner raw name). - currentMOTD = matchName + I.t("Game finished; congratulation to {0} for his victory!", winner.getName()); - } - else - { - /// Game finished MOTD with team winner ({0} = team display name). - currentMOTD = matchName + I.t("Game finished; the team {0} wins this match!", winner.getDisplayName()); - } - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java index 11466fb..81356ac 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java @@ -31,9 +31,7 @@ */ package eu.carrade.amaury.UHCReloaded.old.misc; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; import eu.carrade.amaury.UHCReloaded.UHConfig; -import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.text.ListHeaderFooter; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -76,16 +74,16 @@ public void sendTo(Player player) private void computeHeadersFooter() { - if (UHCReloaded.get().getGameManager().isGameStarted()) - { - currentHeader = computeText(IN_GAME_HEADER_PATTERN); - currentFooter = computeText(IN_GAME_FOOTER_PATTERN); - } - else - { - currentHeader = computeText(WAITING_HEADER_PATTERN); - currentFooter = computeText(WAITING_FOOTER_PATTERN); - } +// if (UHCReloaded.get().getGameManager().isGameStarted()) +// { +// currentHeader = computeText(IN_GAME_HEADER_PATTERN); +// currentFooter = computeText(IN_GAME_FOOTER_PATTERN); +// } +// else +// { +// currentHeader = computeText(WAITING_HEADER_PATTERN); +// currentFooter = computeText(WAITING_FOOTER_PATTERN); +// } } private String computeText(String pattern) @@ -109,18 +107,18 @@ private String computeText(String pattern) private String replaceTags(String raw) { return raw - .replace("{title}", UHConfig.SCOREBOARD.TITLE.get()) - - /// Episode in the player list ({episodeText} replacement). {0} = current episode number. - .replace("{episodeText}", I.t("Episode {0}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode()))) - /// Players in the player list ({playersText} replacement). {0} = current alive players count. - .replace("{playersText}", I.tn("{0} player", "{0} players", UHCReloaded.get().getGameManager().getAlivePlayersCount(), UHCReloaded.get().getGameManager().getAlivePlayersCount())) - /// Teams in the player list ({teamsText} replacement). {0} = current alive teams count. - .replace("{teamsText}", I.tn("{0} team", "{0} teams", UHCReloaded.get().getGameManager().getAliveTeamsCount(), UHCReloaded.get().getGameManager().getAliveTeamsCount())) - - .replace("{episodeNumber}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode())) - .replace("{playersCount}", String.valueOf(UHCReloaded.get().getGameManager().getAlivePlayersCount())) - .replace("{teamsCount}", String.valueOf(UHCReloaded.get().getGameManager().getAliveTeamsCount())) +// .replace("{title}", UHConfig.SCOREBOARD.TITLE.get()) +// +// /// Episode in the player list ({episodeText} replacement). {0} = current episode number. +// .replace("{episodeText}", I.t("Episode {0}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode()))) +// /// Players in the player list ({playersText} replacement). {0} = current alive players count. +// .replace("{playersText}", I.tn("{0} player", "{0} players", UHCReloaded.get().getGameManager().getAlivePlayersCount(), UHCReloaded.get().getGameManager().getAlivePlayersCount())) +// /// Teams in the player list ({teamsText} replacement). {0} = current alive teams count. +// .replace("{teamsText}", I.tn("{0} team", "{0} teams", UHCReloaded.get().getGameManager().getAliveTeamsCount(), UHCReloaded.get().getGameManager().getAliveTeamsCount())) +// +// .replace("{episodeNumber}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode())) +// .replace("{playersCount}", String.valueOf(UHCReloaded.get().getGameManager().getAlivePlayersCount())) +// .replace("{teamsCount}", String.valueOf(UHCReloaded.get().getGameManager().getAliveTeamsCount())) ; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java index d904f31..54bc237 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.UHCReloaded.old.misc; import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.old.commands.core.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java deleted file mode 100644 index a1d9337..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTip.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.protips; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CopyOnWriteArraySet; - - -/** - * A ProTip, sent to a player only once. - */ -public class ProTip -{ - private static final UHSound proTipsSound = new UHSound(UHConfig.PROTIPS.SOUND); - - private String text; - private Boolean enabled; - - private Set<UUID> sentTo = new CopyOnWriteArraySet<>(); - - - /** - * @param enabled {@code false} to avoid this ProTip from being sent when {@link #sendTo(Player)} is called. - * @param text The ProTip text. - */ - public ProTip(Boolean enabled, String text) - { - this.text = text; - this.enabled = enabled; - } - - /** - * @param name A name registered in the UHCReloaded config file, used to disable the powerup if needed, following the configuration. - * @param text The ProTip text. - */ - public ProTip(String name, String text) - { - this(UHCReloaded.get().getConfig().getBoolean("protips." + name), text); - } - - - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - public String getText() - { - return text; - } - - public Boolean isEnabled() - { - return enabled; - } - - - /** - * Checks if this ProTip was sent to this player. - * - * @param id The player's UUID. - * @return {@code true} if already sent. - */ - public Boolean wasSentTo(UUID id) - { - return sentTo.contains(id); - } - - /** - * Checks if this ProTip was sent to this player. - * - * @param player The player. - * @return {@code true} if already sent. - */ - public Boolean wasSentTo(Player player) - { - return wasSentTo(player.getUniqueId()); - } - - - /** - * Sends a ProTip, if this ProTip wasn't sent before to this player. - * - * @param player The receiver of this ProTip. - */ - public void sendTo(Player player) - { - if (!isEnabled() || wasSentTo(player)) - return; - - sentTo.add(player.getUniqueId()); - - /// ProTip invite, displayed before a ProTip. - player.sendMessage(I.t("{darkpurple}ProTip!") + " " + ChatColor.RESET + text); - proTipsSound.play(player); - } - - /** - * Sends a ProTip, if this ProTip wasn't sent before to this player and this player is online. - * - * @param id The receiver of this ProTip. - */ - public void sendTo(UUID id) - { - Player player = Bukkit.getPlayer(id); - if (player != null && player.isOnline()) - sendTo(player); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java deleted file mode 100644 index 0db8d56..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.protips; - -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.entity.Player; - -import java.util.UUID; - - -public enum ProTips -{ - LOCK_CHAT(new ProTip("teamchat.lock", I.tc("protip", "{gray}You can lock and unlock the team chat with {cc}/togglechat{gray}."))), - USE_G_COMMAND(new ProTip("teamchat.useGCommand", I.tc("protip", "{gray}You can send a global message using {cc}/g <message>{gray}."))), - USE_T_COMMAND(new ProTip("teamchat.useTCommand", I.tc("protip", "{gray}You can send a team-chat message with {cc}/t <message>{gray}."))), - - CRAFT_GOLDEN_HEAD(new ProTip("crafts.goldenHead", I.tc("protip", "{gray}You can craft golden apples with heads (same recipe with a head instead of an apple)."))), - CRAFT_COMPASS_EASY(new ProTip("crafts.compassEasy", I.tc("protip", "{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a spider eye and a gunpowder."))), - CRAFT_COMPASS_MEDIUM(new ProTip("crafts.compassMedium", I.tc("protip", "{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a spider eye and a gunpowder; in the center, an ender pearl."))), - CRAFT_COMPASS_HARD(new ProTip("crafts.compassHard", I.tc("protip", "{gray}The compass is crafted with, in the corners, a bone, a rotten flesh, a spider eye and a gunpowder; in the center, an Eye of Ender."))), - CRAFT_GLISTERING_MELON(new ProTip("crafts.glisteringMelon", I.tc("protip", "{gray}The glistering melon is crafted with a melon and a gold block."))), - - CRAFT_NO_ENCHANTED_GOLDEN_APPLE(new ProTip("crafts.noEnchGoldenApple", I.tc("protip", "{gray}The enchanted golden apple is disabled for this game."))), - - STARTUP_INVINCIBILITY(new ProTip("start.invincibility", I.tc("protip", "{gray}Fallen on a tree? Jump, you have a few seconds left to remain invincible."))); - - - private final ProTip proTip; - - ProTips(ProTip proTip) - { - this.proTip = proTip; - } - - public ProTip get() - { - return proTip; - } - - - /** - * Sends this ProTip, if it wasn't sent before to this player. - * - * @param player The receiver of this ProTip. - */ - public void sendTo(Player player) - { - proTip.sendTo(player); - } - - /** - * Sends this ProTip, if it wasn't sent before to this player and this player is online. - * - * @param id The receiver of this ProTip. - */ - public void sendTo(UUID id) - { - proTip.sendTo(id); - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java deleted file mode 100644 index 1aadf35..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.scoreboard; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.game.UHGameManager; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.scoreboard.Sidebar; -import fr.zcraft.zlib.components.scoreboard.SidebarMode; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - - -public class GameSidebar extends Sidebar -{ - private final UHGameManager gameManager; - private final WorldBorder border = null; - - private final boolean EPISODES_ENABLED; - private final boolean EPISODES_IN_SIDEBAR; - private final boolean PLAYERS_IN_SIDEBAR; - private final boolean TEAMS_IN_SIDEBAR; - private final boolean BORDER_IN_SIDEBAR; - private final boolean KILLS_IN_SIDEBAR; - private final boolean TIMER_IN_SIDEBAR; - private final boolean FREEZE_STATUS_IN_SIDEBAR; - - private final boolean OWN_TEAM_IN_SIDEBAR; - private final String OWN_TEAM_TITLE_COLOR; - private final boolean OWN_TEAM_TITLE_IS_NAME; - private final boolean OWN_TEAM_DISPLAY_HEARTS; - private final boolean OWN_TEAM_COLOR_WHOLE_NAME; - private final boolean OWN_TEAM_STRIKE_DEAD_PLAYERS; - private final boolean OWN_TEAM_DISPLAY_LOGIN_STATE_ITALIC; - private final String OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX; - private final boolean OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY; - private final double OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED; - - private final boolean BORDER_DISPLAY_DIAMETER; - - private final String FROOZEN_NULL_TIMER_TEXT; - private final String HEART = "\u2764"; - - private final String sidebarTitle; - private final List<String> sidebarTop = new ArrayList<>(); - private final List<String> sidebarBorder = new ArrayList<>(); - private final List<String> sidebarTimers = new ArrayList<>(); - - - public GameSidebar() - { - gameManager = UHCReloaded.get().getGameManager(); - // border = UHCReloaded.get().getBorderManager().getBorderProxy(); - - EPISODES_ENABLED = UHConfig.EPISODES.ENABLED.get(); - EPISODES_IN_SIDEBAR = UHConfig.SCOREBOARD.EPISODE.get(); - PLAYERS_IN_SIDEBAR = UHConfig.SCOREBOARD.PLAYERS.get(); - TEAMS_IN_SIDEBAR = UHConfig.SCOREBOARD.TEAMS.get(); - BORDER_IN_SIDEBAR = UHConfig.SCOREBOARD.BORDER.DISPLAYED.get(); - KILLS_IN_SIDEBAR = UHConfig.SCOREBOARD.KILLS.get(); - TIMER_IN_SIDEBAR = UHConfig.SCOREBOARD.TIMER.get(); - FREEZE_STATUS_IN_SIDEBAR = UHConfig.SCOREBOARD.FREEZE_STATUS.get(); - - OWN_TEAM_IN_SIDEBAR = UHConfig.SCOREBOARD.OWN_TEAM.ENABLED.get(); - OWN_TEAM_TITLE_COLOR = ChatColor.translateAlternateColorCodes('&', UHConfig.SCOREBOARD.OWN_TEAM.TITLE.COLOR.get()); - OWN_TEAM_TITLE_IS_NAME = UHConfig.SCOREBOARD.OWN_TEAM.TITLE.USE_TEAM_NAME.get(); - OWN_TEAM_DISPLAY_HEARTS = UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.DISPLAY_HEARTS.get(); - OWN_TEAM_COLOR_WHOLE_NAME = UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.COLOR_NAME.get(); - OWN_TEAM_STRIKE_DEAD_PLAYERS = UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.STRIKE_DEAD_PLAYERS.get(); - OWN_TEAM_DISPLAY_LOGIN_STATE_ITALIC = UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.LOGIN_STATE.ITALIC.get(); - OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX = ChatColor.translateAlternateColorCodes('&', UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.LOGIN_STATE.SUFFIX.get()); - OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY = UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.DISPLAY_MET_PLAYERS_ONLY.ENABLED.get(); - OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED = Math.pow(UHConfig.SCOREBOARD.OWN_TEAM.CONTENT.DISPLAY_MET_PLAYERS_ONLY.DISPLAYED_WHEN_CLOSER_THAN.get(), 2); - - BORDER_DISPLAY_DIAMETER = UHConfig.SCOREBOARD.BORDER.DISPLAY_DIAMETER.get(); - - FROOZEN_NULL_TIMER_TEXT = new Timer("").toString(); - - setAsync(true); - setAutoRefreshDelay(20); - setContentMode(SidebarMode.PER_PLAYER); - - sidebarTitle = ChatColor.translateAlternateColorCodes('&', UHConfig.SCOREBOARD.TITLE.get()); - } - - @Override - public void preRender() - { - sidebarTop.clear(); - sidebarBorder.clear(); - sidebarTimers.clear(); - - // Top sidebar - - if (EPISODES_ENABLED && EPISODES_IN_SIDEBAR) - { - /// Current episode in the sidebar - sidebarTop.add(I.t("{gray}Episode {white}{0}", - String.valueOf(gameManager.isGameStarted() ? gameManager.getEpisode() : 0) - )); - } - - if (!gameManager.isGameStarted()) - { - if (PLAYERS_IN_SIDEBAR) - /// Players alive in the sidebar - sidebarTop.add(I.tn("{white}{0}{gray} player", "{white}{0}{gray} players", Bukkit.getOnlinePlayers().size(), Bukkit.getOnlinePlayers().size())); - } - else - { - if (gameManager.isGameWithTeams() && EPISODES_ENABLED && EPISODES_IN_SIDEBAR) - sidebarTop.add(""); - - if (PLAYERS_IN_SIDEBAR) - /// Players alive in the sidebar - sidebarTop.add(I.tn("{white}{0}{gray} player", "{white}{0}{gray} players", gameManager.getAlivePlayersCount(), gameManager.getAlivePlayersCount())); - - if (gameManager.isGameWithTeams() && TEAMS_IN_SIDEBAR) - /// Teams alive in the sidebar - sidebarTop.add(I.tn("{white}{0}{gray} team", "{white}{0}{gray} teams", gameManager.getAliveTeamsCount(), gameManager.getAliveTeamsCount())); - } - - - // Border part of the sidebar - - if (gameManager.isGameStarted()) - { - insertBorder(sidebarBorder); - } - - - // Timers part of the sidebar - - insertTimers(sidebarTimers); - - if (TIMER_IN_SIDEBAR) - { - if (!gameManager.isGameStarted()) - sidebarTimers.add(FROOZEN_NULL_TIMER_TEXT); - else - { - //final Timer mainTimer = UHCReloaded.get().getTimerManager().getMainTimer(); - //if (mainTimer != null) sidebarTimers.add(mainTimer.toString()); - } - } - } - - @Override - public List<String> getContent(Player player) - { - List<String> sidebar = new ArrayList<>(sidebarTop); - sidebar.add(""); - - if (OWN_TEAM_IN_SIDEBAR && gameManager.isGameStarted() && gameManager.isGameWithTeams()) - { - ZTeam team = ZTeams.get().getTeamForPlayer(player); - - if (team != null) - { - sidebar.add( - (OWN_TEAM_TITLE_COLOR.isEmpty() ? team.getColorOrWhite().toChatColor() : OWN_TEAM_TITLE_COLOR) - /// Title of the team section in the sidebar - + (OWN_TEAM_TITLE_IS_NAME ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) - ); - - Location playerLocation = player.getLocation(); - - for (UUID teamMember : team.getPlayersUUID()) - { - SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(teamMember); - - // If enabled, we check if the player was already met or is close to this player. - // Only if the damages are on (= 30 seconds after the game start) to avoid false close while - // teleporting. - if(OWN_TEAM_DISPLAY_MET_PLAYERS_ONLY) - { - if(!(teamMember.equals(player.getUniqueId()) || cache.getMetTeammates().contains(teamMember))) - { - if (gameManager.isGameStarted() && gameManager.isTakingDamage()) - { - if (gameManager.isPlayerDead(teamMember)) - continue; // dead (spectators don't have to be displayed in the sidebar). - - Player teammate = Sidebar.getPlayerAsync(teamMember); - if (teammate == null) - continue; // offline - - - Location teammateLocation = teammate.getLocation(); - - // Check if the players are close - if (teammateLocation.getWorld().equals(playerLocation.getWorld())) - { -// final double distanceSquared = teammateLocation.distanceSquared(playerLocation); -// if (distanceSquared <= OWN_TEAM_DISPLAY_MET_PLAYERS_MIN_DISTANCE_SQUARED) -// cache.getMetTeammates().add(teamMember); -// else -// continue; // Too far, skipped - } - else - { - continue; // Too far, skipped - } - } - else - { - continue; - } - } - } - -// final String strike = OWN_TEAM_STRIKE_DEAD_PLAYERS && !cache.isAlive() ? ChatColor.STRIKETHROUGH.toString() : ""; -// final ChatColor aliveColor = cache.isAlive() ? ChatColor.WHITE : ChatColor.GRAY; - -// final String heart = OWN_TEAM_DISPLAY_HEARTS ? cache.getHealthColor() + strike + HEART + " " : ""; -// final String name = (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) -// + strike -// + (OWN_TEAM_DISPLAY_LOGIN_STATE_ITALIC && !cache.isOnline() ? ChatColor.ITALIC : "") -// + cache.getPlayerName() -// + (!cache.isOnline() ? ChatColor.RESET + "" + (OWN_TEAM_COLOR_WHOLE_NAME ? cache.getHealthColor() : aliveColor) + " " + OWN_TEAM_DISPLAY_LOGIN_STATE_SUFFIX : ""); -// -// sidebar.add(heart + name); - } - - sidebar.add(""); - } - } - - sidebar.addAll(sidebarBorder); - - if (KILLS_IN_SIDEBAR && gameManager.isGameStarted()) - { - SidebarPlayerCache cache = UHCReloaded.get().getScoreboardManager().getSidebarPlayerCache(player.getUniqueId()); - - /// Kills count in the sidebar -// sidebar.add(I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", cache.getPlayersKilled().size(), cache.getPlayersKilled().size())); - sidebar.add(""); - } - - sidebar.addAll(sidebarTimers); - - if (FREEZE_STATUS_IN_SIDEBAR) - { - insertFreezeStatus(sidebar, player); - } - - return sidebar; -// return null; - } - - @Override - public String getTitle(Player player) - { - return sidebarTitle; - } - - - /** - * Inserts the border status in the given list, to be displayed in the sidebar. - * - * @param sidebar The list representing the sidebar's content. - */ - private void insertBorder(List<String> sidebar) - { - if (BORDER_IN_SIDEBAR) - { - /// Title of the border section in the sidebar - sidebar.add(I.t("{blue}{bold}Border")); - - int diameter = (int) Math.ceil(border.getDiameter()); - - if (BORDER_DISPLAY_DIAMETER || border.getShape() == MapShape.CIRCULAR) - { - if (border.getShape() == MapShape.SQUARED) - /// Border diameter for a squared map in the sidebar - sidebar.add(I.tn("{white}{0} block wide", "{white}{0} blocks wide", diameter, diameter)); - else - /// Border diameter for a circular map in the sidebar - sidebar.add(I.tn("{gray}Diameter: {white}{0} block", "{gray}Diameter: {white}{0} blocks", diameter, diameter)); - } - else - { - Location center = border.getCenter(); - int radius = (int) Math.ceil(diameter / 2); - - int minX = center.getBlockX() - radius; - int maxX = center.getBlockX() + radius; - int minZ = center.getBlockZ() - radius; - int maxZ = center.getBlockZ() + radius; - - // Same min & max, we can display both at once - if (minX == minZ && maxX == maxZ) - { - /// Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxZ))); - } - else - { - /// Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}X: {white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxX))); - /// Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}Z: {white}{0} {1}", UHUtils.integerToStringWithSign(minZ), UHUtils.integerToStringWithSign(maxZ))); - } - } - - sidebar.add(""); - } - } - - /** - * Inserts the timers in the given list, to be displayed in the sidebar, at the bottom of the - * list. - * - * @param sidebar The list representing the sidebar's content. - */ - private void insertTimers(List<String> sidebar) - { -// UHCReloaded.get().getTimerManager().getTimers().stream().filter(Timer::isDisplayed).forEach(timer -> { -// sidebar.add(timer.getDisplayName()); -// sidebar.add(timer.toString()); -// sidebar.add(""); -// }); - } - - /** - * Inserts the « frozen » text at the bottom of the list, if active globally or for the given - * player. - * - * @param sidebar The list representing the sidebar's content. - */ - private void insertFreezeStatus(List<String> sidebar, Player player) - { - final Freezer freezer = UHCReloaded.get().getFreezer(); - - if ((freezer.getGlobalFreezeState() && !freezer.isHiddenFreeze()) || freezer.isPlayerFrozen(player)) - { - sidebar.add(""); - /// Notice displayed at the bottom of the sidebar if the game is paused (/uh freeze all). - sidebar.add(I.t("{darkaqua}Game frozen")); - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java deleted file mode 100644 index 37859e2..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/ScoreboardManager.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.scoreboard; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarCacheListener; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; -import fr.zcraft.zlib.components.scoreboard.Sidebar; -import fr.zcraft.zlib.tools.runners.RunTask; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.scoreboard.Criterias; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - - -public class ScoreboardManager -{ - private UHCReloaded p; - - private Map<UUID, SidebarPlayerCache> sidebarCache = new ConcurrentHashMap<>(); - - private final Scoreboard sb; - private Sidebar sidebar = null; - - - public ScoreboardManager(UHCReloaded p) - { - this.p = p; - this.sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); - - UHCReloaded.get().getServer().getPluginManager().registerEvents(new SidebarCacheListener(), UHCReloaded.get()); - - - // Initialization of the scoreboard (match info in the sidebar) - if (UHConfig.SCOREBOARD.ENABLED.get()) - { - sidebar = new GameSidebar(); - - Bukkit.getOnlinePlayers().forEach(player -> sidebar.addRecipient(player)); - - sidebar.runAutoRefresh(true); - } - - // Initialization of the scoreboard (health in players' list) - if (UHConfig.SCOREBOARD.HEALTH.get()) - { - final Objective healthObjective = sb.registerNewObjective("Health", Criterias.HEALTH); - healthObjective.setDisplayName("Health"); - healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); - - // Sometimes, the health is initialized to 0. This is used to fix this. - updateHealthScore(); - } - else - { - sb.clearSlot(DisplaySlot.PLAYER_LIST); // Just in case - } - - // Initialization of the sidebar cache - // Initializes the object. - Bukkit.getOnlinePlayers().stream().map(Entity::getUniqueId).forEach(this::getSidebarPlayerCache); - } - - - /** - * Updates the health score for all players. - */ - public void updateHealthScore() - { - p.getServer().getOnlinePlayers().forEach(this::updateHealthScore); - } - - /** - * Updates the health score for the given player. - * - * @param player The player to update. - */ - public void updateHealthScore(final Player player) - { - if (player.getHealth() != 1d) // Prevents killing the player - { - player.setHealth(player.getHealth() - 1); - - RunTask.later(() -> - { - if (player.getHealth() <= 19d) // Avoids an IllegalArgumentException - { - player.setHealth(player.getHealth() + 1); - } - }, 3L); - } - } - - /** - * Tells the player's client to use this scoreboard. - * - * @param p The player. - */ - public void setScoreboardForPlayer(Player p) - { - p.setScoreboard(sb); - sidebar.addRecipient(p); - } - - /** - * Returns the title of the scoreboard, truncated at 32 characters. - * - * @return The name - */ - public String getScoreboardName() - { - String s = ChatColor.translateAlternateColorCodes('&', UHConfig.SCOREBOARD.TITLE.get()); - return s.substring(0, Math.min(s.length(), 32)); - } - - /** - * Returns the internal scoreboard. - * - * @return The internal scoreboard. - */ - public Scoreboard getScoreboard() - { - return sb; - } - - /** - * Returns the cached data about the given player. - * - * @param id The player's UUID. - * @return The cached data, created on the fly if needed. - */ - public SidebarPlayerCache getSidebarPlayerCache(UUID id) - { - return sidebarCache.computeIfAbsent(id, SidebarPlayerCache::new); - } - - public Map<UUID, SidebarPlayerCache> getAllSidebarPlayerCache() - { - return sidebarCache; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ColorsUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ColorsUtils.java deleted file mode 100644 index 4b7470d..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ColorsUtils.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.utils; - -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; - - -public final class ColorsUtils -{ - private ColorsUtils() {} - - public static DyeColor chat2Dye(ChatColor chatColor) - { - switch (chatColor) - { - case BLACK: - return DyeColor.BLACK; - - case BLUE: - case DARK_BLUE: - return DyeColor.BLUE; - - case DARK_GREEN: - return DyeColor.GREEN; - - case DARK_AQUA: - return DyeColor.CYAN; - - case DARK_RED: - return DyeColor.RED; - - case DARK_PURPLE: - return DyeColor.PURPLE; - - case GOLD: - case YELLOW: - return DyeColor.YELLOW; - - case GRAY: - case DARK_GRAY: - return DyeColor.SILVER; - - case GREEN: - return DyeColor.LIME; - - case AQUA: - return DyeColor.LIGHT_BLUE; - - case RED: - return DyeColor.ORANGE; - - case LIGHT_PURPLE: - return DyeColor.PINK; - - // White, reset & formatting - default: - return DyeColor.WHITE; - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java similarity index 56% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java index db8c2d0..62bb464 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/core/utils/CommandUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java @@ -29,134 +29,21 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.commands.core.utils; +package eu.carrade.amaury.UHCReloaded.utils; -import eu.carrade.amaury.UHCReloaded.old.commands.core.AbstractCommand; -import eu.carrade.amaury.UHCReloaded.old.commands.core.annotations.Command; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.text.Collator; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class CommandUtils { public final static String CHAT_SEPARATOR = ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"; - /** - * Returns {@code true} if the sender is allowed to execute the given command. - * - * <p> - * Use that only if you have an isolated UHCommand object. Not if you have a direct access to - * the parent command, or if you know the command is a root command. - * </p> - * - * @param sender The sender. - * @param command The command. - * - * @return {@code true} if the sender is allowed to execute the command. - */ - public static boolean isAllowed(CommandSender sender, AbstractCommand command) - { - // root command - if (command.getParent() == null) - { - Command commandAnnotation = command.getClass().getAnnotation(Command.class); - if (commandAnnotation != null) - { - if (commandAnnotation.permission() == null) - { - return true; - } - else if (commandAnnotation.permission().isEmpty()) - { - return sender.hasPermission(commandAnnotation.name()); - } - else - { - return sender.hasPermission(commandAnnotation.permission()); - } - } - } - else - { - return sender.hasPermission(command.getParent().getSubcommandsPermissions().get(command.getClass().getAnnotation(Command.class).name())); - } - - return false; // should never happens. - } - - /** - * Returns the args without the first item. - * - * @param args The arguments sent to the parent command. - * @return The arguments to send to the child command. - */ - public static String[] getSubcommandArguments(String[] args) - { - if (args.length <= 1) - { - return new String[0]; - } - - return Arrays.copyOfRange(args, 1, args.length); - } - - - /** - * Returns the tags in the arguments, following the format "tagname:value". - * - * <p> - * If a tag is defined multiple times, the value used is the last one. - * </p> - * <p> - * Invalid tags (other format that « key:value ») are ignored. - * </p> - * - * @param args The args. - * @param defaults The defaults values. The values defined here will always be in the returned map, - * with the same value if the key is not in the arguments. - * {@code null} if no default values are needed. - * - * @return A map tagname -> value. - */ - public static Map<String, String> getTagsInArgs(String[] args, Map<String, String> defaults) - { - Map<String, String> tagsCollected; - - if (defaults != null) - { - tagsCollected = new HashMap<>(defaults); - } - else - { - tagsCollected = new HashMap<>(); - } - - for (String arg : args) - { - String[] argSpilt = arg.split(":"); - if (argSpilt.length >= 2) // valid - { - String key = argSpilt[0]; - String value = StringUtils.join(Arrays.copyOfRange(argSpilt, 1, argSpilt.length), ":"); - - tagsCollected.put(key, value); - } - } - - return tagsCollected; - } - - /** * Returns a list of autocompletion suggestions based on what the user typed and on a list of * available commands. From 507af3b73ca3290b5f51c4ab3257b79c8ccaada3 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 18 Jan 2019 16:45:45 +0100 Subject: [PATCH 53/91] Freezer module --- .../amaury/UHCReloaded/UHCReloaded.java | 6 +- .../ingame/freezer/FreezeCommand.java} | 120 +++++++-------- .../ingame/freezer}/FreezerListener.java | 63 ++------ .../ingame/freezer/FreezerModule.java} | 138 +++++++++++------- .../amaury/UHCReloaded/shortcuts/UR.java | 9 ++ src/main/resources/config.yml | 1 + 6 files changed, 165 insertions(+), 172 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/commands/commands/uh/UHFreezeCommand.java => modules/ingame/freezer/FreezeCommand.java} (53%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/listeners => modules/ingame/freezer}/FreezerListener.java (73%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/misc/Freezer.java => modules/ingame/freezer/FreezerModule.java} (67%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 20057f0..b04044b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -42,7 +42,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.old.misc.Freezer; +import eu.carrade.amaury.UHCReloaded.modules.ingame.freezer.FreezerModule; import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Commands; @@ -85,7 +85,7 @@ public class UHCReloaded extends ZPlugin implements Listener private RulesManager rulesManager = null; - private Freezer freezer = null; + private FreezerModule freezer = null; @Override @@ -294,7 +294,7 @@ public RulesManager getRulesManager() /** * Returns the freezer. */ - public Freezer getFreezer() + public FreezerModule getFreezer() { return freezer; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java similarity index 53% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java index 22d05aa..59aa893 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHFreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java @@ -29,18 +29,19 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.command.CommandSender; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * This command freezes the players. @@ -52,23 +53,23 @@ * - none: unfreezes all the alive players (even if there where frozen before using * /uh freeze all), the mobs and the timer. */ -public class UHFreezeCommand// extends AbstractCommand +@CommandInfo (name = "freeze", usageParameters = "<on|off|all|none> [target]") +public class FreezeCommand extends Command { - private UHCReloaded p; - - public UHFreezeCommand(UHCReloaded plugin) - { - p = plugin; - } - - public void run(CommandSender sender, String[] args)// throws CannotExecuteCommandException + @Override + public void run() throws CommandException { if (args.length == 0) { - //throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); + info(I.t("{aqua}------ Freeze commands ------")); + info(I.t("{cc}/uh freeze on [player]{ci}: freezes a player, or the sender without a specified player.")); + info(I.t("{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if the entire game is frozen.")); + info(I.t("{cc}/uh freeze all{ci}: freezes the entire game (players, mobs, timer).")); + info(I.t("{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this in order to relaunch the timer.")); + return; } - String subCommand = args[0]; + final String subCommand = args[0]; if (subCommand.equalsIgnoreCase("on") || subCommand.equalsIgnoreCase("off")) { @@ -77,45 +78,40 @@ public void run(CommandSender sender, String[] args)// throws CannotExecuteComma // /uh freeze on: freezes the sender if (args.length == 1) { - if (sender instanceof Player) - { - p.getFreezer().setPlayerFreezeState((Player) sender, on); + UR.module(FreezerModule.class).setPlayerFreezeState(playerSender(), on); - if (on) - { - sender.sendMessage(I.t("{cst}You where frozen by {0}.", sender.getName())); - } - else - { - sender.sendMessage(I.t("{cst}You where unfrozen by {0}.", sender.getName())); - } + if (on) + { + info(I.t("{cst}You where frozen by {0}.", sender.getName())); } else { - //throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); + info(I.t("{cst}You where unfrozen by {0}.", sender.getName())); } } // /uh freeze on <player>: freezes <player>. else if (args.length == 2) { - Player player = p.getServer().getPlayer(args[1]); + final Player player = getPlayerParameter(1); + if (player == null) { - sender.sendMessage(I.t("{ce}{0} is offline!", args[1])); + error(I.t("{ce}{0} is offline!", args[1])); } else { - p.getFreezer().setPlayerFreezeState(player, on); + UR.module(FreezerModule.class).setPlayerFreezeState(player, on); + if (on) { player.sendMessage(I.t("{cst}You where frozen by {0}.", sender.getName())); - sender.sendMessage(I.t("{cs}{0} is now frozen.", player.getName())); + success(I.t("{cs}{0} is now frozen.", player.getName())); } else { player.sendMessage(I.t("{cst}You where unfrozen by {0}.", sender.getName())); - sender.sendMessage(I.t("{cs}{0} is now unfrozen.", player.getName())); + success(I.t("{cs}{0} is now unfrozen.", player.getName())); } } } @@ -125,41 +121,49 @@ else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none { final boolean on = subCommand.equalsIgnoreCase("all"); - p.getFreezer().setGlobalFreezeState(on); + UR.module(FreezerModule.class).setGlobalFreezeState(on); + Bukkit.broadcastMessage(""); if (on) { - p.getServer().broadcastMessage(I.t("{darkaqua}The entire game is now frozen.")); + Bukkit.broadcastMessage(I.t("{darkaqua}The entire game is now frozen.")); } else { - p.getServer().broadcastMessage(I.t("{darkaqua}The game is now unfrozen.")); + Bukkit.broadcastMessage(I.t("{darkaqua}The game is now unfrozen.")); } - + Bukkit.broadcastMessage(""); } } - public List<String> tabComplete(CommandSender sender, String[] args) + @Override + public List<String> complete() { if (args.length == 1) { - return CommandUtils.getAutocompleteSuggestions( - args[0], Arrays.asList("on", "off", "all", "none") - ); + return getMatchingSubset(args[0], "on", "off", "all", "none"); } else if (args.length == 2) { if (args[0].equalsIgnoreCase("off")) { - List<String> suggestions = new ArrayList<>(); - - for (Player player : p.getFreezer().getFrozenPlayers()) - { - suggestions.add(player.getName()); - } + return getMatchingSubset( + UR.module(FreezerModule.class).getFrozenPlayers().stream() + .map(OfflinePlayer::getName) + .collect(Collectors.toSet()), + args[1]); + } - return CommandUtils.getAutocompleteSuggestions(args[1], suggestions); + else if (args[0].equalsIgnoreCase("on")) + { + return getMatchingSubset( + UR.game().getAlivePlayers().stream() + .filter(player -> !UR.module(FreezerModule.class).isPlayerFrozen(player)) + .map(OfflinePlayer::getName) + .collect(Collectors.toSet()), + args[1] + ); } else return null; @@ -167,20 +171,4 @@ else if (args.length == 2) else return null; } - - public List<String> help(CommandSender sender) - { - return Arrays.asList( - I.t("{aqua}------ Freeze commands ------"), - I.t("{cc}/uh freeze on [player]{ci}: freezes a player, or the sender without a specified player."), - I.t("{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if the entire game is frozen."), - I.t("{cc}/uh freeze all{ci}: freezes the entire game (players, mobs, timer)."), - I.t("{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this in order to relaunch the timer.") - ); - } - - public List<String> onListHelp(CommandSender sender) - { - return Collections.singletonList(I.t("{cc}/uh freeze {ci}: (un)freezes the entire game, or a player. See /uh freeze for details.")); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java similarity index 73% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java index 515903f..144463b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/FreezerListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java @@ -30,88 +30,63 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.listeners; +package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.player.PlayerMoveEvent; public class FreezerListener implements Listener { - - private UHCReloaded p = null; - - public FreezerListener() - { - this.p = UHCReloaded.get(); - } - - /** * Used to prevent frozen players to break blocks. - * - * @param ev */ @EventHandler public void onBlockBreakEvent(final BlockBreakEvent ev) { - if (p.getFreezer().isPlayerFrozen(ev.getPlayer())) + if (UR.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } } - /** * Used to prevent frozen players to place blocks. - * - * @param ev */ @EventHandler public void onBlockPlaceEvent(final BlockPlaceEvent ev) { - if (p.getFreezer().isPlayerFrozen(ev.getPlayer())) + if (UR.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } } - /** * Used to freeze the players. - * - * @param ev */ @EventHandler public void onPlayerMove(PlayerMoveEvent ev) { - p.getFreezer().freezePlayerIfNeeded(ev.getPlayer(), ev.getFrom(), ev.getTo()); + UR.module(FreezerModule.class).freezePlayerIfNeeded(ev.getPlayer(), ev.getFrom(), ev.getTo()); } - /** * Used to prevent the bows to be used while in global freeze mode. - * - * @param ev */ @EventHandler public void onEntityShoot(EntityShootBowEvent ev) { - if ((ev.getEntity() instanceof Player && p.getFreezer().isPlayerFrozen((Player) ev.getEntity())) - || p.getFreezer().getGlobalFreezeState()) + if ((ev.getEntity() instanceof Player && UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) + || UR.module(FreezerModule.class).getGlobalFreezeState()) { - ev.setCancelled(true); // If a shoot from a player is cancelled, the arrow seems to be @@ -124,47 +99,39 @@ public void onEntityShoot(EntityShootBowEvent ev) } } - /** - * Used to prevent items from despawning if the game is frozen. - * - * @param ev + * Used to prevent items from de-spawning if the game is frozen. */ @EventHandler public void onItemDespawn(ItemDespawnEvent ev) { - if (p.getFreezer().getGlobalFreezeState()) + if (UR.module(FreezerModule.class).getGlobalFreezeState()) { ev.setCancelled(true); } } - /** * Used to freeze the mobs spawning while the game is frozen. - * @param ev */ @EventHandler public void onEntitySpawn(CreatureSpawnEvent ev) { - if (p.getFreezer().getGlobalFreezeState() && ev.getEntity() instanceof Creature) + if (UR.module(FreezerModule.class).getGlobalFreezeState() && ev.getEntity() instanceof Creature) { - p.getFreezer().freezeCreature((Creature) ev.getEntity(), true); + UR.module(FreezerModule.class).freezeCreature((Creature) ev.getEntity(), true); } } - /** * Used to disable any damages if the player is frozen. - * - * @param ev */ @EventHandler public void onEntityDamage(final EntityDamageEvent ev) { if (ev.getEntity() instanceof Player) { - if (p.getFreezer().isPlayerFrozen((Player) ev.getEntity())) + if (UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { ev.setCancelled(true); } @@ -173,13 +140,11 @@ public void onEntityDamage(final EntityDamageEvent ev) /** * Used to cancel any food loss (but the players can still eat). - * - * @param ev */ @EventHandler public void onFoodUpdate(FoodLevelChangeEvent ev) { - if (p.getFreezer().isPlayerFrozen((Player) ev.getEntity())) + if (UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { if (ev.getFoodLevel() < ((Player) ev.getEntity()).getFoodLevel()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java similarity index 67% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java index a7f6fbe..be36a52 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/Freezer.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java @@ -29,46 +29,88 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.misc; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.listeners.FreezerListener; +package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.core.ZLib; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; -public class Freezer +@ModuleInfo ( + name = "Freezer", + description = "Provides a command to freeze some or all players, " + + "allowing to “pause” the game.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.UTILITIES, + icon = Material.PACKED_ICE +) +public class FreezerModule extends UHModule { - private UHCReloaded p = null; - private boolean isListenerRegistered = false; - private FreezerListener freezerListener = null; + private FreezerListener freezerListener; - private Boolean globalFreeze = false; - private ArrayList<UUID> frozenPlayers = new ArrayList<>(); - private HashMap<UUID, Boolean> oldAllowFly = new HashMap<>(); - private HashMap<UUID, Boolean> oldFlyMode = new HashMap<>(); + private boolean globalFreeze = false; + private final Set<UUID> frozenPlayers = new HashSet<>(); + private final Map<UUID, Boolean> oldAllowFly = new HashMap<>(); + private final Map<UUID, Boolean> oldFlyMode = new HashMap<>(); private boolean hiddenFreeze = false; - public Freezer(UHCReloaded plugin) + @Override + public void onEnable() { - this.p = plugin; - this.freezerListener = new FreezerListener(); } + @Override + protected void onDisable() + { + ZLib.unregisterEvents(freezerListener); + freezerListener = null; + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(FreezeCommand.class); + } + + @Override + public void injectIntoSidebar(Player player, SidebarInjector injector) + { + if (!hiddenFreeze) + { + if (globalFreeze) + { + /// Notice displayed at the bottom of the sidebar if the game is paused (/uh freeze all). + injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, I.t("{darkaqua}Game frozen")); + } + else if (isPlayerFrozen(player)) + { + injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, I.t("{darkaqua}You are frozen")); + } + } + } /** * Freezes a player, if needed. @@ -107,36 +149,34 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) if (frozen) { -// p.getGameManager() -// .getOnlineAlivePlayers() -// .forEach(player -> this.setPlayerFreezeState(player, true)); + UR.game().getAlivePlayers().forEach(player -> setPlayerFreezeState(player, true)); // Freezes the mobs by applying a Slowness effect. There isn't any EntityMoveEvent, so... - p.getServer().getWorlds().stream() + UR.get().getWorlds().stream() .flatMap(world -> world.getLivingEntities().stream()) .filter(entity -> entity instanceof Creature) .forEach(entity -> freezeCreature((Creature) entity, true)); // Freezes the timers. - // TODO p.getTimerManager().pauseAllRunning(true); + UR.module(TimersModule.class).pauseAllRunning(true); } else { // All the online players are listed, not the internal list of frozen players, // to avoid a ConcurrentModificationException if the iterated list is being emptied. - p.getServer().getOnlinePlayers().stream() + UR.game().getAlivePlayers().stream() .filter(this::isPlayerFrozen) .forEach(player -> this.setPlayerFreezeState(player, false)); // Removes the slowness effect - p.getServer().getWorlds().stream() + UR.get().getWorlds().stream() .flatMap(world -> world.getLivingEntities().stream()) .filter(entity -> entity instanceof Creature) .forEach(entity -> freezeCreature((Creature) entity, false)); // Unfreezes the timers. - // TODO p.getTimerManager().pauseAllRunning(false); + UR.module(TimersModule.class).pauseAllRunning(false); } updateListenerRegistration(); @@ -169,25 +209,28 @@ public boolean getGlobalFreezeState() * @param player The player to freeze. * @param frozen If true the player will be frozen. If false, unfrozen. */ - public void setPlayerFreezeState(Player player, Boolean frozen) + public void setPlayerFreezeState(OfflinePlayer player, Boolean frozen) { - if (frozen && !this.frozenPlayers.contains(player.getUniqueId())) + if (frozen && !frozenPlayers.contains(player.getUniqueId())) { this.frozenPlayers.add(player.getUniqueId()); - this.oldAllowFly.put(player.getUniqueId(), player.getAllowFlight()); - this.oldFlyMode.put(player.getUniqueId(), player.isFlying()); + this.oldAllowFly.put(player.getUniqueId(), player.isOnline() && player.getPlayer().getAllowFlight()); + this.oldFlyMode.put(player.getUniqueId(), player.isOnline() && player.getPlayer().isFlying()); // Used to prevent the player to be kicked for fly if he was frozen during a fall. // He is blocked inside his current block anyway. - player.setAllowFlight(true); + if (player.isOnline()) player.getPlayer().setAllowFlight(true); } - if (!frozen && this.frozenPlayers.contains(player.getUniqueId())) + if (!frozen && frozenPlayers.contains(player.getUniqueId())) { this.frozenPlayers.remove(player.getUniqueId()); - player.setFlying(this.oldFlyMode.get(player.getUniqueId())); - player.setAllowFlight(this.oldAllowFly.get(player.getUniqueId())); + if (player.isOnline()) + { + player.getPlayer().setFlying(oldFlyMode.get(player.getUniqueId())); + player.getPlayer().setAllowFlight(oldAllowFly.get(player.getUniqueId())); + } this.oldAllowFly.remove(player.getUniqueId()); this.oldFlyMode.remove(player.getUniqueId()); @@ -202,28 +245,18 @@ public void setPlayerFreezeState(Player player, Boolean frozen) * @param player The player to be checked. * @return true if the given player is frozen. */ - public boolean isPlayerFrozen(Player player) + public boolean isPlayerFrozen(final OfflinePlayer player) { return frozenPlayers.contains(player.getUniqueId()); } - /** - * Returns {@code true} if the current freeze must be hidden in the sidebar. - * - * @return {@code true} to hide it. - */ - public boolean isHiddenFreeze() - { - return hiddenFreeze; - } - /** * (Un)freezes a creature. * * @param creature The creature to freeze. * @param frozen If true the creature will be frozen. Else... */ - public void freezeCreature(Creature creature, Boolean frozen) + public void freezeCreature(final Creature creature, final boolean frozen) { if (frozen) { @@ -251,7 +284,7 @@ private void updateListenerRegistration() { if (!this.frozenPlayers.isEmpty() || this.getGlobalFreezeState()) { - p.getServer().getPluginManager().registerEvents(freezerListener, p); + ZLib.registerEvents(freezerListener); this.isListenerRegistered = true; } } @@ -261,7 +294,7 @@ private void updateListenerRegistration() { if (this.frozenPlayers.isEmpty() && !this.getGlobalFreezeState()) { - HandlerList.unregisterAll(freezerListener); + ZLib.unregisterEvents(freezerListener); this.isListenerRegistered = false; } } @@ -273,11 +306,8 @@ private void updateListenerRegistration() * * @return The list. */ - public ArrayList<Player> getFrozenPlayers() + public Set<OfflinePlayer> getFrozenPlayers() { - - return frozenPlayers.stream() - .map(id -> p.getServer().getPlayer(id)) - .collect(Collectors.toCollection(ArrayList::new)); + return frozenPlayers.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toSet()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index 0be2303..a276a33 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -38,6 +38,7 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleLogger; import eu.carrade.amaury.UHCReloaded.core.ModulesManager; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.reflection.Reflection; import org.apache.commons.lang.ArrayUtils; @@ -101,6 +102,14 @@ public static UHModule module() throw new IllegalArgumentException("The class " + caller.getCanonicalName() + " is not inside a module's package."); } + /** + * @return The game module, because it is heavily used through the codebase. + */ + public static GameModule game() + { + return module(GameModule.class); + } + /** * Returns the logger for a given module. This may return null if the module is not * currently loaded. diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3db8121..9b57501 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -39,6 +39,7 @@ modules: "ingame-killsCount": true "ingame-deathAnnouncement": true "ingame-kick": false + "ingame-freezer": true "gameplay-compass": true "gameplay-goldenHeads": true From c94ab0c9a50650b9497d05c350f301470c630d7b Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 18 Jan 2019 17:02:01 +0100 Subject: [PATCH 54/91] Rules module --- .../amaury/UHCReloaded/UHCReloaded.java | 6 +- .../modules/other/rules/Config.java | 62 +++++++++++++ .../other/rules/RulesCommand.java} | 58 +++++------- .../other/rules/RulesModule.java} | 93 +++++++++++-------- src/main/resources/config.yml | 1 + 5 files changed, 144 insertions(+), 76 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/commands/commands/uh/UHRulesCommand.java => modules/other/rules/RulesCommand.java} (62%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/misc/RulesManager.java => modules/other/rules/RulesModule.java} (63%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index b04044b..484332f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -43,7 +43,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; import eu.carrade.amaury.UHCReloaded.modules.ingame.freezer.FreezerModule; -import eu.carrade.amaury.UHCReloaded.old.misc.RulesManager; +import eu.carrade.amaury.UHCReloaded.modules.other.rules.RulesModule; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.gui.Gui; @@ -83,7 +83,7 @@ public class UHCReloaded extends ZPlugin implements Listener private boolean worldsLoaded = false; - private RulesManager rulesManager = null; + private RulesModule rulesManager = null; private FreezerModule freezer = null; @@ -286,7 +286,7 @@ private World setDefaultWorld(final World.Environment environment, final String /** * @return the rules manager. */ - public RulesManager getRulesManager() + public RulesModule getRulesManager() { return rulesManager; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java new file mode 100644 index 0000000..b554d25 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java @@ -0,0 +1,62 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.other.rules; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.zlib.components.configuration.ConfigurationSection; + +import java.io.File; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final DisplaySection DISPLAY = section("display", DisplaySection.class); + + static public class DisplaySection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ON_JOIN = item("onJoin", false); + public final ConfigurationItem<Boolean> ON_START = item("onStart", true); + } + + public static final ConfigurationList<String> RULES = list("rules", String.class); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java similarity index 62% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java index 4aaf10f..4126540 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/commands/commands/uh/UHRulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java @@ -29,43 +29,41 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.commands.commands.uh; +package eu.carrade.amaury.UHCReloaded.modules.other.rules; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.Collections; import java.util.List; +import java.util.Optional; -public class UHRulesCommand// extends AbstractCommand +@CommandInfo (name = "rules", usageParameters = "[player]") +public class RulesCommand extends Command { - private UHCReloaded p; - - public UHRulesCommand(UHCReloaded plugin) - { - p = plugin; - } - - public void run(CommandSender sender, String[] args)// throws CannotExecuteCommandException + public void run() throws CommandException { - if (!p.getRulesManager().isEnabled()) + if (!UR.module(RulesModule.class).hasRules()) { - sender.sendMessage(I.t("{ce}No rules are set in the config file.")); - return; + error(I.t("{ce}No rules are set in the config file.")); } if (args.length >= 1) { - Player player = Bukkit.getPlayer(args[0]); - if (player != null) + final Optional<? extends Player> player = Bukkit.getOnlinePlayers().stream() + .filter(onlinePlayer -> onlinePlayer.getName().equalsIgnoreCase(args[0].trim())) + .findAny(); + + if (player.isPresent()) { - p.getRulesManager().displayRulesTo(player); + UR.module(RulesModule.class).displayRulesTo(player.get()); - if (!sender.equals(player)) - sender.sendMessage(I.t("{cs}Rules sent to {0}.", player.getName())); + if (!sender.equals(player.get())) + sender.sendMessage(I.t("{cs}Rules sent to {0}.", player.get().getName())); } else { @@ -74,22 +72,14 @@ public void run(CommandSender sender, String[] args)// throws CannotExecuteComma } else { - p.getRulesManager().broadcastRules(); + UR.module(RulesModule.class).broadcastRules(); } } - public List<String> tabComplete(CommandSender sender, String[] args) - { - return null; - } - - public List<String> help(CommandSender sender) - { - return null; - } - - public List<String> onListHelp(CommandSender sender) + @Override + public List<String> complete() { - return Collections.singletonList(I.t("{cc}/uh rules [player] {ci}: sends the server rules to the server or the given player.")); + if (args.length == 1) return getMatchingPlayerNames(args[0]); + else return null; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java similarity index 63% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java index 54bc237..a43dcae 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java @@ -29,44 +29,56 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.misc; - -import eu.carrade.amaury.UHCReloaded.UHConfig; +package eu.carrade.amaury.UHCReloaded.modules.other.rules; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; +import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.command.CommandSender; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import java.util.ArrayList; +import java.util.Collections; import java.util.List; - -public class RulesManager +@ModuleInfo ( + name = "Rules", + description = "Displays configured game rules when the game start or the " + + "players join", + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.UTILITIES, + icon = Material.BOOKSHELF, + settings = Config.class +) +public class RulesModule extends UHModule { - private final boolean DISPLAY_ON_JOIN; - private final boolean DISPLAY_ON_START; - private final List<String> rules = new ArrayList<>(); - - public RulesManager() + @Override + public void onEnable() { - if (UHConfig.RULES.isDefined() && !UHConfig.RULES.RULES.isEmpty() ) + if (Config.RULES.isDefined() && !Config.RULES.isEmpty() ) { - DISPLAY_ON_JOIN = UHConfig.RULES.DISPLAY.ON_JOIN.get(); - DISPLAY_ON_START = UHConfig.RULES.DISPLAY.ON_START.get(); - - // We check if the list is non-empty, i.e. if there is at least a non-empty rule. boolean empty = true; - for (String rule : UHConfig.RULES.RULES) + for (final String rule : Config.RULES) { if (rule == null) continue; - rule = rule.trim(); - rules.add(ChatColor.translateAlternateColorCodes('&',rule)); + rules.add(ChatColor.translateAlternateColorCodes('&',rule.trim())); if (!rule.isEmpty()) empty = false; @@ -75,35 +87,20 @@ public RulesManager() // If the list is empty, no rules are displayed. We reset the list. if (empty) rules.clear(); } - else - { - DISPLAY_ON_JOIN = false; - DISPLAY_ON_START = true; - } } - /** - * @return {@code true} if the rules system is enabled - */ - public boolean isEnabled() + @Override + public List<Class<? extends Command>> getCommands() { - return rules.size() != 0; + return Collections.singletonList(RulesCommand.class); } /** - * @return {@code true} if the rules have to be displayed to every joining player. - */ - public boolean displayOnJoin() - { - return isEnabled() && DISPLAY_ON_JOIN; - } - - /** - * @return {@code true} if the rules have to be displayed when the game starts. + * @return {@code true} if the rules system is enabled */ - public boolean displayOnStart() + public boolean hasRules() { - return isEnabled() && DISPLAY_ON_START; + return rules.size() != 0; } @@ -143,4 +140,22 @@ public void broadcastRules() Bukkit.getOnlinePlayers().forEach(this::displayRulesTo); displayRulesTo(Bukkit.getConsoleSender()); } + + @EventHandler + public void onPlayerJoin(final PlayerJoinEvent ev) + { + if (UR.game().getPhase() == GamePhase.WAIT && hasRules() && Config.DISPLAY.ON_JOIN.get()) + { + RunTask.later(() -> { if (ev.getPlayer().isOnline()) displayRulesTo(ev.getPlayer()); }, 100L); + } + } + + @EventHandler + public void onGameStart(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward() && hasRules() && Config.DISPLAY.ON_START.get()) + { + RunTask.later(this::broadcastRules, 200L); + } + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9b57501..31bbfed 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -55,6 +55,7 @@ modules: "other-reports": true "other-playersLoader": true + "other-rules": true "other-about": true "scenarii-alliances": false From 0f1071e3faca73c11ec1ed03a2e41fcb443eee42 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 18 Jan 2019 18:25:21 +0100 Subject: [PATCH 55/91] Statistics & achievements --- .../UHCReloaded/core/ModulesManager.java | 3 +- .../modules/ingame/AdvancementsModule.java | 125 ++++++++++++++++++ .../modules/ingame/StatisticsModule.java | 111 ++++++++++++++++ src/main/resources/config.yml | 2 + 4 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index af05a88..4ff49ce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -40,6 +40,7 @@ import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.Commands; +import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.core.ZLibComponent; import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.reflection.Reflection; @@ -248,7 +249,7 @@ private void collectCommandsFromModules() { try { - pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), this), commandAlias.getValue()); + pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), ZLib.getPlugin()), commandAlias.getValue()); registered.add(commandAlias.getKey()); } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java new file mode 100644 index 0000000..6a16391 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java @@ -0,0 +1,125 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.events.FutureEventHandler; +import fr.zcraft.zlib.components.events.WrappedEvent; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.command.CommandException; +import org.bukkit.event.EventHandler; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + + +@ModuleInfo ( + name = "Advancements", + description = "Resets the advancements when the game starts. Disable if " + + "you want to keep old advancements.\n\n" + + "Even if the name corresponds to Minecraft 1.12+, this module " + + "also handles achievements for older Minecraft versions.", + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.OTHER, + icon = Material.HAY_BLOCK +) +public class AdvancementsModule extends UHModule +{ + @FutureEventHandler (event = "player.PlayerAchievementAwardedEvent", ignoreCancelled = true) + public void onAchievementAwarded(final WrappedEvent ev) + { + if (UR.game().getPhase() == GamePhase.WAIT) + { + ev.setCancelled(true); + } + } + + @EventHandler + public void onGameStarts(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + + + // Achievements + + try + { + final Object[] achievements = Class.forName("org.bukkit.Achievement").getEnumConstants(); + + UR.game().getAliveConnectedPlayers().forEach(player -> { + try + { + for (final Object achievement : achievements) + { + PluginLogger.info("Removing achievement {0}", achievement); + Reflection.call(player, "removeAchievement", achievement); + } + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} + }); + } + catch (final Exception ignored) {} // Unsupported + + + // Advancements + + final Map<String, String> oldGameRule = new HashMap<>(); + UR.get().getWorlds().forEach(world -> { + oldGameRule.put(world.getName(), world.getGameRuleValue("sendCommandFeedback")); + world.setGameRuleValue("sendCommandFeedback", "false"); + }); + + UR.game().getAliveConnectedPlayers().forEach(player -> { + try + { + // ¯\_(ツ)_/¯ + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "advancement revoke " + player.getName() + " everything"); + } + catch (final CommandException ignored) {} + }); + + UR.get().getWorlds().forEach(world -> world.setGameRuleValue("sendCommandFeedback", oldGameRule.get(world.getName()))); + oldGameRule.clear(); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java new file mode 100644 index 0000000..165bfc3 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java @@ -0,0 +1,111 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.ingame; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import org.bukkit.Material; +import org.bukkit.Statistic; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerStatisticIncrementEvent; + + +@ModuleInfo ( + name = "Statistics", + description = "If enabled, statistics will not be collected before the game" + + "and will be reset at the beginning of the game. Disable if you want " + + "to keep old statistics!", + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.OTHER, + icon = Material.WORKBENCH +) +public class StatisticsModule extends UHModule +{ + @EventHandler + public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) + { + if (UR.game().getPhase() == GamePhase.WAIT) + { + ev.setCancelled(true); + } + } + + @EventHandler + public void onGameStart(final GamePhaseChangedEvent ev) + { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) + { + UR.game().getAliveConnectedPlayers().forEach(player -> { + for (final Statistic statistic : Statistic.values()) + { + switch (statistic.getType()) + { + case UNTYPED: + player.setStatistic(statistic, 0); + break; + + case ITEM: + case BLOCK: + for (final Material material : Material.values()) + { + try + { + player.setStatistic(statistic, material, 0); + } + catch (final IllegalArgumentException ignored) {} + } + break; + + case ENTITY: + for (final EntityType entityType : EntityType.values()) + { + try + { + player.setStatistic(statistic, entityType, 0); + } + catch (final Exception ignored) {} + } + break; + } + } + }); + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 31bbfed..045f597 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,8 @@ modules: "ingame-deathAnnouncement": true "ingame-kick": false "ingame-freezer": true + "ingame-advancements": true + "ingame-statistics": true "gameplay-compass": true "gameplay-goldenHeads": true From c638f0db442ffafdddc2cc7e279513ee6d498f65 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 19 Jan 2019 16:30:11 +0100 Subject: [PATCH 56/91] Added a main configuration GUI + option to start the game. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → The game title was moved to UHConfig. → Added a GUI to configure the game: players, teams, modules, title, start. → Added a start GUI to start the game (slow/fast; with/without teams). → Fixes. --- .../carrade/amaury/UHCReloaded/UHConfig.java | 528 +---------------- .../modules/beginning/wait/Config.java | 8 + .../modules/beginning/wait/WaitModule.java | 198 ++++++- .../modules/core/game/GameModule.java | 3 +- .../core/modules/ModulesManagerModule.java | 6 +- ...Command.java => ConfigurationCommand.java} | 8 +- .../core/modules/gui/MainConfigGUI.java | 212 +++++++ .../ConfirmModuleDisableGUI.java | 16 +- .../gui/{ => modules}/FramedModuleGUI.java | 2 +- .../gui/{ => modules}/ModulesListGUI.java | 93 ++- .../core/modules/gui/start/StartGameGUI.java | 131 +++++ .../modules/core/sidebar/Config.java | 1 - .../modules/core/sidebar/GameSidebar.java | 3 +- .../commands/SpectatorsCommand.java | 13 +- .../modules/core/teams/Config.java | 3 +- .../modules/cosmetics/motd/MotdModule.java | 3 +- .../modules/other/reports/ReportsModule.java | 3 +- .../old/recipes/RecipesManager.java | 533 ------------------ .../amaury/UHCReloaded/utils/UHSound.java | 26 - 19 files changed, 646 insertions(+), 1144 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/{ModulesGUICommand.java => ConfigurationCommand.java} (90%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/{ => modules}/ConfirmModuleDisableGUI.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/{ => modules}/FramedModuleGUI.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/{ => modules}/ModulesListGUI.java (75%) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index d189d52..4d32f0b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -1,12 +1,7 @@ package eu.carrade.amaury.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.modules.beginning.cages.Cage; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import fr.zcraft.zlib.components.configuration.*; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.util.Vector; +import org.bukkit.ChatColor; import java.util.Locale; @@ -17,151 +12,18 @@ public class UHConfig extends Configuration { static public final ConfigurationItem<Locale> LANG = item("lang", Locale.class); + static public final ConfigurationItem<String> TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); + static public final ConfigurationMap<String, Boolean> MODULES = map("modules", String.class, Boolean.class); static public final WorldsSection WORLDS = section("worlds", WorldsSection.class); - static public class WorldsSection extends ConfigurationSection { + public final ConfigurationItem<String> OVERWORLD = item("overworld", "world"); public final ConfigurationItem<String> NETHER = item("nether", "world_nether"); public final ConfigurationItem<String> THE_END = item("the-end", "world_the_end"); - } - - - - - static public final EpisodesSection EPISODES = section("episodes", EpisodesSection.class); - - static public class EpisodesSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<String> LENGTH = item("length", "20:00"); - public final ConfigurationItem<Boolean> TITLE = item("title", true); - } - - static public final MapSection MAP = section("map", MapSection.class); - - static public class MapSection extends ConfigurationSection - { - public final ConfigurationItem<Integer> SIZE = item("size", 2000); - public final ConfigurationItem<MapShape> SHAPE = item("shape", MapShape.SQUARED); - - public final WallSection WALL = section("wall", WallSection.class); - - static public class WallSection extends ConfigurationSection - { - public final ConfigurationItem<Integer> HEIGHT = item("height", 128); - - public final BlockSection BLOCK = section("block", BlockSection.class); - - static public class BlockSection extends ConfigurationSection - { - public final ConfigurationItem<Material> REPLACE_AIR = item("replaceAir", Material.GLASS); - public final ConfigurationItem<Material> REPLACE_SOLID = item("replaceSolid", Material.BEDROCK); - } - } - - public final BorderSection BORDER = section("border", BorderSection.class); - - static public class BorderSection extends ConfigurationSection - { - public final ConfigurationItem<String> MOTOR = item("motor", "vanilla"); - public final ConfigurationItem<Double> DAMAGES_BUFFER = item("damagesBuffer", 5d); - public final ConfigurationItem<Double> DAMAGES_AMOUNT = item("damagesAmount", 0.2); - public final ConfigurationItem<Integer> WARNING_DISTANCE = item("warningDistance", 5); - - public final ShrinkingSection SHRINKING = section("shrinking", ShrinkingSection.class); - - static public class ShrinkingSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<String> STARTS_AFTER = item("startsAfter", "30:00"); - public final ConfigurationItem<String> SHRINKS_DURING = item("shrinksDuring", "2:00:00"); - public final ConfigurationItem<Integer> DIAMETER_AFTER_SHRINK = item("diameterAfterShrink", 200); - } - - public final ConfigurationItem<Integer> WARNING_INTERVAL = item("warningInterval", 90); - } - public final SpawnPointsSection SPAWN_POINTS = section("spawnPoints", SpawnPointsSection.class); - - static public class SpawnPointsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DONT_GENERATE_ABOVE_WATER = item("dontGenerateAboveWater", true); - } - } - - static public final DaylightCycleSection DAYLIGHT_CYCLE = section("daylightCycle", DaylightCycleSection.class); - - static public class DaylightCycleSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", false); - public final ConfigurationItem<Long> TIME = item("time", 6000l); - } - - static public final ScoreboardSection SCOREBOARD = section("scoreboard", ScoreboardSection.class); - - static public class ScoreboardSection extends ConfigurationSection - { - public final ConfigurationItem<String> TITLE = item("title", "Kill the Patrick"); - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Boolean> EPISODE = item("episode", true); - public final ConfigurationItem<Boolean> PLAYERS = item("players", true); - public final ConfigurationItem<Boolean> TEAMS = item("teams", true); - - public final OwnTeamSection OWN_TEAM = section("ownTeam", OwnTeamSection.class); - - static public class OwnTeamSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - - public final TitleSection TITLE = section("title", TitleSection.class); - - static public class TitleSection extends ConfigurationSection - { - public final ConfigurationItem<String> COLOR = item("color", ""); - public final ConfigurationItem<Boolean> USE_TEAM_NAME = item("useTeamName", false); - } - - public final ContentSection CONTENT = section("content", ContentSection.class); - - static public class ContentSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISPLAY_HEARTS = item("displayHearts", true); - public final ConfigurationItem<Boolean> COLOR_NAME = item("colorName", false); - public final ConfigurationItem<Boolean> STRIKE_DEAD_PLAYERS = item("strikeDeadPlayers", false); - - public final LoginStateSection LOGIN_STATE = section("loginState", LoginStateSection.class); - - static public class LoginStateSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ITALIC = item("italic", true); - public final ConfigurationItem<String> SUFFIX = item("suffix", "➥"); - } - - public final DisplayMetPlayersOnlySection DISPLAY_MET_PLAYERS_ONLY = section("displayMetPlayersOnly", DisplayMetPlayersOnlySection.class); - - static public class DisplayMetPlayersOnlySection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<Double> DISPLAYED_WHEN_CLOSER_THAN = item("displayedWhenCloserThan", 10d); - } - } - } - - public final BorderSection BORDER = section("border", BorderSection.class); - - static public class BorderSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISPLAYED = item("displayed", true); - public final ConfigurationItem<Boolean> DISPLAY_DIAMETER = item("displayDiameter", false); - } - - public final ConfigurationItem<Boolean> KILLS = item("kills", true); - public final ConfigurationItem<Boolean> TIMER = item("timer", true); - public final ConfigurationItem<Boolean> FREEZE_STATUS = item("freezeStatus", true); - public final ConfigurationItem<Boolean> HEALTH = item("health", true); } static public final PlayersListSection PLAYERS_LIST = section("playersList", PlayersListSection.class); @@ -185,307 +47,6 @@ static public class InGameTimeSection extends ConfigurationSection } } - static public final MotdSection MOTD = section("motd", MotdSection.class); - - static public class MotdSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<Boolean> DISPLAY_MATCH_NAME = item("displayMatchName", true); - public final ConfigurationItem<String> MATCH_NAME_PREFIX = item("matchNamePrefix", ""); - } - - static public final ConfigurationItem<Boolean> TELEPORT_TO_SPAWN_IF_NOT_STARTED = item("teleportToSpawnIfNotStarted", true); - - static public final AchievementsSection ACHIEVEMENTS = section("achievements", AchievementsSection.class); - - static public class AchievementsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> RESET_ACHIEVEMENTS_AT_STARTUP = item("resetAchievementsAtStartup", true); - public final ConfigurationItem<Boolean> DISABLE_ACHIEVEMENTS_BEFORE_START = item("disableAchievementsBeforeStart", true); - } - - static public final StatisticsSection STATISTICS = section("statistics", StatisticsSection.class); - - static public class StatisticsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISABLE_STATISTICS_BEFORE_START = item("disableStatisticsBeforeStart", true); - } - - static public final BeforeStartSection BEFORE_START = section("before-start", BeforeStartSection.class); - - static public class BeforeStartSection extends ConfigurationSection - { - public final InventorySection INVENTORY = section("inventory", InventorySection.class); - - static public class InventorySection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> CLEAR = item("clear", true); - public final ConfigurationItem<Boolean> PREVENT_USAGE = item("preventUsage", true); - public final ConfigurationItem<Boolean> ALLOW_FOR_BUILDERS = item("allowForBuilders", true); - } - - public final TeamSelectorSection TEAM_SELECTOR = section("teamSelector", TeamSelectorSection.class); - - static public class TeamSelectorSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Material> ITEM = item("item", Material.NETHER_STAR); - } - - public final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("teamInActionBar", true); - - public final ConfigurationItem<Boolean> ENABLE_PVP = item("enablePVP", false); - } - - static public final StartSection START = section("start", StartSection.class); - - static public class StartSection extends ConfigurationSection - { - public final SlowSection SLOW = section("slow", SlowSection.class); - - static public class SlowSection extends ConfigurationSection - { - public final ConfigurationItem<Long> DELAY_BETWEEN_TP = item("delayBetweenTP", 3l); - public final ConfigurationItem<Boolean> BROADCAST_PROGRESS = item("broadcastProgress", true); - - public final CagesSection CAGES = section("cages", CagesSection.class); - - static public class CagesSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Cage.CageType> TYPE = item("type", Cage.CageType.TEAM_COLOR_TRANSPARENT); - public final ConfigurationItem<Material> CUSTOM_BLOCK = item("customBlock", Material.BARRIER); - public final ConfigurationItem<Boolean> BUILD_CEILING = item("buildCeiling", false); - public final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visibleWalls", false); - public final ConfigurationItem<Integer> RADIUS = item("radius", 1); - public final ConfigurationItem<Integer> HEIGHT = item("height", 3); - } - } - - public final SoundSection SOUND = section("sound", SoundSection.class); - - public final ConfigurationItem<Boolean> DISPLAY_TITLE = item("displayTitle", true); - public final ConfigurationItem<String> GRACE_PERIOD = item("gracePeriod", "00:30"); - public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcastGraceEnd", true); - public final ConfigurationItem<String> PEACE_PERIOD = item("peacePeriod", "00"); - public final ConfigurationItem<String> SURFACE_MOBS_FREE_PERIOD = item("surfaceMobsFreePeriod", "15:00"); - } - - static public final DeathSection DEATH = section("death", DeathSection.class); - - static public class DeathSection extends ConfigurationSection - { - public final MessagesSection MESSAGES = section("messages", MessagesSection.class); - - static public class MessagesSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> NOTIFY_IF_TEAM_HAS_FALLEN = item("notifyIfTeamHasFallen", true); - public final ConfigurationItem<String> DEATH_MESSAGES_FORMAT = item("deathMessagesFormat", "§6"); - public final ConfigurationItem<String> TEAM_DEATH_MESSAGES_FORMAT = item("teamDeathMessagesFormat", "§6"); - } - - public final KickSection KICK = section("kick", KickSection.class); - - static public class KickSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", false); - public final ConfigurationItem<Integer> TIME = item("time", 30); - public final ConfigurationItem<Boolean> ALLOW_RECONNECT = item("allow-reconnect", true); - } - - public final HeadSection HEAD = section("head", HeadSection.class); - - static public class HeadSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DROP = item("drop", true); - public final ConfigurationItem<Boolean> PVP_ONLY = item("pvpOnly", false); - } - - public final GiveXpToKillerSection GIVE_XP_TO_KILLER = section("give-xp-to-killer", GiveXpToKillerSection.class); - - static public class GiveXpToKillerSection extends ConfigurationSection - { - public final ConfigurationItem<Integer> LEVELS = item("levels", 2); - public final ConfigurationItem<Boolean> ONLY_OTHER_TEAM = item("onlyOtherTeam", true); - } - - public final AnnouncementsSection ANNOUNCEMENTS = section("announcements", AnnouncementsSection.class); - - static public class AnnouncementsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); - public final SoundSection SOUND = section("sound", SoundSection.class); - } - } - - static public final ConfigurationItem<Boolean> COLORIZE_CHAT = item("colorizeChat", true); - - static public final GameplayChangesSection GAMEPLAY_CHANGES = section("gameplay-changes", GameplayChangesSection.class); - - static public class GameplayChangesSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> NATURAL_REGENERATION = item("naturalRegeneration", false); - public final ConfigurationItem<Boolean> WEATHER = item("weather", true); - public final ConfigurationItem<Boolean> REPLACE_GHAST_TEARS_WITH_GOLD = item("replaceGhastTearsWithGold", true); - public final ConfigurationItem<Boolean> CRAFT_GOLDEN_MELON_WITH_GOLD_BLOCK = item("craftGoldenMelonWithGoldBlock", true); - - public final CraftGoldenAppleFromHeadSection CRAFT_GOLDEN_APPLE_FROM_HEAD = section("craftGoldenAppleFromHead", CraftGoldenAppleFromHeadSection.class); - - static public class CraftGoldenAppleFromHeadSection extends ConfigurationSection - { - public final FromHumanSection FROM_HUMAN = section("fromHuman", FromHumanSection.class); - - static public class FromHumanSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", true); - public final ConfigurationItem<Integer> NUMBER_CRAFTED = item("numberCrafted", 2); - public final ConfigurationItem<Boolean> ADD_LORE = item("addLore", true); - public final ConfigurationItem<Boolean> CRAFT_NOTCH_APPLE = item("craftNotchApple", false); - } - - - public final FromWitherSection FROM_WITHER = section("fromWither", FromWitherSection.class); - - static public class FromWitherSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", true); - public final ConfigurationItem<Integer> NUMBER_CRAFTED = item("numberCrafted", 1); - public final ConfigurationItem<Boolean> ADD_LORE = item("addLore", true); - public final ConfigurationItem<Boolean> CRAFT_NOTCH_APPLE = item("craftNotchApple", false); - } - } - - public final GoldenAppleSection GOLDEN_APPLE = section("goldenApple", GoldenAppleSection.class); - - static public class GoldenAppleSection extends ConfigurationSection - { - public final RegenerationSection REGENERATION = section("regeneration", RegenerationSection.class); - - static public class RegenerationSection extends ConfigurationSection - { - public final ConfigurationItem<Integer> NORMAL = item("normal", 4); - public final ConfigurationItem<Integer> NOTCH = item("notch", 180); - public final ConfigurationItem<Integer> FROM_NORMAL_HEAD = item("fromNormalHead", 4); - public final ConfigurationItem<Integer> FROM_NOTCH_HEAD = item("fromNotchHead", 180); - } - - public final ConfigurationItem<Boolean> DISABLE_NOTCH_APPLES = item("disableNotchApples", false); - } - - public final ConfigurationItem<Boolean> DISABLE_ENDERPEARLS_DAMAGES = item("disableEnderpearlsDamages", true); - public final ConfigurationItem<Boolean> DISABLE_LEVEL_II_POTIONS = item("disableLevelIIPotions", false); - - public final WitchSection WITCH = section("witch", WitchSection.class); - - static public class WitchSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISABLE_NATURAL_SPAWN = item("disableNaturalSpawn", false); - public final ConfigurationItem<Boolean> DISABLE_LIGHTNING_SPAWN = item("disableLightningSpawn", false); - } - - public final RabbitSection RABBIT = section("rabbit", RabbitSection.class); - - static public class RabbitSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> KILLER_RABBIT_SPAWN = item("killerRabbitSpawn", true); - public final ConfigurationItem<Double> KILLER_RABBIT_SPAWN_PROBABILITY = item("killerRabbitSpawnProbability", 0.05); - public final ConfigurationItem<String> KILLER_RABBIT_NAME = item("killerRabbitName", "The Killer Rabbit of Caerbannog"); - } - - public final CompassSection COMPASS = section("compass", CompassSection.class); - - static public class CompassSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<String> RECIPE = item("recipe", "medium"); - } - } - - static public final TeamsOptionsSection TEAMS_OPTIONS = section("teams-options", TeamsOptionsSection.class); - - static public class TeamsOptionsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> CAN_SEE_FRIENDLY_INVISIBLES = item("canSeeFriendlyInvisibles", true); - public final ConfigurationItem<Boolean> ALLOW_FRIENDLY_FIRE = item("allowFriendlyFire", true); - public final ConfigurationItem<Integer> MAX_PLAYERS_PER_TEAM = item("maxPlayersPerTeam", 0); - public final ConfigurationItem<Boolean> RANDOM_COLORS = item("randomColors", true); - - public final BannerSection BANNER = section("banner", BannerSection.class); - - static public class BannerSection extends ConfigurationSection - { - public final ShapeSection SHAPE = section("shape", ShapeSection.class); - - static public class ShapeSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> WRITE_LETTER = item("writeLetter", true); - public final ConfigurationItem<Boolean> ADD_BORDER = item("addBorder", true); - } - - public final GiveSection GIVE = section("give", GiveSection.class); - - static public class GiveSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> PLACE_ON_SPAWN = item("placeOnSpawn", true); - public final ConfigurationItem<Boolean> GIVE_IN_HOTBAR = item("giveInHotbar", false); - public final ConfigurationItem<Boolean> GIVE_IN_HEAD = item("giveInHead", false); - } - - public final ShieldSection SHIELDS = section("shields", ShieldSection.class); - - static public class ShieldSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ADD_ON_SHIELDS = item("addOnShields", true); - } - } - - public final GuiSection GUI = section("gui", GuiSection.class); - - static public class GuiSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISPLAY_PLAYERS_IN_TEAMS = item("displayPlayersInTeams", true); - public final ConfigurationItem<Boolean> AUTO_DISPLAY = item("autoDisplay", true); - public final ConfigurationItem<Integer> DELAY = item("delay", 4); - } - - public final ChestGuiSection CHEST_GUI = section("chestGui", ChestGuiSection.class); - - static public class ChestGuiSection extends ConfigurationSection - { - public final DisplaySection DISPLAY = section("display", DisplaySection.class); - - static public class DisplaySection extends ConfigurationSection - { - public final ConfigurationItem<String> TEAM_ITEM = item("teamItem", "banner"); - public final ConfigurationItem<Boolean> GLOW_ON_SELECTED_TEAM = item("glowOnSelectedTeam", true); - } - } - - public final TeamChatSection TEAM_CHAT = section("teamChat", TeamChatSection.class); - - static public class TeamChatSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISABLE_LOCK_ON_DEATH = item("disableLockOnDeath", true); - public final ConfigurationItem<Boolean> LOG = item("log", false); - } - } - - static public final HardcoreHeartsSection HARDCORE_HEARTS = section("hardcore-hearts", HardcoreHeartsSection.class); - - static public class HardcoreHeartsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DISPLAY = item("display", true); - public final ConfigurationItem<Boolean> RESPAWN_MESSAGE = item("respawnMessage", false); - } - - static public final AutoRespawnSection AUTO_RESPAWN = section("auto-respawn", AutoRespawnSection.class); - - static public class AutoRespawnSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", true); - public final ConfigurationItem<Integer> DELAY = item("delay", 6); - } - static public final FinishSection FINISH = section("finish", FinishSection.class); static public class FinishSection extends ConfigurationSection @@ -511,31 +72,6 @@ static public class FireworksSection extends ConfigurationSection } } - static public final DynmapSection DYNMAP = section("dynmap", DynmapSection.class); - - static public class DynmapSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> SHOW_SPAWN_LOCATIONS = item("showSpawnLocations", true); - public final ConfigurationItem<Boolean> SHOW_DEATH_LOCATIONS = item("showDeathLocations", true); - } - - static public final ConfigurationItem<Boolean> SPECTATOR_MODE_WHEN_NEW_PLAYER_JOIN_AFTER_START = item("spectatorModeWhenNewPlayerJoinAfterStart", true); - - static public final RulesSection RULES = section("rules", RulesSection.class); - - static public class RulesSection extends ConfigurationSection - { - public final DisplaySection DISPLAY = section("display", DisplaySection.class); - - static public class DisplaySection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ON_JOIN = item("onJoin", false); - public final ConfigurationItem<Boolean> ON_START = item("onStart", true); - } - - public final ConfigurationList<String> RULES = list("rules", String.class); - } - static public final CommandsSection COMMANDS = section("commands", CommandsSection.class); static public class CommandsSection extends ConfigurationSection @@ -544,60 +80,4 @@ static public class CommandsSection extends ConfigurationSection public final ConfigurationList<String> EXECUTE_START = list("execute-start", String.class); public final ConfigurationList<String> EXECUTE_END = list("execute-end", String.class); } - - static public final ProtipsSection PROTIPS = section("protips", ProtipsSection.class); - - static public class ProtipsSection extends ConfigurationSection - { - public final SoundSection SOUND = section("sound", SoundSection.class); - - public final TeamchatSection TEAMCHAT = section("teamchat", TeamchatSection.class); - - static public class TeamchatSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> USE_T_COMMAND = item("useTCommand", true); - public final ConfigurationItem<Boolean> LOCK = item("lock", true); - public final ConfigurationItem<Boolean> USE_G_COMMAND = item("useGCommand", true); - } - - public final CraftsSection CRAFTS = section("crafts", CraftsSection.class); - - static public class CraftsSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> GOLDEN_HEAD = item("goldenHead", true); - public final ConfigurationItem<Boolean> COMPASS_EASY = item("compassEasy", true); - public final ConfigurationItem<Boolean> COMPASS_MEDIUM = item("compassMedium", true); - public final ConfigurationItem<Boolean> COMPASS_HARD = item("compassHard", true); - public final ConfigurationItem<Boolean> GLISTERING_MELON = item("glisteringMelon", true); - public final ConfigurationItem<Boolean> NO_ENCH_GOLDEN_APPLE = item("noEnchGoldenApple", true); - } - - public final StartSection START = section("start", StartSection.class); - - static public class StartSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> INVINCIBILITY = item("invincibility", true); - } - } - - static public final ConfigurationList<Vector> SPAWN_POINTS = list("spawnpoints", Vector.class); - static public final ConfigurationList<String> TEAMS = list("teams", String.class); - static public final ConfigurationMap<String, BannerMeta> TEAM_BANNERS = map("teambanners", String.class, BannerMeta.class); - - /* ** Helper sub-sections ** */ - - static public class SoundSection extends ConfigurationSection - { - public final ConfigurationItem<Sound> NAME = item("name", Sound.class); - public final ConfigurationItem<Integer> VOLUME = item("volume", 1); - public final ConfigurationItem<Integer> PITCH = item("pitch", 1); - } - - /* ** Helper value handlers ** */ - - static - { -// ConfigurationValueHandlers.registerHandlers(TeamManager.class); -// ConfigurationValueHandlers.registerHandlers(UHSound.class); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java index 8c9db1a..6fc45aa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java @@ -69,6 +69,14 @@ static public class TeamSelectorSection extends ConfigurationSection public final ConfigurationItem<Material> ITEM = item("item", Material.NETHER_STAR); } + public static final ConfigAccessorSection CONFIG_ACCESSOR = section("config-accessor", ConfigAccessorSection.class); + + static public class ConfigAccessorSection extends ConfigurationSection + { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Material> ITEM = item("item", Material.REDSTONE_COMPARATOR); + } + public static final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("team-in-action-bar", true); public static final ConfigurationItem<Boolean> ENABLE_PVP = item("enable-pvp", false); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index e0ea36b..a17a166 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -39,14 +39,19 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.attributes.Attribute; +import fr.zcraft.zlib.components.attributes.Attributes; import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.core.ZLib; +import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.reflection.NMSException; +import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.ActionBar; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; @@ -68,6 +73,11 @@ import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permissible; +import org.bukkit.scheduler.BukkitTask; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; @ModuleInfo ( @@ -80,30 +90,97 @@ ) public class WaitModule extends UHModule { + private final static UUID ACTIONABLE_ITEM_UUID = UUID.fromString("3f65c4a9-e1ae-437e-b8b4-57d80a831480"); + + private final Map<UUID, String> playerInventoriesStates = new HashMap<>(); + private BukkitTask inventoriesUpdateTask = null; + @Override protected void onEnable() { Bukkit.getOnlinePlayers().forEach(this::handleNewPlayer); + + inventoriesUpdateTask = RunTask.timer(() -> Bukkit.getOnlinePlayers().forEach(this::updateInventory), 20L, 20L); + } + + @Override + protected void onDisable() + { + if (inventoriesUpdateTask != null) + { + inventoriesUpdateTask.cancel(); + inventoriesUpdateTask = null; + } } /** - * Opens the teams selector GUI, if needed (enabled, game not started, needed item). + * Writes an action into an Item Stack. * - * TODO improve selector item detection. + * @param item The item. This must be a CraftItemStack. + * @param action The action to store. + * @see #readAction(ItemStack) to read a previously stored action. + */ + private void writeAction(final ItemStack item, final String action) + { + final Attribute attribute = new Attribute(); + + attribute.setUUID(ACTIONABLE_ITEM_UUID); + attribute.setCustomData(action); + + try + { + Attributes.set(item, attribute); + } + catch (final NMSException e) + { + PluginLogger.error("Unable to store item action into attribute. Inventory tools won't work before the game."); + } + } + + /** + * Reads an action previously written into this ItemStack. + * @param item The item. + * @return The action, or en empty string if nothing stored. + * @see #writeAction(ItemStack, String) to write an action. + */ + private String readAction(final ItemStack item) + { + try + { + final Attribute attribute = Attributes.get(item, ACTIONABLE_ITEM_UUID); + return attribute != null && attribute.getCustomData() != null ? attribute.getCustomData() : ""; + } + catch (NMSException ignored) { + return ""; + } + } + + /** + * Opens the teams selector GUI, if needed (enabled, game not started, needed item). * * @param player The player who right-clicked an item. * @param item The right-clicked item. */ - private void openTeamsGUI(Player player, ItemStack item) + private boolean openGUI(Player player, ItemStack item) { - if (isGameStarted()) return; + if (isGameStarted() || item == null) return false; - if (Config.TEAM_SELECTOR.ENABLED.get() - && item != null - && item.getType() == Config.TEAM_SELECTOR.ITEM.get()) + switch (readAction(item)) { - Gui.open(player, new TeamsSelectorGUI()); + case "teams": + Gui.open(player, new TeamsSelectorGUI()); + return true; + + case "config": + if (player.isOp()) // TODO add permissions + { + Gui.open(player, new MainConfigGUI()); + return true; + } + else return false; } + + return false; } /** @@ -113,8 +190,6 @@ private void openTeamsGUI(Player player, ItemStack item) */ private void handleNewPlayer(final Player player) { - final boolean builder = isBuilder(player); - if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get()) { final Location worldSpawn = UR.get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); @@ -133,6 +208,34 @@ private void handleNewPlayer(final Player player) player.setFoodLevel(20); player.setSaturation(20f); + updateInventory(player); + + player.getInventory().setHeldItemSlot(4); + + displayTeamInActionBar(player); + } + + /** + * Update the player inventory and game mode, if its state changed since last update. + * + * @param player The player to update. + */ + private void updateInventory(final Player player) + { + final boolean builder = isBuilder(player); + final boolean teamsDisplayed = Config.TEAM_SELECTOR.ENABLED.get(); + final boolean configDisplayed = Config.CONFIG_ACCESSOR.ENABLED.get() && player.isOp(); + + // Only updates the inventory when the access state change. + final String state = String.format("%b%b%b", builder, teamsDisplayed, configDisplayed); + if (playerInventoriesStates.containsKey(player.getUniqueId()) && playerInventoriesStates.get(player.getUniqueId()).equals(state)) + { + return; + } + + PluginLogger.info("New state: {0}", state); + playerInventoriesStates.put(player.getUniqueId(), state); + player.setGameMode(builder ? GameMode.CREATIVE : GameMode.ADVENTURE); if (!builder && Config.INVENTORY.CLEAR.get()) @@ -141,24 +244,61 @@ private void handleNewPlayer(final Player player) player.getInventory().setArmorContents(null); } - if (Config.TEAM_SELECTOR.ENABLED.get()) + if (Config.TEAM_SELECTOR.ENABLED.get() || Config.CONFIG_ACCESSOR.ENABLED.get()) { - Material itemType = Config.TEAM_SELECTOR.ITEM.get(); - - ItemStack item = new ItemStackBuilder(itemType) + final ItemStack teamsSelector = new ItemStackBuilder(Config.TEAM_SELECTOR.ITEM.get()) /// The title of the item given before the game to select a team .title(I.t("{green}{bold}Select a team {gray}(Right-Click)")) /// The lore of the item given before the game to select a team - .lore(GuiUtils.generateLore(I.t("{gray}Right-click to select your team for this game"))) + .longLore(I.t("{gray}Right-click to select your team for this game")) .hideAttributes() - .item(); + .craftItem(); + + final ItemStack configAccessor = new ItemStackBuilder(Config.CONFIG_ACCESSOR.ITEM.get()) + .title(I.t("{red}{bold}Configure the game {gray}(Right-Click)")) + .longLore(I.t("{gray}Right-click to open the game configuration GUI")) + .hideAttributes() + .craftItem(); + + writeAction(teamsSelector, "teams"); + writeAction(configAccessor, "config"); + + final int teamsSlot = configDisplayed ? 2 : 4; + final int configSlot = teamsDisplayed ? 6 : 4; + + clearIfSimilar(player, teamsSelector, 2); + clearIfSimilar(player, teamsSelector, 4); + clearIfSimilar(player, configAccessor, 4); + clearIfSimilar(player, configAccessor, 6); + + if (teamsDisplayed) + { + placeIfPossible(player, teamsSelector, teamsSlot); + } - final ItemStack centralItem = player.getInventory().getItem(4); - if (!builder || centralItem == null || centralItem.getType() == org.bukkit.Material.AIR) - player.getInventory().setItem(4, item); + if (configDisplayed) + { + placeIfPossible(player, configAccessor, configSlot); + } } + } - displayTeamInActionBar(player); + private void placeIfPossible(final Player player, final ItemStack item, final int slot) + { + final ItemStack previousItem = player.getInventory().getItem(slot); + if (!isBuilder(player) || previousItem == null || previousItem.getType() == org.bukkit.Material.AIR) + { + player.getInventory().setItem(slot, item); + } + } + + private void clearIfSimilar(final Player player, final ItemStack ifSimilarTo, final int slot) + { + final ItemStack previousItem = player.getInventory().getItem(slot); + if (previousItem != null && previousItem.getType() == ifSimilarTo.getType()) + { + player.getInventory().setItem(slot, new ItemStack(Material.AIR)); + } } /** @@ -197,14 +337,19 @@ public void onPlayerJoin(final PlayerJoinEvent ev) @EventHandler(priority = EventPriority.LOWEST) public void onPlayerInteract(PlayerInteractEvent ev) { - if (ev.getAction() != Action.PHYSICAL) - openTeamsGUI(ev.getPlayer(), ev.getItem()); + if (ev.getAction() != Action.PHYSICAL && openGUI(ev.getPlayer(), ev.getItem())) + { + ev.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent ev) { - openTeamsGUI(ev.getPlayer(), ev.getPlayer().getItemInHand()); + if (openGUI(ev.getPlayer(), ev.getPlayer().getItemInHand())) + { + ev.setCancelled(true); + } } @EventHandler @@ -367,6 +512,11 @@ public void onGameStarts(final GamePhaseChangedEvent ev) case IN_GAME: ZLib.unregisterEvents(this); + if (inventoriesUpdateTask != null) + { + inventoriesUpdateTask.cancel(); + inventoriesUpdateTask = null; + } break; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index f60d154..bec2bef 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -726,8 +726,7 @@ public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev if (Config.BROADCAST_PROGRESS.get()) { /// Displayed in the action bar when the slow teleportation is finished but the game not started. - String message = I.t("{lightpurple}Teleportation complete. {gray}The game will start soon..."); - Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, message)); + Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, I.tl(player, "{lightpurple}Teleportation complete. {gray}The game will start soon..."))); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java index 1880f04..02b60c6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java @@ -40,7 +40,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModuleCommand; import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModulesCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModulesGUICommand; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ConfigurationCommand; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; @@ -69,7 +69,7 @@ public List<Class<? extends Command>> getCommands() return Arrays.asList( ModulesCommand.class, ModuleCommand.class, - ModulesGUICommand.class + ConfigurationCommand.class ); } @@ -78,7 +78,7 @@ public Map<String, Class<? extends Command>> getCommandsAliases() { return ImmutableMap.of( "modules", ModulesCommand.class, - "config", ModulesGUICommand.class + "config", ConfigurationCommand.class ); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java index 50d512f..b95a9df 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesGUICommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java @@ -33,18 +33,18 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.ModulesListGUI; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; import fr.zcraft.zlib.components.gui.Gui; -@CommandInfo (name = "modules-gui") -public class ModulesGUICommand extends Command +@CommandInfo (name = "config") +public class ConfigurationCommand extends Command { @Override protected void run() throws CommandException { - Gui.open(playerSender(), new ModulesListGUI()); + Gui.open(playerSender(), new MainConfigGUI()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java new file mode 100644 index 0000000..c222a44 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java @@ -0,0 +1,212 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; + +import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +import eu.carrade.amaury.UHCReloaded.modules.beginning.wait.Config; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules.ModulesListGUI; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start.StartGameGUI; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.gui.ActionGui; +import fr.zcraft.zlib.components.gui.Gui; +import fr.zcraft.zlib.components.gui.GuiAction; +import fr.zcraft.zlib.components.gui.PromptGui; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zteams.ZTeams; +import fr.zcraft.zteams.guis.TeamsSelectorGUI; +import org.bukkit.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class MainConfigGUI extends ActionGui +{ + private BukkitTask headsCycleTask = null; + private String[] headCycleNames = null; + private int headCycleIndex = 0; + + @Override + protected void onUpdate() + { + setTitle(I.tl(getPlayerLocale(), "{black}Game Configuration")); + setHeight(UR.game().currentPhaseAfter(GamePhase.WAIT) ? 3 : 5); + + final Set<String> alivePlayers = (UR.game().currentPhaseBefore(GamePhase.IN_GAME) + ? Bukkit.getOnlinePlayers().stream().filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) + : UR.game().getAlivePlayers().stream()) + .map(OfflinePlayer::getName) + .collect(Collectors.toSet()); + + final Set<String> spectators = UR.module(SpectatorsModule.class).getSpectators().stream() + .map(Bukkit::getOfflinePlayer) + .map(OfflinePlayer::getName) + .collect(Collectors.toSet()); + + headCycleNames = Stream.concat(alivePlayers.stream(), spectators.stream()).toArray(String[]::new); + + action("players", 10, new ItemStackBuilder(Material.SKULL_ITEM) + .data((short) SkullType.PLAYER.ordinal()) + .amount(Math.max(alivePlayers.size(), 1)) + .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Players")) + .loreLine( + ChatColor.DARK_GRAY, + I.tln(getPlayerLocale(), "{0} player", "{0} players", alivePlayers.size()), + " - ", + I.tln(getPlayerLocale(), "{0} spectator", "{0} spectators", UR.module(SpectatorsModule.class).getSpectators().size()) + ) + .loreSeparator() + .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Players")) + .longLore(ChatColor.GRAY, alivePlayers.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : String.join(", ", alivePlayers), 38) + .loreSeparator() + .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Spectators")) + .longLore(ChatColor.GRAY, spectators.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : String.join(", ", spectators), 38) + .loreSeparator() + .longLore(ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Actions on players coming soon: in the mean time, use commands."), 38) + ); + + action("teams", 12, new ItemStackBuilder(Config.TEAM_SELECTOR.ITEM.get()) + .title(ChatColor.AQUA, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teams")) + .amount(Math.max(ZTeams.get().countTeams(), 1)) + .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", ZTeams.get().countTeams())) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "The game can either be solo or in teams. In the second case, click here to create or update teams."), 38) + .loreSeparator() + .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage the teams")) + ); + + action("title", 14, new ItemStackBuilder(Material.BOOK_AND_QUILL) + .title(ChatColor.DARK_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Game Title")) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click to update the game title. It is displayed on the sidebar and may be used by other modules (like the reports one)."), 38) + .loreSeparator() + .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Current Title")) + .longLore(UHConfig.TITLE.get()) + .loreSeparator() + .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to change the title")) + ); + + final int modules = UR.get().getModulesManager().getModules().size(); + final int modulesEnabled = (int) UR.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); + final int modulesLoaded = (int) UR.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); + + action("modules", 16, new ItemStackBuilder(Material.COMMAND) + .title(ChatColor.LIGHT_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Modules")) + .loreLine( + ChatColor.DARK_GRAY, + I.tln(getPlayerLocale(), "{0} module", "{0} modules", modules), + " - ", + I.tln(getPlayerLocale(), "{0} enabled", "{0} enabled", modulesEnabled), + " - ", + I.tln(getPlayerLocale(), "{0} loaded", "{0} loaded", modulesLoaded) + ) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "This plugin is divided into modules, each one bringing one small or large piece of the game."), 52) + .loreSeparator() + .lore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage modules and their configuration")) + ); + + if (!UR.game().currentPhaseAfter(GamePhase.WAIT)) + { + action("start", 31, new ItemStackBuilder(Material.INK_SACK) // FIXME 1.13 + .data(DyeColor.LIME.getDyeData()) + .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Start the game")) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If you're ready, click here to start the game!")) + ); + } + + if (headsCycleTask != null) headsCycleTask.cancel(); + + headsCycleTask = RunTask.timer(() -> { + final ItemStack skull = getInventory().getItem(10); + if (skull != null) + { + new ItemStackBuilder(getInventory().getItem(10)).head(headCycleNames[headCycleIndex]).item(); + + headCycleIndex = (headCycleIndex + 1) % headCycleNames.length; + if (headCycleIndex < 0) headCycleIndex += headCycleNames.length; + } + }, 0L, 40L); + } + + @Override + protected void onClose() + { + if (headsCycleTask != null) + { + headsCycleTask.cancel(); + headsCycleTask = null; + headCycleIndex = 0; + } + + super.onClose(); + } + + @GuiAction + protected void players() { + update(); + } + + + @GuiAction + protected void teams() + { + Gui.open(getPlayer(), new TeamsSelectorGUI(), this); + } + + @GuiAction + protected void title() + { + PromptGui.prompt(getPlayer(), newTitle -> UHConfig.TITLE.set(ChatColor.translateAlternateColorCodes('&', newTitle), false), UHConfig.TITLE.get().replace(ChatColor.COLOR_CHAR, '&'), this); + } + + @GuiAction + protected void modules() + { + Gui.open(getPlayer(), new ModulesListGUI(), this); + } + + @GuiAction + protected void start() + { + Gui.open(getPlayer(), new StartGameGUI()); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java index 278de8a..b7a80d1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ConfirmModuleDisableGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java @@ -31,18 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.gui.GuiUtils; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.mojang.MojangHead; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; import java.util.List; import java.util.stream.Collectors; @@ -65,20 +64,13 @@ protected void onUpdate() title.remove(0); - final ItemStack confirm = new ItemStackBuilder(Material.SKULL_ITEM) - .data((short) 3) + action("", 22, MojangHead.QUESTION.asItemBuilder() .title(ChatColor.RED, ChatColor.BOLD + firstTitleLine) .lore(title.stream().map(line -> ChatColor.RED + "" + ChatColor.BOLD + line).collect(Collectors.toList())) .loreSeparator() .longLore(ChatColor.GRAY, I.t("This module cannot be re-loaded after its original load period. This means that if you disable this module, you won't be able to re-enable it during this game."), 38) .longLore(ChatColor.WHITE, I.t("Are you sure you want to disable {0}?", module.getName()), 38) - .item(); - - final SkullMeta meta = (SkullMeta) confirm.getItemMeta(); - meta.setOwner("MHF_Question"); - confirm.setItemMeta(meta); - - action("", 22, confirm); + .item()); final ItemStackBuilder no = new ItemStackBuilder(Material.STAINED_GLASS_PANE) .data(DyeColor.RED.getWoolData()) // FIXME 1.13 diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java index 53084fd..453d915 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/FramedModuleGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import fr.zcraft.zlib.components.gui.ActionGui; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java similarity index 75% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java index 081ff97..3baf304 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; @@ -42,8 +42,10 @@ import fr.zcraft.zlib.components.gui.GuiAction; import fr.zcraft.zlib.components.i18n.I; import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.mojang.MojangHead; import fr.zcraft.zteams.colors.ColorsUtils; import org.bukkit.ChatColor; +import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; @@ -55,6 +57,7 @@ public class ModulesListGUI extends ExplorerGui<ModuleWrapper> * The category filtered. {@code null} means all. */ private ModuleCategory filterCategory; + private StateFilter filterState = StateFilter.ALL; public ModulesListGUI() { @@ -75,6 +78,23 @@ protected void onUpdate() final ModuleWrapper[] modules = UR.get().getModulesManager().getModules().stream() .filter(module -> filterCategory == null || module.getCategory() == filterCategory) + .filter(module -> { + switch (filterState) + { + case ALL: + return true; + + case ENABLED: + return module.isEnabled(); + + case LOADED: + return module.isLoaded(); + + case DISABLED: + default: + return !module.isEnabled(); + } + }) .sorted((module1, module2) -> { if (module1.equals(module2)) return 0; @@ -92,7 +112,9 @@ protected void onUpdate() setData(modules); + // Sets the title + if (filterCategory == null) { setTitle(I.t("{black}All modules {darkgray}({0})", UR.get().getModulesManager().getModules().size())); @@ -102,7 +124,9 @@ protected void onUpdate() setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, UR.get().getModulesManager().getModules().size())); } + // Displays the bottom bar of color + final ItemStackBuilder bottomColorStripe = new ItemStackBuilder(Material.STAINED_GLASS_PANE) .data(ColorsUtils.chat2Dye(filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE).getWoolData()) // FIXME 1.13 .title(filterCategory != null ? filterCategory.getColor() + "" + ChatColor.BOLD + filterCategory.getDisplayName() : ""); @@ -110,15 +134,18 @@ protected void onUpdate() for (int slot = getSize() - 9; slot < getSize(); slot++) action("", slot, bottomColorStripe); + + final String prefixActive = ChatColor.YELLOW + "» "; + final String prefixInactive = ChatColor.DARK_GRAY + "» " + ChatColor.GRAY; + + // Displays the category filter button + final Material endCrystal = Material.getMaterial("END_CRYSTAL"); final ItemStackBuilder catFilter = new ItemStackBuilder(filterCategory == null ? new ItemStack(endCrystal != null ? endCrystal : Material.HOPPER) : filterCategory.getIcon()) .title(ChatColor.YELLOW, ChatColor.BOLD + I.t("Filter modules category")) .loreSeparator(); - final String prefixActive = ChatColor.YELLOW + "» "; - final String prefixInactive = ChatColor.DARK_GRAY + "» " + ChatColor.GRAY; - catFilter.loreLine((filterCategory == null ? prefixActive : prefixInactive) + I.t("All modules")); for (ModuleCategory category : ModuleCategory.values()) @@ -130,6 +157,32 @@ protected void onUpdate() catFilter.longLore(ChatColor.WHITE, filterCategory == null ? I.t("Click to filter the modules by category. A description will be displayed here.") : filterCategory.getDescription(), 38); action("switch_category", getSize() - 5, catFilter); + + + // Displays the state filter button + + final ItemStackBuilder stateFilter = new ItemStackBuilder(Material.INK_SACK) // FIXME 1.13 + .data(filterState.color.getDyeData()) + .title(ChatColor.YELLOW, ChatColor.BOLD + I.tl(getPlayerLocale(), "Filter modules state")) + .loreSeparator(); + + for (StateFilter filter : StateFilter.values()) + { + stateFilter.loreLine(filterState == filter ? prefixActive : prefixInactive, filter.displayName); + } + + stateFilter.loreSeparator(); + stateFilter.longLore(ChatColor.WHITE, I.tl(getPlayerLocale(), "Click here to filter by state. Loaded modules are currently running. Enabled ones are running or will run when needed. Disabled modules will never run."), 48); + + action("switch_status", getSize() - 7, stateFilter); + + + // Displays the back button + + action("quit", getSize() - 3, MojangHead.ARROW_LEFT.asItemBuilder() + .title(ChatColor.GREEN, ChatColor.BOLD + (getParent() != null ? I.tl(getPlayerLocale(), "Go Back") : I.tl(getPlayerLocale(), "Close"))) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click here to close this GUI and go back. You can also press “Escape”.")) + ); } @Override @@ -210,4 +263,36 @@ protected void switch_category(final InventoryClickEvent ev) filterCategory = UHUtils.getNextElement(filterCategory, ev.getClick() == ClickType.RIGHT ? -1 : 1, true, ModuleCategory.class); update(); } + + @GuiAction + protected void switch_status(final InventoryClickEvent ev) + { + filterState = UHUtils.getNextElement(filterState, ev.getClick() == ClickType.RIGHT ? -1 : 1); + update(); + } + + @GuiAction + protected void quit() + { + close(); + } + + private enum StateFilter + { + ALL(DyeColor.PURPLE, I.t("All modules")), + ENABLED(DyeColor.PINK, I.t("Enabled modules")), + LOADED(DyeColor.LIME, I.t("Loaded modules")), + DISABLED(DyeColor.GRAY, I.t("Disabled modules")) + + ; + + private final DyeColor color; + private final String displayName; + + StateFilter(DyeColor color, String displayName) + { + this.color = color; + this.displayName = displayName; + } + } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java new file mode 100644 index 0000000..7b86aa8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java @@ -0,0 +1,131 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.components.gui.ActionGui; +import fr.zcraft.zlib.components.gui.Gui; +import fr.zcraft.zlib.components.gui.GuiAction; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.zlib.tools.mojang.MojangHead; +import fr.zcraft.zteams.ZTeams; +import org.bukkit.ChatColor; +import org.bukkit.Material; + +public class StartGameGUI extends ActionGui +{ + private TeleportationMode mode = TeleportationMode.NORMAL; + + @Override + protected void onUpdate() + { + setHeight(5); + setTitle(I.tl(getPlayerLocale(), "{black}Ready to start the game?")); + + final String prefixActive = ChatColor.YELLOW + "» "; + final String prefixInactive = ChatColor.DARK_GRAY + "» " + ChatColor.GRAY; + + action("fast", 11, new ItemStackBuilder(Material.MAGMA_CREAM) + .title(ChatColor.DARK_GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Fast Start")) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click here to start the game immediately. Players will be teleported at once (thus loading a lot of chunks in a few seconds) and the countdown will begin immediately after."), 52) + ); + + action("slow", 15, new ItemStackBuilder(Material.SLIME_BALL) + .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Slow Start")) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If your server is a little bit small, use this option to teleport players slowly, loading the chunks one player at a time. You'll have to confirm the game start using a link in the chat."), 52) + ); + + if (ZTeams.get().countTeams() > 0) + { + action("teleportation_mode", 13, new ItemStackBuilder() + .material(mode == TeleportationMode.NORMAL ? Material.SUGAR : Material.GLOWSTONE_DUST) + .title(ChatColor.YELLOW, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teleportation Mode")) + .loreSeparator() + .loreLine(mode == TeleportationMode.NORMAL ? prefixActive : prefixInactive, I.tl(getPlayerLocale(), "Teams together")) + .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Teams are teleported to a shared spawn point. Teammates start together."), 38) + .loreSeparator() + .loreLine(mode == TeleportationMode.IGNORE_TEAMS ? prefixActive : prefixInactive, I.tl(getPlayerLocale(), "Ignoring teams")) + .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Players will be alone at the beginning, even if they are in a team."), 38) + ); + } + + action("back", 31, MojangHead.ARROW_LEFT.asItemBuilder() + .title(ChatColor.RED, ChatColor.BOLD + I.tl(getPlayerLocale(), "Go Back")) + .loreSeparator() + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Changed your mind? No problem, click here to go back without starting the game."), 38) + ); + } + + @GuiAction + protected void teleportation_mode() + { + mode = UHUtils.getNextElement(mode, 1); + update(); + } + + @GuiAction + protected void fast() + { + start(false); + close(); + } + + @GuiAction + protected void slow() + { + start(true); + close(); + } + + private void start(final boolean slow) + { + UR.game().setTeleportationMode(mode); + UR.game().setSlowMode(slow); + + UR.game().setPhase(GamePhase.STARTING); + } + + @GuiAction + protected void back() + { + Gui.open(getPlayer(), new MainConfigGUI()); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java index f46a18e..bab2b46 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java @@ -47,5 +47,4 @@ public Config(File file) super(file); } - public final static ConfigurationItem<String> TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java index 2e04809..373ebdd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.core.UHModule; import fr.zcraft.zlib.components.scoreboard.Sidebar; @@ -75,6 +76,6 @@ public List<String> getContent(Player player) @Override public String getTitle(Player player) { - return Config.TITLE.get(); + return UHConfig.TITLE.get(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java index 7e11e61..06a65f4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java @@ -42,6 +42,7 @@ import fr.zcraft.zlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; import java.util.Arrays; import java.util.List; @@ -92,19 +93,21 @@ protected void run() throws CommandException // /uh spec add <player> else { + final CommandSender finalSender = sender; + OfflinePlayersLoader.loadPlayer(args[1], player -> { if (player == null) { - sender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); + finalSender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); if (!Bukkit.getOnlineMode()) - sender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); + finalSender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); return; } UR.module(SpectatorsModule.class).addSpectator(player); - sender.sendMessage(I.t("{cs}The player {0} is now a spectator.", player.getName())); + finalSender.sendMessage(I.t("{cs}The player {0} is now a spectator.", player.getName())); }); } @@ -124,12 +127,12 @@ protected void run() throws CommandException final OfflinePlayer oldSpectator = OfflinePlayersLoader.getOfflinePlayer(args[1]); if (oldSpectator == null) { - sender.sendMessage(I.t("{ce}The player {0} was not found.", args[1])); + error(I.t("{ce}The player {0} was not found.", args[1])); } else { UR.module(SpectatorsModule.class).removeSpectator(oldSpectator); - sender.sendMessage(I.t("{cs}The player {0} is now a player.", args[1])); + success(I.t("{cs}The player {0} is now a player.", args[1])); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java index bdc6760..def0ae9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java @@ -31,7 +31,6 @@ */ package eu.carrade.amaury.UHCReloaded.modules.core.teams; -import eu.carrade.amaury.UHCReloaded.UHConfig; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; import fr.zcraft.zlib.components.configuration.ConfigurationSection; @@ -78,7 +77,7 @@ static public class GiveSection extends ConfigurationSection public final ConfigurationItem<Boolean> GIVE_ON_HEAD = item("give-on-head", false); } - public final UHConfig.TeamsOptionsSection.BannerSection.ShieldSection SHIELDS = section("shields", UHConfig.TeamsOptionsSection.BannerSection.ShieldSection.class); + public final ShieldSection SHIELDS = section("shields", ShieldSection.class); static public class ShieldSection extends ConfigurationSection { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java index 54f04ad..1f3263a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; +import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; @@ -64,7 +65,7 @@ private String getMOTD() if (Config.DISPLAY_MATCH_NAME.get()) { matchName = ChatColor.translateAlternateColorCodes('&', Config.MATCH_NAME_PREFIX.get()) - + eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get() + + UHConfig.TITLE.get() + ChatColor.RESET + "\n"; } else diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java index 91e5baa..a0c40b5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.other.reports; +import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; @@ -159,7 +160,7 @@ protected void onEnable() .autoCollectPreviousStatistics(true) .registerPlayers(game.getAlivePlayers()) - .title(eu.carrade.amaury.UHCReloaded.modules.core.sidebar.Config.TITLE.get()) + .title(UHConfig.TITLE.get()) .settings() .displayDate(Config.DATE.get()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java deleted file mode 100644 index 0abc414..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.recipes; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.SkullType; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.ArrayList; - - -public class RecipesManager -{ - private UHCReloaded p = null; - - private Material compassCentralIngredient = null; - private int compassRecipeType = -1; - - public static final String RECIPE_COMPASS = "compass"; - public static final String RECIPE_GLISTERING_MELON = "glistering"; - public static final String RECIPE_ENCHANTED_GOLDEN_APPLE = "EGA"; - - public static final int COMPASS_DISABLED = 0; - public static final int COMPASS_EASY = 1; - public static final int COMPASS_MEDIUM = 2; - public static final int COMPASS_HARD = 3; - - private String lastFailedRecipe = null; - - - public RecipesManager(UHCReloaded plugin) - { - this.p = plugin; - } - - - /** - * Registers the recipes needed, following the configuration. - */ - public void registerRecipes() - { - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.DO.get()) - { - p.getServer().addRecipe(getGoldenHeadHumanRecipe()); - } - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.DO.get()) - { - p.getServer().addRecipe(getGoldenHeadMonsterRecipe()); - } - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - { - p.getServer().addRecipe(getLoreRemoverNormalRecipe()); - p.getServer().addRecipe(getLoreRemoverNotchRecipe()); - } - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_MELON_WITH_GOLD_BLOCK.get()) - { - p.getServer().addRecipe(getGoldenMelonRecipe()); - } - - // Because the compass recipe is "semi-shapeless" (the central part is fixed, but the - // loots can be placed into any configuration), there isn't a registered recipe for it - // (I don't want to register 16 recipes for each difficulty). - // Instead, using the inventoryClickEvent/inventoryDragEvent, we checks manually if the - // recipe is valid. - switch (this.getCompassRecipeType()) - { - case COMPASS_EASY: - compassCentralIngredient = Material.REDSTONE; - break; - case COMPASS_MEDIUM: - compassCentralIngredient = Material.ENDER_PEARL; - break; - case COMPASS_HARD: - compassCentralIngredient = Material.EYE_OF_ENDER; - break; - case COMPASS_DISABLED: - break; - } - } - - /** - * Checks if a recipe is allowed. - * - * @param recipe The recipe to be checked. - * @return True if the recipe is allowed, false else. - */ - public boolean isRecipeAllowed(Recipe recipe) - { - // Vanilla compass recipe is disabled if the special compass is used. - if (UHConfig.GAMEPLAY_CHANGES.COMPASS.ENABLED.get() && RecipesUtils.areSimilar(recipe, getVanillaCompassRecipe())) - { - this.lastFailedRecipe = RECIPE_COMPASS; - return false; - } - - // Vanilla golden melon recipe is disabled if the craft with a gold block is enabled. - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_MELON_WITH_GOLD_BLOCK.get() && RecipesUtils.areSimilar(recipe, getVanillaGoldenMelonRecipe())) - { - this.lastFailedRecipe = RECIPE_GLISTERING_MELON; - return false; - } - - // If enchanted golden apples are disabled... - // The same technique does not work, this is a workaround - if (UHConfig.GAMEPLAY_CHANGES.GOLDEN_APPLE.DISABLE_NOTCH_APPLES.get()) - { - if (recipe.getResult().getType() == Material.GOLDEN_APPLE) - { - for (ItemStack item : RecipesUtils.getListOfIngredients(recipe)) - { - if (item.getType() == Material.GOLD_BLOCK) - { - // There is a gold block in a recipe for a golden apple - NOPE NOPE NOPE - this.lastFailedRecipe = RECIPE_ENCHANTED_GOLDEN_APPLE; - return false; - } - } - } - } - - // The recipe is allowed. - return true; - } - - /** - * Checks if the recipe is a valid compass recipe. - * <p> - * A valid compass recipe is a recipe with: - * <ul> - * <li> - * in the center, the valid ingredient for the current compass craft - * (redstone, ender pearl or eye of ender); - * </li> - * <li> - * four iron ingots placed like the vanilla compass recipe; - * </li> - * <li> - * in the four corners, a bone, a rotten flesh, a spider eye and a gunpowder, - * placed in any shape. - * </li> - * </ul> - * <p> - * Executed in the {@code onInventoryClick} and {@code onInventoryDrag} events, to allow this to be recognized even if - * the recipe is not registered. - * - * @param matrix The content of the crafting inventory. - * @return true if the recipe is an alternate recipe for the compass. - */ - public boolean isValidCompassRecipe(ItemStack[] matrix) - { - if (matrix.length <= 5) - { - return false; // Small crafting grid - } - - if (this.getCompassRecipeType() == COMPASS_DISABLED) - { - return false; - } - - - // 1: check of the static part (central ingredient + iron) - - Material iron1 = matrix[1].getType(); - Material iron2 = matrix[3].getType(); - Material iron3 = matrix[5].getType(); - Material iron4 = matrix[7].getType(); - Material centralIngredient = matrix[4].getType(); - - if (!(iron1.equals(Material.IRON_INGOT) - && iron2.equals(Material.IRON_INGOT) - && iron3.equals(Material.IRON_INGOT) - && iron4.equals(Material.IRON_INGOT) - && centralIngredient.equals(compassCentralIngredient))) - { - return false; - } - - // 2: check of the dynamic part (loots) - - ArrayList<Material> corners = new ArrayList<>(); - corners.add(matrix[0].getType()); - corners.add(matrix[2].getType()); - corners.add(matrix[6].getType()); - corners.add(matrix[8].getType()); - - return corners.contains(Material.BONE) - && corners.contains(Material.ROTTEN_FLESH) - && corners.contains(Material.SPIDER_EYE) - && corners.contains(Material.SULPHUR); - } - - - /** - * Adds the lore to the golden apples, if needed. - * - * @param recipe The recipe to change. - * @param inventory The crafting inventory (used to access the skull owner) - * @return The modified result (ItemStack) if a change was needed. Null if no change is needed. - */ - public ItemStack addLore(Recipe recipe, CraftingInventory inventory) - { - if ((UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.DO.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.DO.get()) - && (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - && (RecipesUtils.areSimilar(recipe, getGoldenHeadHumanRecipe()) || RecipesUtils.areSimilar(recipe, getGoldenHeadMonsterRecipe()))) - { - ItemStack result = recipe.getResult(); - ItemMeta meta = result.getItemMeta(); - - // Lookup for the head in the recipe - String name = ""; - Boolean wither = true; - - for (ItemStack item : inventory.getContents()) - { - // An human head - if (item.getType() == Material.SKULL_ITEM && item.getDurability() == (short) SkullType.PLAYER.ordinal()) - { - SkullMeta sm = (SkullMeta) item.getItemMeta(); - if (sm.hasOwner()) // An human head - { - name = sm.getOwner(); - wither = false; - } - break; - } - } - - if ((wither && UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - || (!wither && UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get())) - { - if (wither) - { - /// Golden head lore for withers - meta.setLore(GuiUtils.generateLore(I.t("Made from the fallen head of a malignant monster"))); - } - else - { - /// Golden head lore for players. {0} = player name. - meta.setLore(GuiUtils.generateLore(I.t("Made from the fallen head of {0}", name))); - } - } - - result.setItemMeta(meta); - return result; - } - - return null; - } - - /** - * Changes the name of the result item of the anti-lore recipe, - * to keep the same name than the original. - * - * @param recipe The recipe. - * @param inventory The crafting inventory. Used to get the name of the item placed in the inventory grid. - * @return The ItemStack if a change was needed; null else. - */ - public ItemStack keepNameOnLoreRemover(Recipe recipe, CraftingInventory inventory) - { - if ((UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.ADD_LORE.get() || UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.ADD_LORE.get()) - && (RecipesUtils.areSimilar(recipe, getLoreRemoverNormalRecipe()) || RecipesUtils.areSimilar(recipe, getLoreRemoverNotchRecipe()))) - { - - ItemStack original = null; - for (int slot = 0; slot <= 9; slot++) - { - original = inventory.getMatrix()[slot]; - if (original.getType() != Material.AIR) - { - break; // Found (because there is only one item in the craft). - } - } - - ItemMeta metaOriginal = original.getItemMeta(); - - if (metaOriginal != null && metaOriginal.hasDisplayName()) - { - ItemStack result = recipe.getResult(); - ItemMeta metaResult = result.getItemMeta(); - - metaResult.setDisplayName(metaOriginal.getDisplayName()); - result.setItemMeta(metaResult); - - return result; - } - - return null; - } - - return null; - } - - - /** - * Returns the current compass recipe. - * - * @return {@link RecipesManager#COMPASS_DISABLED}, {@link RecipesManager#COMPASS_EASY}, - * {@link RecipesManager#COMPASS_MEDIUM} or {@link RecipesManager#COMPASS_HARD}. - */ - public int getCompassRecipeType() - { - if (compassRecipeType != -1) - { - return compassRecipeType; - } - - if (UHConfig.GAMEPLAY_CHANGES.COMPASS.ENABLED.get()) - { - switch (UHConfig.GAMEPLAY_CHANGES.COMPASS.RECIPE.get().toLowerCase()) - { - case "easy": - compassRecipeType = COMPASS_EASY; - break; - - case "hard": - compassRecipeType = COMPASS_HARD; - break; - - default: - compassRecipeType = COMPASS_MEDIUM; - break; - } - } - else - { - compassRecipeType = COMPASS_DISABLED; - } - - return compassRecipeType; - } - - /** - * Returns the recipe that transforms 8 gold ingots and 1 human head into - * a golden apple. - * - * @return The shaped recipe. - */ - public ShapedRecipe getGoldenHeadHumanRecipe() - { - short damage = 0; - /// Item name of a golden head (from a player) - String name = I.tc("player_head", "{aqua}Golden head"); - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.CRAFT_NOTCH_APPLE.get()) - { - damage = 1; - /// Item name of an enchanted golden head (from a player) - name = I.tc("player_head", "{lightpurple}Golden head"); - } - - final ItemStack goldenAppleStack = new ItemStack(Material.GOLDEN_APPLE, UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_HUMAN.NUMBER_CRAFTED.get(), damage); - final ItemMeta goldenAppleMeta = goldenAppleStack.getItemMeta(); - goldenAppleMeta.setDisplayName(ChatColor.RESET + name); - goldenAppleStack.setItemMeta(goldenAppleMeta); - - final ShapedRecipe goldenAppleFromHeadRecipe = new ShapedRecipe(goldenAppleStack); - - goldenAppleFromHeadRecipe.shape("GGG", "GHG", "GGG"); - goldenAppleFromHeadRecipe.setIngredient('G', Material.GOLD_INGOT); - goldenAppleFromHeadRecipe.setIngredient('H', Material.SKULL_ITEM, SkullType.PLAYER.ordinal()); // TODO: deprecated, but no alternative found... - - return goldenAppleFromHeadRecipe; - } - - /** - * Returns the recipe that transforms 8 gold ingots and 1 wither head into - * a golden apple. - * - * @return The shaped recipe. - */ - public ShapedRecipe getGoldenHeadMonsterRecipe() - { - short damage = 0; - /// Item name of a golden head (from a monster) - String name = I.tc("monster_head", "{aqua}Golden head"); - - if (UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.CRAFT_NOTCH_APPLE.get()) - { - damage = 1; - /// Item name of an enchanted golden head (from a monster) - name = I.tc("monster_head", "{lightpurple}Golden head"); - } - - final ItemStack goldenAppleStack = new ItemStack(Material.GOLDEN_APPLE, UHConfig.GAMEPLAY_CHANGES.CRAFT_GOLDEN_APPLE_FROM_HEAD.FROM_WITHER.NUMBER_CRAFTED.get(), damage); - final ItemMeta goldenAppleMeta = goldenAppleStack.getItemMeta(); - goldenAppleMeta.setDisplayName(ChatColor.RESET + name); - goldenAppleStack.setItemMeta(goldenAppleMeta); - - final ShapedRecipe goldenAppleFromWitherHeadRecipe = new ShapedRecipe(goldenAppleStack); - - goldenAppleFromWitherHeadRecipe.shape("GGG", "GHG", "GGG"); - goldenAppleFromWitherHeadRecipe.setIngredient('G', Material.GOLD_INGOT); - goldenAppleFromWitherHeadRecipe.setIngredient('H', Material.SKULL_ITEM, SkullType.WITHER.ordinal()); // TODO: deprecated, but no alternative found... - - return goldenAppleFromWitherHeadRecipe; - } - - /** - * Returns the recipe that transforms one golden apple into one golden apple. - * Used to remove the lore, so two apples from a different head are stackable. - * - * @return The shapeless recipe. - */ - public ShapelessRecipe getLoreRemoverNormalRecipe() - { - final ShapelessRecipe goldenAppleLoreRemoverRecipe = new ShapelessRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 0)); - goldenAppleLoreRemoverRecipe.addIngredient(Material.GOLDEN_APPLE); - - return goldenAppleLoreRemoverRecipe; - } - - /** - * Returns the recipe that transforms one enchanted golden apple into one enchanted - * golden apple. - * Used to remove the lore, so two apples from a different head are stackable. - * - * @return The shapeless recipe. - */ - public ShapelessRecipe getLoreRemoverNotchRecipe() - { - final ShapelessRecipe goldenAppleLoreRemoverNotchRecipe = new ShapelessRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); - goldenAppleLoreRemoverNotchRecipe.addIngredient(Material.GOLDEN_APPLE, 1); - - return goldenAppleLoreRemoverNotchRecipe; - } - - /** - * Returns the recipe that transforms one melon and one gold block into a golden melon. - * - * @return The shapeless recipe. - */ - public ShapelessRecipe getGoldenMelonRecipe() - { - final ShapelessRecipe goldenMelonRecipe = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON)); - goldenMelonRecipe.addIngredient(1, Material.GOLD_BLOCK); - goldenMelonRecipe.addIngredient(1, Material.MELON); - - return goldenMelonRecipe; - } - - /** - * Returns the vanilla recipe for the compass. - * - * @return The shaped recipe. - */ - public ShapedRecipe getVanillaCompassRecipe() - { - final ShapedRecipe vanillaCompassRecipe = new ShapedRecipe(new ItemStack(Material.COMPASS)); - vanillaCompassRecipe.shape(" I ", "IRI", " I "); - - vanillaCompassRecipe.setIngredient('I', Material.IRON_INGOT); - vanillaCompassRecipe.setIngredient('R', Material.REDSTONE); - - return vanillaCompassRecipe; - } - - /** - * Returns the vanilla recipe for the golden melon. - * - * @return The shaped recipe. - */ - public ShapedRecipe getVanillaGoldenMelonRecipe() - { - ShapedRecipe vanillaGoldenMelonRecipe = new ShapedRecipe(new ItemStack(Material.SPECKLED_MELON)); - vanillaGoldenMelonRecipe.shape("GGG", "GMG", "GGG"); - - vanillaGoldenMelonRecipe.setIngredient('G', Material.GOLD_NUGGET); - vanillaGoldenMelonRecipe.setIngredient('M', Material.MELON); - - return vanillaGoldenMelonRecipe; - } - - - /** - * Returns the last failed recipe. - * - * Use {@link RecipesManager#RECIPE_COMPASS}, {@link RecipesManager#RECIPE_GLISTERING_MELON} and - * {@link RecipesManager#RECIPE_ENCHANTED_GOLDEN_APPLE} to get the type of the failed recipe. - * - * @return the lastFailedRecipe - */ - public String getLastFailedRecipe() - { - return lastFailedRecipe; - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java index 7d11452..58e3061 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java @@ -32,7 +32,6 @@ package eu.carrade.amaury.UHCReloaded.utils; -import eu.carrade.amaury.UHCReloaded.UHConfig; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; import org.apache.commons.lang3.Validate; @@ -190,31 +189,6 @@ public UHSound(ConfigurationSection config) this.pitch = (float) config.getDouble("pitch"); } - /** - * Constructs a sound from a zLib sound configuration section. - * <p> - * Format: - * <pre> - * key: - * name: string parsable as a sound. If not parsable, null used (i.e. no sound played). - * volume: decimal number - * pitch: decimal number - * </pre> - * - * @param config The configuration section. - */ - public UHSound(UHConfig.SoundSection config) - { - if (config == null) - { - return; - } - - this.sound = config.NAME.get(); - this.volume = (float) config.VOLUME.get(); - this.pitch = (float) config.PITCH.get(); - } - /** * Plays the sound for the specified player. * <p> From b89217aa198c1ee85356b109a7ce34c100acaa2b Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 19 Jan 2019 22:24:45 +0100 Subject: [PATCH 57/91] Added amount of regen in the apples tooltips, if non-vanilla. --- .../modules/gameplay/goldenHeads/Config.java | 4 +- .../goldenHeads/GoldenHeadsModule.java | 143 +++++++++++------- 2 files changed, 94 insertions(+), 53 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java index 3c4366e..fa6e21f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java @@ -52,6 +52,8 @@ public Config(File file) public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH = item("drop-head-on-death", true); public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH_PVP_ONLY = item("drop-head-on-death-pvp-only", false); + public static final ConfigurationItem<Boolean> DISPLAY_REGEN_AMOUNT_ON_APPLES = item("display-regen-amount-on-apples", true); + public static final GoldenAppleSection GOLDEN_APPLE = section("golden-apple", GoldenAppleSection.class); public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = section("golden-apple", EnchantedGoldenAppleSection.class); @@ -69,7 +71,7 @@ public static class GoldenAppleSection extends ConfigurationSection public static class EnchantedGoldenAppleSection extends ConfigurationSection { - public final ConfigurationItem<Boolean> ENABLE = item("enable", false); + public final ConfigurationItem<Boolean> ENABLE = item("enable", true); public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 180); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java index 5debf17..433e7c7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -46,6 +46,7 @@ import fr.zcraft.zlib.tools.items.ItemUtils; import fr.zcraft.zlib.tools.reflection.NMSException; import fr.zcraft.zlib.tools.runners.RunTask; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -77,6 +78,9 @@ public class GoldenHeadsModule extends UHModule { private final static UUID HEADS_UUID = UUID.fromString("1a050e3b-6274-434e-b8c0-a720048142e7"); + private final String HEART = "\u2764"; + private final String HALF = "\u00bd"; + private final static int TICKS_BETWEEN_EACH_REGENERATION = 50; private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN = 4; private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH = 180; @@ -178,8 +182,10 @@ public void onPreCraft(final PrepareItemCraftEvent ev) final ItemStack result = ev.getInventory().getResult(); if (result == null || (result.getType() != Material.GOLDEN_APPLE /* && result.getType() != Material.ENCHANTED_GOLDEN_APPLE FIXME 1.13 */)) return; - if ((!Config.GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && result.getData().getData() == 0) - || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && result.getData().getData() == 1)) + final boolean isEnchanted = result.getData().getData() == 1; + + if ((!Config.GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && !isEnchanted) + || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && isEnchanted)) { result.setType(Material.AIR); } @@ -193,13 +199,13 @@ public void onPreCraft(final PrepareItemCraftEvent ev) final ItemStackBuilder revampedResult = new ItemStackBuilder(result); if (headType == SkullType.WITHER && - ((result.getData().getData() == 0 && Config.WITHER_GOLDEN_HEAD.ADD_LORE.get()) || (result.getData().getData() == 1 && Config.WITHER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) + ((!isEnchanted && Config.WITHER_GOLDEN_HEAD.ADD_LORE.get()) || (isEnchanted && Config.WITHER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) { revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of a malignant monster")); } else if (headType == SkullType.PLAYER && - ((result.getData().getData() == 0 && Config.PLAYER_GOLDEN_HEAD.ADD_LORE.get()) || (result.getData().getData() == 1 && Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) + ((!isEnchanted && Config.PLAYER_GOLDEN_HEAD.ADD_LORE.get()) || (isEnchanted && Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) { // We retrieve the player name to write it into the lore String name = null; @@ -230,6 +236,35 @@ else if (headType == SkullType.PLAYER && revampedResult.hideAttributes().item(); } + + + /* *** We add the regeneration amount on all apples, if non-vanilla *** */ + + if (Config.DISPLAY_REGEN_AMOUNT_ON_APPLES.get()) + { + final int halfHearts = getRegenerationFor(headType, isEnchanted); + if (halfHearts != 0 && ((!isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN) || (isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH))) + { + final int hearts = halfHearts / 2; + final boolean plusHalf = halfHearts % 2 != 0; + + final String heartsSymbol; + + if (hearts <= 10) + { + heartsSymbol = ChatColor.RED + StringUtils.repeat(HEART, hearts) + (plusHalf ? ChatColor.GRAY + " + " + HALF : ""); + } + else + { + heartsSymbol = ChatColor.RED + HEART + ChatColor.GRAY + " × " + hearts + (plusHalf ? " + " + HALF : ""); + } + + final ItemStackBuilder revampedResult = new ItemStackBuilder(result); + if (headType != null) revampedResult.loreSeparator(); + + revampedResult.loreLine(ChatColor.GRAY, I.t("Regenerates {0}", heartsSymbol)).item(); + } + } } @EventHandler @@ -268,54 +303,8 @@ public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) final SkullType headType = readHeadType(ev.getItem()); final short dataValue = ev.getItem().getDurability(); - final int halfHearts; - final int level; - - // Standard golden apple - if (headType == null) - { - if (dataValue == 0) // FIXME 1.13 - { - halfHearts = Config.GOLDEN_APPLE.REGENERATION.get(); - level = REGENERATION_LEVEL_GOLDEN_APPLE; - } - else - { - halfHearts = Config.ENCHANTED_GOLDEN_APPLE.REGENERATION.get(); - level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; - } - } - - else if (headType == SkullType.PLAYER) - { - if (dataValue == 0) // FIXME 1.13 - { - halfHearts = Config.PLAYER_GOLDEN_HEAD.REGENERATION.get(); - level = REGENERATION_LEVEL_GOLDEN_APPLE; - } - else - { - halfHearts = Config.PLAYER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); - level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; - } - } - - else if (headType == SkullType.WITHER) - { - if (dataValue == 0) // FIXME 1.13 - { - halfHearts = Config.WITHER_GOLDEN_HEAD.REGENERATION.get(); - level = REGENERATION_LEVEL_GOLDEN_APPLE; - } - else - { - halfHearts = Config.WITHER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); - level = REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; - } - } - - // Invalid attribute. Should never happen. - else return; + final int halfHearts = getRegenerationFor(headType, dataValue == 1); + final int level = dataValue == 0 ? REGENERATION_LEVEL_GOLDEN_APPLE : REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; // Technically, a level-I effect is « level 0 ». @@ -358,4 +347,54 @@ else if (headType == SkullType.WITHER) } } } + + /** + * Returns the amount of regeneration we should apply for a given apple. + * + * @param headType The apple type ({@code null} meaning standard apple; else, {@link SkullType#WITHER} or {@link SkullType#PLAYER}). + * @param isEnchanted True if this is an enchanted golden apple (aka Notch Apple). + * @return The amount of regeneration, or 0 if invalid (i.e. bad skull type). + */ + private int getRegenerationFor(final SkullType headType, final boolean isEnchanted) + { + // Standard golden apple + if (headType == null) + { + if (!isEnchanted) // FIXME 1.13 + { + return Config.GOLDEN_APPLE.REGENERATION.get(); + } + else + { + return Config.ENCHANTED_GOLDEN_APPLE.REGENERATION.get(); + } + } + + else if (headType == SkullType.PLAYER) + { + if (!isEnchanted) // FIXME 1.13 + { + return Config.PLAYER_GOLDEN_HEAD.REGENERATION.get(); + } + else + { + return Config.PLAYER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); + } + } + + else if (headType == SkullType.WITHER) + { + if (!isEnchanted) // FIXME 1.13 + { + return Config.WITHER_GOLDEN_HEAD.REGENERATION.get(); + } + else + { + return Config.WITHER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); + } + } + + // Invalid attribute. Should never happen. + else return 0; + } } From eed24986427d3a80d75c6ccd6cc7d1678ce34174 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 20 Jan 2019 03:01:52 +0100 Subject: [PATCH 58/91] List Header & Footer --- .../playerListHeaderFooter/Config.java | 52 +++++++ .../PlayerListHeaderFooterModule.java | 145 ++++++++++++++++++ .../ingame/episodes/EpisodesModule.java | 17 +- .../old/listeners/GameListener.java | 75 --------- .../misc/PlayerListHeaderFooterManager.java | 130 ---------------- 5 files changed, 213 insertions(+), 206 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java new file mode 100644 index 0000000..e30f2c9 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; + +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.zlib.components.configuration.ConfigurationMap; + +import java.io.File; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationMap<GamePhase, String> HEADERS = ConfigurationItem.map("headers", GamePhase.class, String.class); + public static final ConfigurationMap<GamePhase, String> FOOTERS = ConfigurationItem.map("footers", GamePhase.class, String.class); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java new file mode 100644 index 0000000..35843a8 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -0,0 +1,145 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; + +import eu.carrade.amaury.UHCReloaded.UHConfig; +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.text.ListHeaderFooter; +import fr.zcraft.zteams.events.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Supplier; +import java.util.stream.Stream; + + +@ModuleInfo ( + name = "Players List Header & Footer", + description = "Fills the players list header & footer with any text, that may contains infos related " + + "to the current game through placeholders. Other modules can add placeholders.", + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.COSMETICS, + icon = Material.DETECTOR_RAIL, + settings = Config.class, + can_be_loaded_late = false +) +public class PlayerListHeaderFooterModule extends UHModule +{ + private final Map<String, Supplier<String>> placeholderSuppliers = new HashMap<>(); + + @Override + protected void onEnable() + { + registerPlaceholder("title", UHConfig.TITLE::get); + registerPlaceholder("playersText", () -> I.tn("{0} player", "{0} players", UR.game().countAlivePlayers())); + registerPlaceholder("playersCount", () -> String.valueOf(UR.game().countAlivePlayers())); + registerPlaceholder("teamsText", () -> I.tn("{0} team", "{0} teams", UR.game().countAliveTeams())); + registerPlaceholder("teamsCount", () -> String.valueOf(UR.game().countAliveTeams())); + + update(); + } + + /** + * Registers a new placeholder for player list headers & footers. + * + * @param placeholderName The name of the placeholder. The module will lookup for {givenName} + * in the patterns. + * @param supplier The supplier returning the value to use for this placeholder. + */ + public void registerPlaceholder(final String placeholderName, final Supplier<String> supplier) + { + placeholderSuppliers.put(placeholderName, supplier); + } + + private String computeText(String pattern) + { + return pattern.isEmpty() ? "" : ChatColor.translateAlternateColorCodes('&', replaceTags(pattern)); + } + + /** + * @param raw The raw text. + * @return The text, with tags replaced using the registered placeholders. + */ + private String replaceTags(String raw) + { + for (Map.Entry<String, Supplier<String>> entry : placeholderSuppliers.entrySet()) + { + raw = raw.replace("{" + entry.getKey() + "}", entry.getValue().get()); + } + + return raw; + } + + public void update() + { + if (!isEnabled()) return; // Other modules may keep a reference if the module is disabled. + + final String headerPattern = Config.HEADERS.get(UR.game().getPhase()); + final String footerPattern = Config.FOOTERS.get(UR.game().getPhase()); + + if (!headerPattern.isEmpty() || !footerPattern.isEmpty()) + { + final String header = computeText(headerPattern); + final String footer = computeText(footerPattern); + + Stream.concat( + UR.game().getAliveConnectedPlayers().stream(), + UR.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) + ).forEach(player -> ListHeaderFooter.sendListHeaderFooter(player, header, footer)); + } + } + + @EventHandler (priority = EventPriority.MONITOR) protected void onGamePhaseChange(final GamePhaseChangedEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerDeath(final AlivePlayerDeathEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerResurrect(final PlayerResurrectedEvent ev) { update(); } + + @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamUpdatedEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamRegisteredEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamUnregisteredEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final PlayerJoinedTeamEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final PlayerLeftTeamEvent ev) { update(); } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java index c874eff..861dfb0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java @@ -44,6 +44,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.commands.ShiftCommand; import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; @@ -73,8 +74,9 @@ ) public class EpisodesModule extends UHModule { - private final GameModule game = UR.module(GameModule.class); + private final GameModule game = UR.game(); private final TimersModule timers = UR.module(TimersModule.class); + private final PlayerListHeaderFooterModule headFoot = UR.module(PlayerListHeaderFooterModule.class); private Timer episodesTimer; private int episode = 1; @@ -92,6 +94,12 @@ protected void onEnable() episodesTimer.setNameDisplayed(false); episodesTimer.start(); + + if (headFoot != null) + { + headFoot.registerPlaceholder("episodeText", () -> I.t("Episode {0}", episode)); + headFoot.registerPlaceholder("episodeNumber", () -> String.valueOf(episode)); + } } @Override @@ -155,6 +163,13 @@ public void onEpisodeChange(final EpisodeChangedEvent ev) "" ); } + + + // Update headers & footers + if (headFoot != null) + { + headFoot.update(); + } } public int getEpisode() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java deleted file mode 100644 index 30d2a83..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameListener.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.listeners; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerAchievementAwardedEvent; -import org.bukkit.event.player.PlayerStatisticIncrementEvent; - - -public class GameListener implements Listener -{ - private final UHCReloaded p; - - - public GameListener() - { - this.p = UHCReloaded.get(); - } - - /** - * Used to disable the achievements before the game. - */ - @EventHandler - public void onPlayerAchievementAwarded(final PlayerAchievementAwardedEvent ev) - { - //if (!p.getGameManager().isGameStarted() && UHConfig.ACHIEVEMENTS.DISABLE_ACHIEVEMENTS_BEFORE_START.get()) - { - ev.setCancelled(true); - } - } - - /** - * Used to disable the statistics before the game. - */ - @EventHandler - public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) - { - //if (!p.getGameManager().isGameStarted() && UHConfig.STATISTICS.DISABLE_STATISTICS_BEFORE_START.get()) - { - ev.setCancelled(true); - } - } -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java deleted file mode 100644 index 81356ac..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/PlayerListHeaderFooterManager.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.old.misc; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import fr.zcraft.zlib.tools.text.ListHeaderFooter; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - - -public class PlayerListHeaderFooterManager -{ - private final String WAITING_HEADER_PATTERN; - private final String WAITING_FOOTER_PATTERN; - private final String IN_GAME_HEADER_PATTERN; - private final String IN_GAME_FOOTER_PATTERN; - - private String currentHeader = ""; - private String currentFooter = ""; - - - public PlayerListHeaderFooterManager() - { - WAITING_HEADER_PATTERN = UHConfig.PLAYERS_LIST.WAITING_TIME.HEADER.get(); - WAITING_FOOTER_PATTERN = UHConfig.PLAYERS_LIST.WAITING_TIME.FOOTER.get(); - IN_GAME_HEADER_PATTERN = UHConfig.PLAYERS_LIST.IN_GAME_TIME.HEADER.get(); - IN_GAME_FOOTER_PATTERN = UHConfig.PLAYERS_LIST.IN_GAME_TIME.FOOTER.get(); - - updateHeadersFooters(); - } - - - public void updateHeadersFooters() - { - computeHeadersFooter(); - send(); - } - - public void sendTo(Player player) - { - if (!currentHeader.isEmpty() || !currentFooter.isEmpty()) - ListHeaderFooter.sendListHeaderFooter(player, currentHeader, currentFooter); - } - - - private void computeHeadersFooter() - { -// if (UHCReloaded.get().getGameManager().isGameStarted()) -// { -// currentHeader = computeText(IN_GAME_HEADER_PATTERN); -// currentFooter = computeText(IN_GAME_FOOTER_PATTERN); -// } -// else -// { -// currentHeader = computeText(WAITING_HEADER_PATTERN); -// currentFooter = computeText(WAITING_FOOTER_PATTERN); -// } - } - - private String computeText(String pattern) - { - return pattern.isEmpty() ? "" : ChatColor.translateAlternateColorCodes('&', replaceTags(pattern)); - } - - /** - * Tags: - * - {title}: contains the scoreboard title (key scoreboard.title). - * - {episodeText}: contains the localized “Episode x” text. - * - {playersText}: contains the localized “x players left” text. - * - {teamsText}: contains the localized “x teams left” text. - * - {episodeNumber}: contains the raw episode number (e.g. “2”). - * - {playersCount}: contains the raw alive players count (e.g. “18”). - * - {teamsCount}: contains the raw alive teams count (e.g. “6”). - * - * @param raw The raw text. - * @return The text, with tags replaced. - */ - private String replaceTags(String raw) - { - return raw -// .replace("{title}", UHConfig.SCOREBOARD.TITLE.get()) -// -// /// Episode in the player list ({episodeText} replacement). {0} = current episode number. -// .replace("{episodeText}", I.t("Episode {0}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode()))) -// /// Players in the player list ({playersText} replacement). {0} = current alive players count. -// .replace("{playersText}", I.tn("{0} player", "{0} players", UHCReloaded.get().getGameManager().getAlivePlayersCount(), UHCReloaded.get().getGameManager().getAlivePlayersCount())) -// /// Teams in the player list ({teamsText} replacement). {0} = current alive teams count. -// .replace("{teamsText}", I.tn("{0} team", "{0} teams", UHCReloaded.get().getGameManager().getAliveTeamsCount(), UHCReloaded.get().getGameManager().getAliveTeamsCount())) -// -// .replace("{episodeNumber}", String.valueOf(UHCReloaded.get().getGameManager().getEpisode())) -// .replace("{playersCount}", String.valueOf(UHCReloaded.get().getGameManager().getAlivePlayersCount())) -// .replace("{teamsCount}", String.valueOf(UHCReloaded.get().getGameManager().getAliveTeamsCount())) - ; - } - - private void send() - { - if (!currentHeader.isEmpty() || !currentFooter.isEmpty()) - ListHeaderFooter.sendListHeaderFooter(currentHeader, currentFooter); - } -} From a74d94b3dbe3bea3c500e848a615833181e57445 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 20 Jan 2019 13:45:08 +0100 Subject: [PATCH 59/91] Built-in modules are loaded by default without having to reference them in the configuration file. --- .../amaury/UHCReloaded/UHCReloaded.java | 35 +++------ .../carrade/amaury/UHCReloaded/UHConfig.java | 1 + .../UHCReloaded/core/ModulesManager.java | 75 +++++++++++++++++-- ...sManagerModule.java => ModulesModule.java} | 2 +- .../core/modules/gui/MainConfigGUI.java | 3 +- src/main/resources/config.yml | 53 +++---------- 6 files changed, 92 insertions(+), 77 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/{ModulesManagerModule.java => ModulesModule.java} (98%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 484332f..9bf256a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -36,14 +36,12 @@ import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesManagerModule; +import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesModule; import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.modules.ingame.freezer.FreezerModule; -import eu.carrade.amaury.UHCReloaded.modules.other.rules.RulesModule; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Commands; import fr.zcraft.zlib.components.gui.Gui; @@ -74,7 +72,6 @@ public class UHCReloaded extends ZPlugin implements Listener private static UHCReloaded instance; private ModulesManager modulesManager = null; - private Scoreboard scoreboard = null; private World worldNormal = null; @@ -83,10 +80,6 @@ public class UHCReloaded extends ZPlugin implements Listener private boolean worldsLoaded = false; - private RulesModule rulesManager = null; - - private FreezerModule freezer = null; - @Override public void onEnable() @@ -119,7 +112,7 @@ public void onEnable() /* *** Core modules *** */ modulesManager.registerModules( - ModulesManagerModule.class, // Manages the modules from the game/commands. + ModulesModule.class, // Manages the modules from the game/commands. SidebarModule.class, // Manages the sidebar and provides hooks for other modules. // Must be loaded before the game-related modules. @@ -141,6 +134,14 @@ public void onEnable() ); + /* *** Built-in modules *** */ + + if (UHConfig.BULT_IN_MODULES.get()) + { + modulesManager.registerBuiltInModules(); + } + + /* *** Config modules *** */ UHConfig.MODULES.forEach((BiConsumer<String, Boolean>) modulesManager::registerModule); @@ -283,22 +284,6 @@ private World setDefaultWorld(final World.Environment environment, final String return Bukkit.getWorlds().get(0); } - /** - * @return the rules manager. - */ - public RulesModule getRulesManager() - { - return rulesManager; - } - - /** - * Returns the freezer. - */ - public FreezerModule getFreezer() - { - return freezer; - } - /** * Returns the plugin's instance. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index 4d32f0b..201a557 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -14,6 +14,7 @@ public class UHConfig extends Configuration static public final ConfigurationItem<String> TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); + static public final ConfigurationItem<Boolean> BULT_IN_MODULES = item("built-in-modules", true); static public final ConfigurationMap<String, Boolean> MODULES = map("modules", String.class, Boolean.class); static public final WorldsSection WORLDS = section("worlds", WorldsSection.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index 4ff49ce..441bfb5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -33,9 +33,12 @@ */ package eu.carrade.amaury.UHCReloaded.core; +import com.google.common.reflect.ClassPath; import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.UHCReloaded.modules.ingame.kick.KickModule; +import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import fr.zcraft.zlib.components.commands.Command; @@ -51,6 +54,7 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; +import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.*; @@ -58,10 +62,64 @@ public class ModulesManager extends ZLibComponent implements Listener { + /** + * The package were all built-in modules are stored. + */ + private final static String MODULES_PACKAGE = "eu.carrade.amaury.UHCReloaded.modules"; + + /** + * These built-in modules will not be enabled by default. It includes all scenarii, so the default game + * is a standard one, and the kick module, as spectators are better for most admins. + */ + private final static List<Class<? extends UHModule>> DISABLED_BY_DEFAULT = Arrays.asList( + KickModule.class, + AlliancesModule.class + ); + + /** + * All the registered modules. + */ private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); + + /** + * These loads times were loaded using {@link #loadModules(ModuleLoadTime)} and are stored to not + * be loaded again (e.g. in case of cancelled start, modules with {@link ModuleLoadTime#ON_GAME_STARTING} + * will not be loaded twice). + */ private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); + /** + * Lookup and loads all built-in modules. They will be enabled by default, except if in + * the {@link #DISABLED_BY_DEFAULT disabled-by-default list}. + */ + public void registerBuiltInModules() + { + long t = System.currentTimeMillis(); + int i = 0; + + try + { + for (ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(MODULES_PACKAGE)) + { + final Class<?> potentialModuleClass = classInfo.load(); + + if (UHModule.class.isAssignableFrom(potentialModuleClass)) + { + registerModule((Class<? extends UHModule>) potentialModuleClass, !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); + i++; + } + } + } + catch (final IOException e) + { + PluginLogger.error("Unable to load built-in modules.", e); + } + + PluginLogger.info("Registered {0} built-in modules in {1}ms", i, System.currentTimeMillis() - t); + } + + /** * @return A view on all registered modules. */ @@ -71,7 +129,7 @@ public Collection<ModuleWrapper> getModules() } /** - * Registers an UHCReloaded module (or many). It is not enabled by this method. + * Registers an UHCReloaded module (or many). It is not loaded by this method. * * @param modules the module's class, that must accept a zero-arguments constructor. */ @@ -82,18 +140,21 @@ public final void registerModules(final Class<? extends UHModule>... modules) } /** - * Registers an UHCReloaded module (or many). It is not enabled by this method. + * Registers an UHCReloaded module. It is not loaded by this method. * * @param module the module's class, that must accept a zero-arguments constructor. - * @param initiallyEnabled {@code true} if this module, according to the configuration file, should be loaded at startup. + * @param initiallyEnabled {@code true} if this module, according to the configuration file, should be enabled at startup. */ public void registerModule(final Class<? extends UHModule> module, final boolean initiallyEnabled) { - this.modules.put(module, new ModuleWrapper(module, initiallyEnabled)); + if (!modules.containsKey(module)) + { + this.modules.put(module, new ModuleWrapper(module, initiallyEnabled)); + } } /** - * Registers an UHCReloaded module. It is not enabled by this method. + * Registers an UHCReloaded module. It is not loaded by this method. * * It tries to load the following classes (in this order, taking the first existing): * @@ -116,7 +177,7 @@ public void registerModule(final String module) } /** - * Registers an UHCReloaded module. It is not enabled by this method. + * Registers an UHCReloaded module. It is not loaded by this method. * * It tries to load the following classes (in this order, taking the first existing): * @@ -139,7 +200,7 @@ public void registerModule(final String module, boolean initiallyEnabled) { final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( module.replace('-', '.'), - "eu.carrade.amaury.UHCReloaded.modules", + MODULES_PACKAGE, "Module", UHModule.class ); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java index 02b60c6..1fc44d9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesManagerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java @@ -61,7 +61,7 @@ icon = Material.COMMAND, can_be_unloaded = false ) -public class ModulesManagerModule extends UHModule +public class ModulesModule extends UHModule { @Override public List<Class<? extends Command>> getCommands() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java index c222a44..3e064db 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java @@ -36,6 +36,7 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; import eu.carrade.amaury.UHCReloaded.modules.beginning.wait.Config; +import eu.carrade.amaury.UHCReloaded.modules.beginning.wait.WaitModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules.ModulesListGUI; import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start.StartGameGUI; @@ -103,7 +104,7 @@ protected void onUpdate() .longLore(ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Actions on players coming soon: in the mean time, use commands."), 38) ); - action("teams", 12, new ItemStackBuilder(Config.TEAM_SELECTOR.ITEM.get()) + action("teams", 12, new ItemStackBuilder(UR.module(WaitModule.class) != null ? Config.TEAM_SELECTOR.ITEM.get() : Material.NETHER_STAR) .title(ChatColor.AQUA, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teams")) .amount(Math.max(ZTeams.get().countTeams(), 1)) .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", ZTeams.get().countTeams())) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 045f597..b688661 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,52 +15,19 @@ # Empty value: system language. lang: fr +# If set to false, no built-in modules (except core ones) will be loaded (except if +# re-specified in the `modules` configuration below). +built-in-modules: true -# The modules to load & load. You can add modules provided by other plugins. +# The modules to load. You can add modules provided by other plugins. Other plugins also may +# self-register their modules for you. # Each module's configuration is in plugins/UHPlugin/modules/<modulename>.yml . -# You can put internal modules or refer to modules classes from other plugins. In all -# cases, replace all dots in class paths by dashes. +# You can put built-in modules or refer to modules classes from other plugins. In all +# cases, replace all dots in class paths by dashes. The value after “:” may be true to +# enable the module by default, or false else. modules: - "beginning-wait": true - "beginning-cages": true - - "border-walls": true - "border-warning": true - "border-check": true - - "ingame-hardcore": true - "ingame-weather": true - "ingame-daylightCycle": true - "ingame-food": true - "ingame-health": true - "ingame-listHealth": true - "ingame-teleportation": true - "ingame-episodes": true - "ingame-killsCount": true - "ingame-deathAnnouncement": true - "ingame-kick": false - "ingame-freezer": true - "ingame-advancements": true - "ingame-statistics": true - - "gameplay-compass": true - "gameplay-goldenHeads": true - "gameplay-noGhastTears": true - "gameplay-noEnderPearlDamages": true - "gameplay-noWitches": true - "gameplay-potions": true - "gameplay-xpToKillers": true - - "cosmetics-hardcoreHearts": true - "cosmetics-motd": true - "cosmetics-dynmap": true - - "other-reports": true - "other-playersLoader": true - "other-rules": true - "other-about": true - - "scenarii-alliances": false + # "scenarii-alliances": true + # "eu-my-other-package-moduleName": true # The worlds to use as main worlds. From b200f326975df350a92ecddb24ae7a702c0f99ed Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 21 Jan 2019 01:45:10 +0100 Subject: [PATCH 60/91] Normalized config and added default files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added default files in the modules directory containing configuration default, so it can be edited without having to look at the source code → Normalized configuration with lower-hyphenated keys everywhere. → Fixed bugs → Added a command in the players list head&foot module to get all placeholders. → Added support for the random compass. --- .../amaury/UHCReloaded/core/ModuleInfo.java | 18 ++++ .../UHCReloaded/core/ModuleWrapper.java | 74 +++++++++++-- .../UHCReloaded/core/ModulesManager.java | 6 +- .../modules/beginning/cages/Config.java | 6 +- .../modules/beginning/wait/WaitModule.java | 3 +- .../modules/border/walls/Config.java | 4 +- .../modules/border/warning/Config.java | 3 +- .../border/warning/WarningCommand.java | 2 +- .../modules/border/warning/WarningModule.java | 2 +- .../modules/core/sidebar/Config.java | 50 --------- .../modules/core/sidebar/SidebarModule.java | 1 - .../modules/core/teams/Config.java | 1 - .../ListPlaceholdersCommand.java | 85 +++++++++++++++ .../PlayerListHeaderFooterModule.java | 52 ++++++--- .../gameplay/compass/CompassModule.java | 35 ++++-- .../modules/gameplay/compass/Config.java | 2 +- .../modules/gameplay/goldenHeads/Config.java | 4 +- .../ingame/deathAnnouncement/Config.java | 2 +- .../modules/other/reports/Config.java | 2 +- .../modules/other/rules/Config.java | 4 +- .../amaury/UHCReloaded/utils/UHSound.java | 38 ++++++- .../modules-config/other/reports.yml | 53 --------- src/main/resources/modules/core-border.yml | 52 +++++++++ src/main/resources/modules/core-game.yml | 44 ++++++++ src/main/resources/modules/core-spawns.yml | 15 +++ .../resources/modules/core-spectators.yml | 11 ++ src/main/resources/modules/core-teams.yml | 82 ++++++++++++++ .../resources/modules/cosmetics-episodes.yml | 9 ++ .../modules/cosmetics-hardcore-hearts.yml | 12 +++ .../cosmetics-player-list-header-footer.yml | 33 ++++++ .../modules/end-death-announcement.yml | 20 ++++ src/main/resources/modules/end-kick.yml | 5 + .../resources/modules/end-xp-to-killers.yml | 5 + .../resources/modules/external-dynmap.yml | 5 + src/main/resources/modules/external-motd.yml | 5 + .../resources/modules/external-reports.yml | 102 ++++++++++++++++++ .../resources/modules/gameplay-compass.yml | 25 +++++ .../modules/gameplay-daylight-cycle.yml | 15 +++ .../modules/gameplay-golden-heads.yml | 73 +++++++++++++ .../resources/modules/gameplay-hardcore.yml | 6 ++ .../modules/gameplay-killer-rabbit.yml | 8 ++ .../resources/modules/gameplay-no-witches.yml | 5 + .../resources/modules/gameplay-potions.yml | 11 ++ .../resources/modules/gameplay-weather.yml | 11 ++ .../resources/modules/scenarii-alliances.yml | 12 +++ src/main/resources/modules/starting-cages.yml | 25 +++++ .../resources/modules/utilities-rules.yml | 17 +++ .../resources/modules/utilities-walls.yml | 8 ++ .../resources/modules/utilities-warning.yml | 3 + .../resources/modules/waiting-phase-wait.yml | 39 +++++++ 50 files changed, 951 insertions(+), 154 deletions(-) delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java delete mode 100644 src/main/resources/modules-config/other/reports.yml create mode 100644 src/main/resources/modules/core-border.yml create mode 100644 src/main/resources/modules/core-game.yml create mode 100644 src/main/resources/modules/core-spawns.yml create mode 100644 src/main/resources/modules/core-spectators.yml create mode 100644 src/main/resources/modules/core-teams.yml create mode 100644 src/main/resources/modules/cosmetics-episodes.yml create mode 100644 src/main/resources/modules/cosmetics-hardcore-hearts.yml create mode 100644 src/main/resources/modules/cosmetics-player-list-header-footer.yml create mode 100644 src/main/resources/modules/end-death-announcement.yml create mode 100644 src/main/resources/modules/end-kick.yml create mode 100644 src/main/resources/modules/end-xp-to-killers.yml create mode 100644 src/main/resources/modules/external-dynmap.yml create mode 100644 src/main/resources/modules/external-motd.yml create mode 100644 src/main/resources/modules/external-reports.yml create mode 100644 src/main/resources/modules/gameplay-compass.yml create mode 100644 src/main/resources/modules/gameplay-daylight-cycle.yml create mode 100644 src/main/resources/modules/gameplay-golden-heads.yml create mode 100644 src/main/resources/modules/gameplay-hardcore.yml create mode 100644 src/main/resources/modules/gameplay-killer-rabbit.yml create mode 100644 src/main/resources/modules/gameplay-no-witches.yml create mode 100644 src/main/resources/modules/gameplay-potions.yml create mode 100644 src/main/resources/modules/gameplay-weather.yml create mode 100644 src/main/resources/modules/scenarii-alliances.yml create mode 100644 src/main/resources/modules/starting-cages.yml create mode 100644 src/main/resources/modules/utilities-rules.yml create mode 100644 src/main/resources/modules/utilities-walls.yml create mode 100644 src/main/resources/modules/utilities-warning.yml create mode 100644 src/main/resources/modules/waiting-phase-wait.yml diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java index d9b6aa3..bb71ecd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java @@ -94,6 +94,24 @@ */ String settings_filename() default ""; + /** + * @return The settings's default filename, containing the default configuration written + * to the server's plugins/UHPlugin/modules directory if the file does not exists. + * + * The format can either be a simple filename without extension, like “moduleName“, and + * the file will be copied from the UHCReloaded's JAR, from modules/moduleName.yml; or + * the filename prefixed by the plugin name like so: “OtherPlugin:moduleName”, and the + * file will be copied from the given plugin's JAR, from modules/moduleName.yml too. + * + * If left empty, it will be derived from the module name and category, by converting + * the module's class name into hyphened-snake-case, removing the “-module” suffix (if + * any) and prefixing by the category converted to hyphened-snake-case. + * Example: “external-reports”. + * + * In all cases, the file will be copied into UHPlugin's data directory, under module/. + */ + String settings_default_filename() default ""; + /** * @return A list of external Bukkit/Spigot plugin this module depends on. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java index c4b7031..67fae70 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.core; import com.google.common.base.CaseFormat; +import com.google.common.base.Charsets; import eu.carrade.amaury.UHCReloaded.core.events.ModuleDisabledEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleEnabledEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; @@ -43,6 +44,7 @@ import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.items.ItemStackBuilder; import fr.zcraft.zlib.tools.reflection.Reflection; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -50,8 +52,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.lang.reflect.InvocationTargetException; import java.util.stream.Stream; @@ -74,6 +75,7 @@ public class ModuleWrapper private final Class<? extends ConfigurationInstance> moduleConfiguration; private final String settingsFileName; + private final String settingsDefaultFileName; private String[] dependencies; private final boolean internal; @@ -108,6 +110,7 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable icon = Material.AIR; moduleConfiguration = null; settingsFileName = null; + settingsDefaultFileName = null; dependencies = new String[] {}; } else @@ -123,9 +126,11 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable icon = info.icon(); moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); + settingsDefaultFileName = info.settings_default_filename().isEmpty() ? null : info.settings_default_filename(); dependencies = info.depends(); } + saveDefaultConfig(); loadConfiguration(); } @@ -372,23 +377,77 @@ public Class<? extends UHModule> getModuleClass() return moduleClass; } + private String getDefaultSettingsFileName() + { + return String.format("%s-%s", category.name().toLowerCase().replace('_', '-'), StringUtils.removeEnd(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, moduleClass.getSimpleName()), "-module")); + } + /** * @return A {@link File} representing the configuration file on the server's filesystem. */ private File getConfigurationFile() { - final String settingsFileName; + final String settingsFileName = this.settingsFileName != null ? this.settingsFileName + ".yml" : getDefaultSettingsFileName() + ".yml"; + return new File(ZLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); + } - if (this.settingsFileName != null) + /** + * Saves the default configuration file into the plugin's directory, if it + * does not exists ad the default configuration file does exist. + */ + public void saveDefaultConfig() + { + final File targetSettingsFile = getConfigurationFile(); + if (targetSettingsFile.exists()) return; + + final String settingsDefaultFileName = this.settingsDefaultFileName != null ? this.settingsDefaultFileName : getDefaultSettingsFileName(); + + final Plugin plugin; + final String settingsDefaultFilePath; + + // If the default file is in another plugin + if (settingsDefaultFileName.contains(":")) { - settingsFileName = this.settingsFileName + ".yml"; + final String[] parts = settingsDefaultFileName.split(":"); + final Plugin pl = Bukkit.getPluginManager().getPlugin(parts[0]); + if (pl != null) + { + plugin = pl; + settingsDefaultFilePath = "modules" + File.separator + String.join(":", (String[]) ArrayUtils.remove(parts, 0)) + ".yml"; + } + else return; } else { - settingsFileName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, moduleClass.getSimpleName()) + ".yml"; + plugin = UR.get(); + settingsDefaultFilePath = "modules" + File.separator + settingsDefaultFileName + ".yml"; } - return new File(ZLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); + final InputStream stream = plugin.getResource(settingsDefaultFilePath); + if (stream == null) return; + + try (final InputStreamReader reader = new InputStreamReader(stream, Charsets.UTF_8)) + { + final StringBuilder buffer = new StringBuilder(); + + int currentChar; + while((currentChar = reader.read()) != -1) + { + buffer.append((char) currentChar); + } + + targetSettingsFile.getParentFile().mkdirs(); + if (!targetSettingsFile.createNewFile()) return; + + try (final PrintWriter writer = new PrintWriter(targetSettingsFile)) + { + writer.write(buffer.toString()); + } + } + catch (final IOException e) + { + PluginLogger.error("Cannot create {0}'s default configuration file.", e, getName()); + } } /** @@ -416,7 +475,6 @@ private void loadConfiguration() final ConfigurationInstance settings = Reflection.instantiate(moduleConfiguration, settingsFile); settings.setEnabled(true); - settings.save(); } catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index 441bfb5..734c960 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -38,6 +38,7 @@ import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; import eu.carrade.amaury.UHCReloaded.modules.ingame.kick.KickModule; +import eu.carrade.amaury.UHCReloaded.modules.other.pomf.PomfModule; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; @@ -73,6 +74,7 @@ public class ModulesManager extends ZLibComponent implements Listener */ private final static List<Class<? extends UHModule>> DISABLED_BY_DEFAULT = Arrays.asList( KickModule.class, + PomfModule.class, AlliancesModule.class ); @@ -95,12 +97,12 @@ public class ModulesManager extends ZLibComponent implements Listener */ public void registerBuiltInModules() { - long t = System.currentTimeMillis(); + final long t = System.currentTimeMillis(); int i = 0; try { - for (ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(MODULES_PACKAGE)) + for (final ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(MODULES_PACKAGE)) { final Class<?> potentialModuleClass = classInfo.load(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java index bbadab2..78c1033 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java @@ -50,9 +50,9 @@ public Config(File file) } public static final ConfigurationItem<Cage.CageType> TYPE = item("type", Cage.CageType.TEAM_COLOR_TRANSPARENT); - public static final ConfigurationItem<Material> CUSTOM_BLOCK = item("customBlock", Material.BARRIER); - public static final ConfigurationItem<Boolean> BUILD_CEILING = item("buildCeiling", false); - public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visibleWalls", false); + public static final ConfigurationItem<Material> CUSTOM_BLOCK = item("custom-block", Material.BARRIER); + public static final ConfigurationItem<Boolean> BUILD_CEILING = item("build-ceiling", false); + public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visible-walls", false); public static final ConfigurationItem<Integer> RADIUS = item("radius", 2); public static final ConfigurationItem<Integer> HEIGHT = item("height", 3); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java index a17a166..112dd11 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java @@ -190,7 +190,7 @@ private boolean openGUI(Player player, ItemStack item) */ private void handleNewPlayer(final Player player) { - if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get()) + if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get() && UR.game().getPhase() != GamePhase.STARTING) { final Location worldSpawn = UR.get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); if (!UHUtils.safeTP(player, worldSpawn)) @@ -233,7 +233,6 @@ private void updateInventory(final Player player) return; } - PluginLogger.info("New state: {0}", state); playerInventoriesStates.put(player.getUniqueId(), state); player.setGameMode(builder ? GameMode.CREATIVE : GameMode.ADVENTURE); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java index 64542e2..668d010 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java @@ -56,7 +56,7 @@ public Config(File file) static public class BlockSection extends ConfigurationSection { - public final ConfigurationItem<Material> REPLACE_AIR = item("replaceAir", Material.GLASS); - public final ConfigurationItem<Material> REPLACE_SOLID = item("replaceSolid", Material.BEDROCK); + public final ConfigurationItem<Material> REPLACE_AIR = item("replace-air", Material.GLASS); + public final ConfigurationItem<Material> REPLACE_SOLID = item("replace-solid", Material.BEDROCK); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java index c88b807..97fde42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java @@ -33,6 +33,7 @@ */ package eu.carrade.amaury.UHCReloaded.modules.border.warning; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; @@ -47,5 +48,5 @@ public Config(File file) super(file); } - public static final ConfigurationItem<Integer> WARNING_INTERVAL = item("warningInterval", 90); + public static final ConfigurationItem<TimeDelta> WARNING_INTERVAL = item("warning-interval", new TimeDelta(0, 1, 30)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java index 2b08ba5..9826f96 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java @@ -84,7 +84,7 @@ else if (args[0].equalsIgnoreCase("cancel")) } warnings.setWarningSize(warnDiameter, warnTime, sender); - success(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", Config.WARNING_INTERVAL.get())); + success(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", (int) Config.WARNING_INTERVAL.get().getSeconds())); } catch (NumberFormatException e) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java index c29c208..5c050c2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java @@ -157,7 +157,7 @@ public void setWarningSize(final int diameter, final TimeDelta timeLeft, final C RunTask.timer( warningTask = new BorderWarningTask(), 20L, - 20L * Config.WARNING_INTERVAL.get() + 20L * Config.WARNING_INTERVAL.get().getSeconds() ); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java deleted file mode 100644 index bab2b46..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/Config.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ -package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; - -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import org.bukkit.ChatColor; - -import java.io.File; - -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - -} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java index 1d24f5a..b79a205 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java @@ -46,7 +46,6 @@ description = "Manages the sidebar and allows hooks for all modules into it.", category = ModuleCategory.CORE, icon = Material.BOOK_AND_QUILL, - settings = Config.class, internal = true, can_be_unloaded = false ) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java index def0ae9..fa94af2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java @@ -52,7 +52,6 @@ public Config(File file) static public final ConfigurationItem<Boolean> CAN_SEE_FRIENDLY_INVISIBLES = item("can-see-friendly-invisibles", true); static public final ConfigurationItem<Boolean> ALLOW_FRIENDLY_FIRE = item("allow-friendly-fire", true); static public final ConfigurationItem<Integer> MAX_PLAYERS_PER_TEAM = item("max-players-per-team", 0); - static public final ConfigurationItem<Boolean> RANDOM_COLORS = item("random-colors", true); static public final ConfigurationItem<Boolean> COLORIZE_CHAT = item("colorize-chat", true); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java new file mode 100644 index 0000000..f955a95 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java @@ -0,0 +1,85 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; + +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; +import fr.zcraft.zlib.components.commands.CommandException; +import fr.zcraft.zlib.components.commands.CommandInfo; +import fr.zcraft.zlib.components.commands.WithFlags; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.commands.PaginatedTextView; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + +import java.util.Map; +import java.util.function.Supplier; + +@CommandInfo (name = "list-hf-placeholders") +@WithFlags("page") +public class ListPlaceholdersCommand extends Command +{ + @Override + protected void run() throws CommandException + { + final Map<String, Supplier<String>> placeholders = UR.module(PlayerListHeaderFooterModule.class).getPlaceholderSuppliers(); + final int page = args.length > 0 ? getIntegerParameter(0) : 1; + + new PlaceholdersList() + .setData(placeholders.entrySet().toArray(new Map.Entry[placeholders.entrySet().size()])) + .setCurrentPage(page) + .display(sender); + } + + private final class PlaceholdersList extends PaginatedTextView<Map.Entry<String, Supplier<String>>> + { + @Override + protected void displayHeader(final CommandSender receiver) + { + receiver.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + I.tn("{0} registered placeholder", "{0} registered placeholders", data().length)); + } + + @Override + protected void displayItem(final CommandSender receiver, final Map.Entry<String, Supplier<String>> item) + { + receiver.sendMessage(String.format("%s{%s}%s\t« %s%s »", ChatColor.WHITE, item.getKey(), ChatColor.GRAY, item.getValue().get(), ChatColor.GRAY)); + } + + @Override + protected String getCommandToPage(final int page) + { + return build(String.valueOf(page)); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java index 35843a8..1b8aeba 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -36,23 +36,26 @@ import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.ListHeaderFooter; import fr.zcraft.zteams.events.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.function.Supplier; import java.util.stream.Stream; @@ -63,7 +66,7 @@ "to the current game through placeholders. Other modules can add placeholders.", when = ModuleLoadTime.POST_WORLD, category = ModuleCategory.COSMETICS, - icon = Material.DETECTOR_RAIL, + icon = Material.ACTIVATOR_RAIL, settings = Config.class, can_be_loaded_late = false ) @@ -80,7 +83,13 @@ protected void onEnable() registerPlaceholder("teamsText", () -> I.tn("{0} team", "{0} teams", UR.game().countAliveTeams())); registerPlaceholder("teamsCount", () -> String.valueOf(UR.game().countAliveTeams())); - update(); + RunTask.nextTick(this::update); + } + + @Override + public List<Class<? extends Command>> getCommands() + { + return Collections.singletonList(ListPlaceholdersCommand.class); } /** @@ -95,6 +104,11 @@ public void registerPlaceholder(final String placeholderName, final Supplier<Str placeholderSuppliers.put(placeholderName, supplier); } + public Map<String, Supplier<String>> getPlaceholderSuppliers() + { + return Collections.unmodifiableMap(placeholderSuppliers); + } + private String computeText(String pattern) { return pattern.isEmpty() ? "" : ChatColor.translateAlternateColorCodes('&', replaceTags(pattern)); @@ -121,21 +135,33 @@ public void update() final String headerPattern = Config.HEADERS.get(UR.game().getPhase()); final String footerPattern = Config.FOOTERS.get(UR.game().getPhase()); - if (!headerPattern.isEmpty() || !footerPattern.isEmpty()) + if ((headerPattern != null && !headerPattern.isEmpty()) || (footerPattern != null && !footerPattern.isEmpty())) { - final String header = computeText(headerPattern); - final String footer = computeText(footerPattern); - - Stream.concat( - UR.game().getAliveConnectedPlayers().stream(), - UR.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) - ).forEach(player -> ListHeaderFooter.sendListHeaderFooter(player, header, footer)); + final String header = headerPattern != null ? computeText(headerPattern) : ""; + final String footer = footerPattern != null ? computeText(footerPattern) : ""; + + final Stream<? extends Player> receivers; + + if (UR.game().currentPhaseAfter(GamePhase.STARTING)) + { + receivers = Stream.concat( + UR.game().getAliveConnectedPlayers().stream(), + UR.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) + ); + } + else + { + receivers = Bukkit.getOnlinePlayers().stream(); + } + + receivers.forEach(player -> ListHeaderFooter.sendListHeaderFooter(player, header, footer)); } } @EventHandler (priority = EventPriority.MONITOR) protected void onGamePhaseChange(final GamePhaseChangedEvent ev) { update(); } @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerDeath(final AlivePlayerDeathEvent ev) { update(); } @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerResurrect(final PlayerResurrectedEvent ev) { update(); } + @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerJoin(final PlayerJoinEvent ev) { update(); } @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamUpdatedEvent ev) { update(); } @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamRegisteredEvent ev) { update(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java index 5c097a4..660ad71 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java @@ -47,6 +47,7 @@ import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.RawMessage; import fr.zcraft.zteams.ZTeams; +import org.apache.commons.lang.math.RandomUtils; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -186,23 +187,41 @@ public void onPlayerInteract(final PlayerInteractEvent ev) return; } - final CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); + CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); - if (behavior == CompassBehavior.GIVE_DIRECTION || behavior == CompassBehavior.GIVE_BOTH) + if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) + { + final double r = RandomUtils.nextDouble(); + + if (r < .45) behavior = CompassBehavior.GIVE_DIRECTION; + else if (r < .9) behavior = CompassBehavior.GIVE_DISTANCE; + else behavior = CompassBehavior.GIVE_BOTH; + } + + if (behavior == CompassBehavior.GIVE_BOTH) { - /// Success message when a player uses his pointing compass. - compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("The compass now points to the closest player."))); // TODO update language files compassUser.setCompassTarget(nearest.getLocation()); + compassUser.sendMessage(UHUtils.prefixedMessage( + I.t("Compass"), + ChatColor.YELLOW + I.tn( + "The compass now points to the closest player, {gold}{0} block {yellow}from you.", + "The compass now points to the closest player, {gold}{0} blocks {yellow}from you.", + (int) nearest.getLocation().distanceSquared(compassUser.getLocation()) + ) + )); } - if (behavior == CompassBehavior.GIVE_DISTANCE || behavior == CompassBehavior.GIVE_BOTH) + else if (behavior == CompassBehavior.GIVE_DIRECTION) { - compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), I.tn("{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); + compassUser.setCompassTarget(nearest.getLocation()); + + /// Success message when a player uses his pointing compass. + compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("The compass now points to the closest player."))); // TODO update language files } - else if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) + else { - // TODO + compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), I.tn("{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); } new UHSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java index 3d1c605..c45d267 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java @@ -55,5 +55,5 @@ public Config(File file) public final static ConfigurationItem<Boolean> NEVER_TARGET_TEAMMATES = item("never-target-teammates", true); - public final static ConfigurationItem<CompassModule.CompassBehavior> COMPASS_BEHAVIOR = item("compass-behavior", CompassModule.CompassBehavior.GIVE_BOTH); + public final static ConfigurationItem<CompassModule.CompassBehavior> COMPASS_BEHAVIOR = item("compass-behavior", CompassModule.CompassBehavior.GIVE_DIRECTION); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java index fa6e21f..2f269e6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java @@ -55,7 +55,7 @@ public Config(File file) public static final ConfigurationItem<Boolean> DISPLAY_REGEN_AMOUNT_ON_APPLES = item("display-regen-amount-on-apples", true); public static final GoldenAppleSection GOLDEN_APPLE = section("golden-apple", GoldenAppleSection.class); - public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = section("golden-apple", EnchantedGoldenAppleSection.class); + public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = section("enchanted-golden-apple", EnchantedGoldenAppleSection.class); public static final GoldenHeadSection PLAYER_GOLDEN_HEAD = section("player-golden-head", GoldenHeadSection.class); public static final GoldenHeadSection WITHER_GOLDEN_HEAD = section("wither-golden-head", GoldenHeadSection.class); @@ -71,7 +71,7 @@ public static class GoldenAppleSection extends ConfigurationSection public static class EnchantedGoldenAppleSection extends ConfigurationSection { - public final ConfigurationItem<Boolean> ENABLE = item("enable", true); + public final ConfigurationItem<Boolean> ENABLE = item("enable", false); public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 180); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java index cf17a88..50fb6ef 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java @@ -54,5 +54,5 @@ public Config(File file) public static final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); public static final ConfigurationItem<Boolean> PLAY_SOUND = item("play-sound", true); - public static final ConfigurationItem<UHSound> SOUND = item("sound", new UHSound("WITHER_SPAWN")); + public static final ConfigurationItem<UHSound> SOUND = item("sound", new UHSound("ENTITY_WITHER_SPAWN")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java index 81e64f3..324d5e2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java @@ -151,7 +151,7 @@ static public List<Material> defaultPickedUpHighlight() ); } - static public enum ReportBroadcastedTo + public enum ReportBroadcastedTo { ALL, ADMINISTRATORS, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java index b554d25..a10882c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java @@ -54,8 +54,8 @@ public Config(File file) static public class DisplaySection extends ConfigurationSection { - public final ConfigurationItem<Boolean> ON_JOIN = item("onJoin", false); - public final ConfigurationItem<Boolean> ON_START = item("onStart", true); + public final ConfigurationItem<Boolean> ON_JOIN = item("on-join", false); + public final ConfigurationItem<Boolean> ON_START = item("on-start", true); } public static final ConfigurationList<String> RULES = list("rules", String.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java index 58e3061..841c7cf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.utils; +import fr.zcraft.zlib.components.configuration.ConfigurationParseException; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; import org.apache.commons.lang3.Validate; @@ -42,6 +43,8 @@ import org.bukkit.entity.Player; import java.util.Arrays; +import java.util.Collection; +import java.util.Map; import java.util.Objects; @@ -333,11 +336,44 @@ public static Sound string2Sound(String soundName) } @ConfigurationValueHandler - public static Sound handleSoundValue(Object object) + public static Sound handleSoundValue(final Object object) { return string2Sound(object.toString()); } + @ConfigurationValueHandler + public static UHSound handleUHSoundValue(final Map<String, Object> section) throws ConfigurationParseException + { + if (!section.containsKey("name")) + throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); + + final float volume = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("volume", 1f)); + final float pitch = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("pitch", 1f)); + + final Object names = section.get("name"); + + if (names == null) + { + throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); + } + else if (names instanceof Collection) + { + final String[] soundNames = new String[((Collection) names).size()]; + + int i = 0; + for (final Object name : (Collection) names) + { + soundNames[i++] = name.toString(); + } + + return new UHSound(volume, pitch, soundNames); + } + else + { + return new UHSound(names.toString(), volume, pitch); + } + } + static { ConfigurationValueHandlers.registerHandlers(UHSound.class); } diff --git a/src/main/resources/modules-config/other/reports.yml b/src/main/resources/modules-config/other/reports.yml deleted file mode 100644 index 8b6a038..0000000 --- a/src/main/resources/modules-config/other/reports.yml +++ /dev/null @@ -1,53 +0,0 @@ - -# The reports API base website URL. If empty, defaults to the instance -# managed by DamagesLogger's authors. -# Change this if you want to use your own instance. -reports-api-base-url: "" - -# If false, the report will not be published at the end of the game. -# It will still be saved in the plugin directory (under plugins/UHPlugin/reports). -publish-report: true - -# If published, the URL can be automatically broadcasted to: -# - ALL: all players in the server (plus the console); -# - ADMINISTRATORS: only administrators (currently operators) -# - CONSOLE: only the console (absolutely nothing in-game). -broadcast-report-to: ALL - - -# The settings below configure the reports web page. -# Empty lists implies sensible default values. -# TODO add documentation for each. - -date: true -players-count: true -winners: true - -summary: - enabled: true - history: true - players: true - teams: true - -damages: - enabled: true - damages-per-players: true - damages-per-teams: true - damages-from-environment: true - display-killer: true - -players: - enabled: true - play-time: true - global-statistics: true - statistics-whitelist: [] - statistics-highlight: [] - used: false - used-whitelist: [] - used-highlight: [] - mined: true - mined-whitelist: [] - mined-highlight: [] - picked-up: true - picked-up-whitelist: [] - picked-up-highlight: [] diff --git a/src/main/resources/modules/core-border.yml b/src/main/resources/modules/core-border.yml new file mode 100644 index 0000000..12516b2 --- /dev/null +++ b/src/main/resources/modules/core-border.yml @@ -0,0 +1,52 @@ +# The diameter of the map (not the radius!), in blocks +size: 2000 + +# "squared" or "circular". Affects the WorldBorder pre-configuration, and the +# wall generator used. +shape: "squared" + +# The world border manager. Can be: +# - "vanilla", to use the vanilla world border; or +# - "brettflan", to use the WorldBorder Bukkit plugin by Brettflan +# (http://dev.bukkit.org/bukkit-plugins/worldborder/). +# +# If the shape is "circular", fallbacks to "brettflan" as the vanilla world border don't +# support circular borders. And if the WorldBorder plugin is not installed, fallbacks to +# no border. +motor: "vanilla" + +# The amount of blocks a player may safely be outside the border before taking damage. +# Only for the vanilla world border. Ignored else. +damages-buffer: 5 + +# The amount of damage a player takes when outside the border plus the border buffer. +# The damages delt is calculated by multiplying this amount by the number of blocks behind the buffer. +# Only for the vanilla world border. Ignored else. +damages-amount: 0.2 + +# The warning distance that causes the screen to be tinted red when the player is within the specified +# number of blocks from the border. +# Only for the vanilla world border. Ignored else. +warning-distance: 5 + + +# Automatic and progressive border shrinking. +# Notice: if the border is circular, the WorldBorder Bukkit plugin by Brettflan (see above) +# is REQUIRED. Without, the border shrinking will not work. +shrinking: + enabled: false + + # Formats: "mm", "mm:ss" or "hh:mm:ss". + # With the default values, the border eats one block every 8 seconds on each side. + starts-after: "1:30:00" + shrinks-during: "2:00:00" + diameter-after-shrink: 200 + + +# Do you want the border current size to be displayed into the sidebar? +sidebar: + displayed: true + + # If true, displays the border diameter (ex. "2000 blocks wide"). Else, the min/max + # coordinates (ex. "-1000 +1000"). Ignored if the border is circular. + display-diameter: false diff --git a/src/main/resources/modules/core-game.yml b/src/main/resources/modules/core-game.yml new file mode 100644 index 0000000..7929592 --- /dev/null +++ b/src/main/resources/modules/core-game.yml @@ -0,0 +1,44 @@ +# The duration of the countdown before the game (seconds). +countdown: 7 + +# Displays a title when the game starts. +startup-title: true + +# If true, in solo games, all players will be colored randomly. +# Else everyone will be white. +random-colors-in-solo-games: true + +# If true, the initial teleportation progress will be broadcasted +# in the players' action bars, so they don't wait in the dark. +broadcast-progress: true + + +# The slow start allow the game to teleports the players slowly, for +# smaller servers, to avoid too many chunks loaded at once. You can +# enable the slow mode by using /uh start --slow, or using the GUI: +# as an operator, right-click the redstone comparator, then “Start the +# game”, then “Slow Start”. +slow: + # The delay, in seconds, between two teleportations in slow mode. + delay-between-teleportations: 3 + + +beginning: + # During this period, all damages will be disabled. + grace-period: "00:01:00" + + # Broadcast the end of the grace period + broadcast-grace-end: true + + # During this period, the PVP will be disabled. + peace-period: "00:15:00" + + # During this period, there will not be any hostile creature at the surface. + # They will still be there in caves. + surface-mobs-free-period: "00:20:00" + + +# Displays the players' count and teams' count in the sidebar. +sidebar: + players: true + teams: true diff --git a/src/main/resources/modules/core-spawns.yml b/src/main/resources/modules/core-spawns.yml new file mode 100644 index 0000000..a64b748 --- /dev/null +++ b/src/main/resources/modules/core-spawns.yml @@ -0,0 +1,15 @@ +# Don't generate the spawn points (with /uh spawns generate) above the water? +avoid-water: true + +# Use this to set the spawn points of the teams (or the players) +# You can also use the command `/uh spawns add` to add temporary spawn points, +# and `/uh spawns generate` to automatically generate them. (See `/uh spawns` for documentation.) +# (The spawn points added through `/uh spawns` are deleted when the server is stopped.) +# +# Format: +# - x,z +# - x,z +# - etc. + +spawn-points: + - diff --git a/src/main/resources/modules/core-spectators.yml b/src/main/resources/modules/core-spectators.yml new file mode 100644 index 0000000..8f4302b --- /dev/null +++ b/src/main/resources/modules/core-spectators.yml @@ -0,0 +1,11 @@ +# Allows registered spectators to re-join the game. +# This includes dead players and spectators manually registered with /uh spectators add. +spectators-can-join: true + +# Allows unregistered spectators to join the game (as spectator only). +unknown-spectators-can-join: true + +# If the previous option is set to false and this one to true, the first time +# an unknown spectator try to join the server, all administrators will be notified +# with a link to allow the spectator to join. The notification will only be sent once. +notify-on-unknown-spectators-trying-to-join: true diff --git a/src/main/resources/modules/core-teams.yml b/src/main/resources/modules/core-teams.yml new file mode 100644 index 0000000..ecd1463 --- /dev/null +++ b/src/main/resources/modules/core-teams.yml @@ -0,0 +1,82 @@ +can-see-friendly-invisibles: true +allow-friendly-fire: true + +# 0 = unlimited. +max-players-per-team: 0 + +# True to have players name in the team's color in the chat. +# No cat will be altered if this option is enabled. +colorize-chat: true + + +# These options are related to the auto-generated banner of each team. +# This banner is used on the teams selector (if set to "banner"), and can be given to the +# players when the game starts. +banner: + shape: + write-letter: true + add-border: true + + give: + place-on-spawn: true # Places the team banner on the spawn point. + give-in-hotbar: false # Gives a banner to each player. + give-on-head: false # Places the banner on the head of each player. + + shields: + add-on-shields: true # Crafted shields will have the team banner on them. MC 1.9+ only. + + +# Chest-based GUI to choose a team and manage the teams +gui: + display: + team-item: "banner" # Values: "banner", "glass", "glass_pane", "clay", "wool", "dye" + glow-on-selected-team: true # Set to true to display an enchantment glow on the player team. + # Note that the glow effect will not be applied with banners. + +team-chat: + # Forces disable the team-chat when the player die. + # If you use SpectatorPlus with the block-commands option enabled, this will prevent spectators + # from using the team chat. + disable-lock-on-death: true + + # Log the private team-chat in the console? + log: false + + +# The sidebar can display the player's team. +sidebar: + # Displays the player's team in the scoreboard + enabled: true + + title: + # The color of the title. If empty, the team color is used. + color: "" + + # If true, the title is the team's name. Else, a generic title (« Your team »). + use-team-name: false + + content: + # Displays hearts colored following the player's life (low = red, high = green) + display-hearts: true + + # Color the whole name, not only the heart, following the life. If disabled, + # the name is white (alive) or gray (dead). + color-name: false + + # Strike the dead players lines. + strike-dead-players: false + + login-state: + # Logged-out players are displayed in italic + italic: true + + # This string is displayed after the name of logged-out players + suffix: "\u27A5" + + display-met-players-only: + # If enabled, the sidebar will only contains players met at some time. + enabled: false + + # If enabled, a teammate will be displayed to the reference player if he/she + # is closer that this amount of blocks to the player. + displayed-when-closer-than: 10 diff --git a/src/main/resources/modules/cosmetics-episodes.yml b/src/main/resources/modules/cosmetics-episodes.yml new file mode 100644 index 0000000..8affd18 --- /dev/null +++ b/src/main/resources/modules/cosmetics-episodes.yml @@ -0,0 +1,9 @@ +# Format: "mm", "mm:ss" or "hh:mm:ss". If invalid, 20 minutes. +# Don't remove the "quotes" (because of the commas)! +length: "20:00" + +# A title is displayed when the episode changes. +display-title: true + +# The current episode is displayed into the sidebar. +display-in-sidebar: true diff --git a/src/main/resources/modules/cosmetics-hardcore-hearts.yml b/src/main/resources/modules/cosmetics-hardcore-hearts.yml new file mode 100644 index 0000000..7f6763f --- /dev/null +++ b/src/main/resources/modules/cosmetics-hardcore-hearts.yml @@ -0,0 +1,12 @@ +# Display hardcore hearts instead of normal ones? +hardcore-hearts: true + +# If a player die, with old Minecraft versions, his client will display an hardcore Game Over screen, +# without a « Respawn » button. But the player CAN respawn, by clicking « Leave server » and then, +# on the confirmation screen, « Respawn ». +# This option can automatically respawn the player after its death. +# Recent versions of Minecraft do have a « Spectate » button in the Game Over screen, but you can still +# enable the auto-respawn for them. +auto-respawn: + do: true + delay: 6 # seconds diff --git a/src/main/resources/modules/cosmetics-player-list-header-footer.yml b/src/main/resources/modules/cosmetics-player-list-header-footer.yml new file mode 100644 index 0000000..d1d7410 --- /dev/null +++ b/src/main/resources/modules/cosmetics-player-list-header-footer.yml @@ -0,0 +1,33 @@ +# You can here fill the header and footer of the player's list (opened with TAB by default) +# with custom strings. You can include chat color codes (with either § or &) and special +# placeholders that will be replaced by special values. +# +# You can use `\n` to split the text over multiple lines. +# +# By default, the following placeholders are available: +# +# {title} -> title of the game +# {playersText} -> the string « x players », where x is the number of players alive +# {playersCount} -> the number of alive players +# {teamsText} -> the string « x teams », where x is the number of teams alive +# {teamsCount} -> the number of alive teams +# +# If the episodes module is loaded, the following are also available: +# +# {episodeText} -> the string « Episode x », where x is the current episode number +# {episodeNumber} -> The current episode's number. +# +# Any module can add their own placeholders (including you owns). Use /uh list-hf-placeholders +# to get a list of all available placeholders for your modules. + +headers: + WAIT: "{title}" + STARTING: "{title}" + IN_GAME: "{title}" + END: "{title}" + +footers: + WAIT: "§2Be patient, the game will start soon..." + STARTING: "§2The game is starting!" + IN_GAME: "§2{playersText} §7- §2{teamsText}" + END: "§2§lGame Over!" diff --git a/src/main/resources/modules/end-death-announcement.yml b/src/main/resources/modules/end-death-announcement.yml new file mode 100644 index 0000000..186bbcd --- /dev/null +++ b/src/main/resources/modules/end-death-announcement.yml @@ -0,0 +1,20 @@ +# Broadcasts a message if a team has fallen. +notify-if-team-has-fallen: true + +# Use this to increase visibility of death messages. +eath-messages-format: "§6" +team-death-messages-format: "§6" + +# Sends a lightning strike effect on the death point +lightning-strike: false + +# Broadcasts a sound to the whole server. +play-sound: true + +# The sound to broadcast. +sound: + name: + - ENTITY_WITHER_SPAWN + - WITHER_SPAWN + volume: 1 + pitch: 1 diff --git a/src/main/resources/modules/end-kick.yml b/src/main/resources/modules/end-kick.yml new file mode 100644 index 0000000..a8f8dc6 --- /dev/null +++ b/src/main/resources/modules/end-kick.yml @@ -0,0 +1,5 @@ +# Kick the player after this delay. +delay: "00:30" + +# Kick the player with this message. +message: "jayjay" diff --git a/src/main/resources/modules/end-xp-to-killers.yml b/src/main/resources/modules/end-xp-to-killers.yml new file mode 100644 index 0000000..21bb1dd --- /dev/null +++ b/src/main/resources/modules/end-xp-to-killers.yml @@ -0,0 +1,5 @@ +# Give this amount of XP levels when a player kills another player. +levels: 2 + +# Only when a player kills a player from another team. +only-other-team: true diff --git a/src/main/resources/modules/external-dynmap.yml b/src/main/resources/modules/external-dynmap.yml new file mode 100644 index 0000000..58bed31 --- /dev/null +++ b/src/main/resources/modules/external-dynmap.yml @@ -0,0 +1,5 @@ +# Displays the players' spawns in the dynmap. +show-spawn-locations: true + +# Displays the players' death locations in the dynmap. +show-death-locations: true diff --git a/src/main/resources/modules/external-motd.yml b/src/main/resources/modules/external-motd.yml new file mode 100644 index 0000000..d085bf8 --- /dev/null +++ b/src/main/resources/modules/external-motd.yml @@ -0,0 +1,5 @@ +# Display the match name in the MOTD +display-match-name: true + +# This will be displayed before the match name (formatting...) +match-name-prefix: "" diff --git a/src/main/resources/modules/external-reports.yml b/src/main/resources/modules/external-reports.yml new file mode 100644 index 0000000..aec07e6 --- /dev/null +++ b/src/main/resources/modules/external-reports.yml @@ -0,0 +1,102 @@ + +# The Hawk reports API base website URL. If empty, defaults +# to the Hawk instance managed by DamagesLogger's authors. +# Change this if you want to use your own instance. +reports-api-base-url: "" + +# If false, the report will not be published at the end of the game. +# It will still be saved in the plugin directory (under plugins/UHPlugin/reports). +publish-report: true + +# If published, the URL can be automatically broadcasted to: +# - ALL: all players in the server (plus the console); +# - ADMINISTRATORS: only administrators (currently operators) +# - CONSOLE: only the console (absolutely nothing in-game). +broadcast-report-to: ALL + + +# The settings below configure the Hawk reports web page. +# TODO add documentation for each. + +date: true +players-count: true +winners: true + +summary: + enabled: true + history: true + players: true + teams: true + +damages: + enabled: true + damages-per-players: true + damages-per-teams: true + damages-from-environment: true + display-killer: true + +players: + enabled: true + play-time: true + + global-statistics: true + statistics-whitelist: [] + statistics-highlight: + - DAMAGE_DEALT + - CRAFT_ITEM + - ITEM_ENCHANTED + - BREWINGSTAND_INTERACTION + - SPRINT_ONE_CM + + used: false + used-whitelist: [] + used-highlight: + - DIAMOND_SWORD + - DIAMOND_AXE + - DIAMOND_PICKAXE + - DIAMOND_HOE + - IRON_SWORD + - IRON_AXE + - IRON_PICKAXE + - IRON_HOE + - CAKE + - SADDLE + - GOLDEN_APPLE + - POTION + - GOLD_RECORD + - GREEN_RECORD + - RECORD_3 + - RECORD_4 + - RECORD_5 + - RECORD_6 + - RECORD_7 + - RECORD_8 + - RECORD_9 + - RECORD_10 + - RECORD_11 + - RECORD_12 + + mined: true + mined-whitelist: [] + mined-highlight: + - DIAMOND + - DIAMOND_ORE + - GOLD_INGOT + - GOLD_ORE + - IRON_INGOT + - IRON_ORE + - EMERALD + - EMERALD_ORE + - OBSIDIAN + - NETHER_WARTS + - MOB_SPAWNER + - STONE + + picked-up: true + picked-up-whitelist: [] + picked-up-highlight: + - APPLE + - BOW + - ENDER_PEARL + - GOLD_INGOT + - SKULL_ITEM diff --git a/src/main/resources/modules/gameplay-compass.yml b/src/main/resources/modules/gameplay-compass.yml new file mode 100644 index 0000000..dbfc1d9 --- /dev/null +++ b/src/main/resources/modules/gameplay-compass.yml @@ -0,0 +1,25 @@ +# The special recipe is with an ingredient in the center, and then, +# from the top, clockwise: iron, spider eye, iron, rotten flesh, iron, bone, iron, gunpowder. +# This field change the central ingredient. +# "easy": redstone (like the normal compass). +# "medium": ender pearl. +# "hard": eye of ender. +recipe: "medium" + +# This item will be required to be able to use the compass, and for each use +# of it. +compass-fee-item: ROTTEN_FLESH + +# This amount of the previous item will be required and consumed for each +# use of the compass. +compass-fee-amount: 1 + +# If true, the compass will only target players from other teams. +never-target-teammates: true + +# The behavior of the compass. +# GIVE_DIRECTION: gives the target's direction by updating the compass. +# GIVE_DISTANCE: Gives the target's distance from the player. +# GIVE_BOTH: gives both the direction and the distance. +# GIVE_EITHER_RANDOMLY: gives either the direction or the distance, randomly, with a small chance of getting both. +compass-behavior: GIVE_DIRECTION diff --git a/src/main/resources/modules/gameplay-daylight-cycle.yml b/src/main/resources/modules/gameplay-daylight-cycle.yml new file mode 100644 index 0000000..f8b0ba2 --- /dev/null +++ b/src/main/resources/modules/gameplay-daylight-cycle.yml @@ -0,0 +1,15 @@ +# If false, the time will be frozen. +enable-daylight-cycle: true + +# The duration of one Minecraft day, in real life minutes. The default duration is +# 20 minutes, but you can change this to any value longer or shorter, down to the +# second if you like to see the sun navigating the sky reaaaallly fast. +daylight-cycle-duration: "00:20:00" + +# The hour of the waiting phase, in ticks. +# For the record, 0 = sun rise, 6000 = midday, 12 000 = sun set, 18 000 = midnight. +waiting-phase-hour: 6000 + +# The hour when the game starts. If the daylight cycle is disabled, this will be the +# hour of the whole game. +initial-game-hour: 0 diff --git a/src/main/resources/modules/gameplay-golden-heads.yml b/src/main/resources/modules/gameplay-golden-heads.yml new file mode 100644 index 0000000..fd20b1c --- /dev/null +++ b/src/main/resources/modules/gameplay-golden-heads.yml @@ -0,0 +1,73 @@ +# Will players drop their head on death? +drop-head-on-death: true + +# Maybe ony in PvP? +drop-head-on-death-pvp-only: false + +# Below, you'll be able to tweak the amount of half-hearts +# apples regenerate. Should we display this amount, if +# different from vanilla, in the apples' tooltips? +display-regen-amount-on-apples: true + + +# Golden apple settings. +# If disabled, the craft will be impossible. +# The regeneration is in half-hearts. +golden-apple: + enable: true + regeneration: 4 + +# Enchanted golden apple settings (a.k.a. “Notch Apple”). +# If disabled, the craft will be impossible. +# If enabled, the old craft with gold blocks will be registered. +# The regeneration is in half-hearts. +enchanted-golden-apple: + enable: false + regeneration: 180 + + +# Player “golden head”, made with a player head and eight gold ingots. +# You can change the amount of golden heads crafted from one head +# and eight ingots, and add or not a RP lore to the item. +# The regeneration is in half-hearts. +player-golden-apple: + enable: true + regeneration: 4 + amount-crafted: 1 + add-lore: true + + +# Wither “golden head”, made with a Wither Skeleton head and eight +# gold ingots. +# You can change the amount of golden heads crafted from one head +# and eight ingots, and add or not a RP lore to the item. +# The regeneration is in half-hearts. +wither-golden-apple: + enable: true + regeneration: 4 + amount-crafted: 1 + add-lore: true + + +# Player “enchanted golden head”, made with a player head and eight +# gold blocks. +# You can change the amount of golden heads crafted from one head +# and eight blocks, and add or not a RP lore to the item. +# The regeneration is in half-hearts. +player-enchanted-golden-apple: + enable: false + regeneration: 180 + amount-crafted: 1 + add-lore: true + + +# Player “enchanted golden head”, made with a Wither Skeleton head +# and eight gold blocks. +# You can change the amount of golden heads crafted from one head +# and eight blocks, and add or not a RP lore to the item. +# The regeneration is in half-hearts. +wither-enchanted-golden-apple: + enable: false + regeneration: 180 + amount-crafted: 1 + add-lore: true diff --git a/src/main/resources/modules/gameplay-hardcore.yml b/src/main/resources/modules/gameplay-hardcore.yml new file mode 100644 index 0000000..b951834 --- /dev/null +++ b/src/main/resources/modules/gameplay-hardcore.yml @@ -0,0 +1,6 @@ +# If false, the natural regeneration will be disabled in playing worlds. +natural-regeneration: false + +# The difficulty of the game worlds. +# Either PEACEFUL, EASY, NORMAL or HARD. +difficulty: HARD diff --git a/src/main/resources/modules/gameplay-killer-rabbit.yml b/src/main/resources/modules/gameplay-killer-rabbit.yml new file mode 100644 index 0000000..b092617 --- /dev/null +++ b/src/main/resources/modules/gameplay-killer-rabbit.yml @@ -0,0 +1,8 @@ +# When a rabbit spawn, it'll have this probability of becoming a Killer Rabbit. +# If 0, no killer rabbit will spawn (but you can also disable the module for the same +# effect). +spawn-probability: 0.05 + +# The Killer Rabbit's name. You can use color codes with § in this. +# If empty, the rabbit won't have any special name (we'll rely on Minecraft default). +name: "The Killer Rabbit of Cærbannog" diff --git a/src/main/resources/modules/gameplay-no-witches.yml b/src/main/resources/modules/gameplay-no-witches.yml new file mode 100644 index 0000000..6e8e67e --- /dev/null +++ b/src/main/resources/modules/gameplay-no-witches.yml @@ -0,0 +1,5 @@ +# Disables Witches' natural spawn (e.g. in caves/dark, or in their huts). +disable-natural-spawn: true + +# Disables Witches' lightning spawn (villagers hit by a lightning bolt will not turn into a witch). +disable-lightning-spawn: true diff --git a/src/main/resources/modules/gameplay-potions.yml b/src/main/resources/modules/gameplay-potions.yml new file mode 100644 index 0000000..e2685af --- /dev/null +++ b/src/main/resources/modules/gameplay-potions.yml @@ -0,0 +1,11 @@ +# Potions won't be able to be increased to the second level. +disable-level-II: true + +# Potions won't be able to be extended in time. +disable-extended: false + +# Players won't be able to make splashes potions. +disable-splash: false + +# Players won't be able to make lingering potions. +disable-lingering: false diff --git a/src/main/resources/modules/gameplay-weather.yml b/src/main/resources/modules/gameplay-weather.yml new file mode 100644 index 0000000..be87507 --- /dev/null +++ b/src/main/resources/modules/gameplay-weather.yml @@ -0,0 +1,11 @@ +# If true, the weather will randomly change during the game. +enable-weather-cycle: true + +# The weather when the game starts. If the weather cycle is disabled, +# this will also be the weather during the whole game. +# Can be CLEAR or DOWNFALL. +initial-weather: CLEAR + +# The weather during the initial waiting phase. +# Can be CLEAR or DOWNFALL. +waiting-phase-weather: CLEAR diff --git a/src/main/resources/modules/scenarii-alliances.yml b/src/main/resources/modules/scenarii-alliances.yml new file mode 100644 index 0000000..27bd3dd --- /dev/null +++ b/src/main/resources/modules/scenarii-alliances.yml @@ -0,0 +1,12 @@ +# The number of alliances each player is allowed to enter. +# To be allowed to enter an alliance, a player must have its +# alliance counter strictly positive. If he/she enters the alliance, +# the amount of players minus one will be subtracted from its counter. +alliances-per-player: 2 + +# The maximal size of an alliance. Similar to teams' max size. +max-players-per-alliance: 3 + +# Players will only be allowed to send an alliance request (using /a) if they +# are at less than this amount of blocks from each other. +max-distance-to-create-an-alliance: 60 diff --git a/src/main/resources/modules/starting-cages.yml b/src/main/resources/modules/starting-cages.yml new file mode 100644 index 0000000..4447a8b --- /dev/null +++ b/src/main/resources/modules/starting-cages.yml @@ -0,0 +1,25 @@ +# The cage type. Can be: +# - team_color_transparent (stained glass using the team color, or white without color/for solo); +# - team_color_solid (the same with stained hardened clay); +# - custom (a custom block, configure the one to use after). +type: TEAM_COLOR_TRANSPARENT + +# If you selected “custom” before, write here the block you want to use. It can be any valid Material. +# You can use safely any falling block here, they will never fall. +custom-block: + +# If true, the cages will be built completely, including the ceiling. Else, they will be open to the sky. +build-ceiling: false + +# If true, the walls will be built using the block above. Else, using barrier blocks. +visible-walls: true + +# The internal square radius of the cage. +# With 0, you'll have a cage with one block to walk. +# With 1, you'll have a 3×3 cage. +# With 2, a 5×5 cage. Etc. +radius: 2 + +# The internal height of the cages, i.e. the height of the space available to the players inside the cage. +# It is kinda useless to set a too high height here, as players won't be able to fly. +height: 3 diff --git a/src/main/resources/modules/utilities-rules.yml b/src/main/resources/modules/utilities-rules.yml new file mode 100644 index 0000000..6237703 --- /dev/null +++ b/src/main/resources/modules/utilities-rules.yml @@ -0,0 +1,17 @@ +# You can send the rules automatically. +# Remainder: you can also send the rules manually using /uh rules [player]. +display: + # Automatically displays the rules to players when they join the game (and it is not started). + on-join: false + + # Automatically broadcasts the rules when the game starts. + on-start: true + +# Rules are a way to display rules & other infos to the players. +# The content is completely up to you, formatting included (using standard +# formatting codes with either § or &). It will be displayed as a list to +# the players (one bullet per line in the following list). +# Empty entries (« - "" ») are replaced by a completely blank line, if you +# need a separator. +rules: + - diff --git a/src/main/resources/modules/utilities-walls.yml b/src/main/resources/modules/utilities-walls.yml new file mode 100644 index 0000000..192fc7b --- /dev/null +++ b/src/main/resources/modules/utilities-walls.yml @@ -0,0 +1,8 @@ +# The height of the wall generated using /uh build-wall, in blocks, counted from the bottom of the world. +height: 128 + +block: + # The replace-air block will be placed where there where some transparent blocks or trees before. + # The replace-solid one, where there was another kind of block. + replace-air: GLASS + replace-solid: BEDROCK diff --git a/src/main/resources/modules/utilities-warning.yml b/src/main/resources/modules/utilities-warning.yml new file mode 100644 index 0000000..c727791 --- /dev/null +++ b/src/main/resources/modules/utilities-warning.yml @@ -0,0 +1,3 @@ +# The delay between two warning messages sent to the players out of a future border +# (this warning is set using /uh border-warning <futureDiameter>). +warning-interval: "00:01:30" diff --git a/src/main/resources/modules/waiting-phase-wait.yml b/src/main/resources/modules/waiting-phase-wait.yml new file mode 100644 index 0000000..ce458b2 --- /dev/null +++ b/src/main/resources/modules/waiting-phase-wait.yml @@ -0,0 +1,39 @@ +# Teleport the players to the spawn point on login if the game is not started? +# Avoids the random spawn point of Minecraft, and teleports them back to +# there if they log out then in. +teleport-to-spawn-if-not-started: true + +inventory: + # True to clear the inventory of the players before the beginning of the game. + clear: true + + # True to prevent users from using their inventory when the game is not started. + prevent-usage: true + + # True to disable all the inventory points above for players with the uh.build permission. + allow-for-builders: true + + +teams-selector: + # True to give to the players a team selector, opening the teams inventory GUI (same as /teams). + enabled: true + + # The item to use as the team selector. Right-clicking it will open the GUI. + item: NETHER_STAR + + +config-accessor: + # True to give to the players with enough permissions a config accessor, opening the + # /config GUI. + enabled: true + + # The item to use as the config accessor. Right-clicking it will open the GUI. + item: REDSTONE_COMPARATOR + +# Displays the current team in the action bar before the game. Nothing is displayed if the player is +# not in a team. +team-in-action-bar: true + +# If set to true, players will be able to PVP while waiting. They will respawn in the world's +# spawn point every time. +enable-pvp: false From 76225fbd7c7b12a9c503c4925960dbf4b4630dc5 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 21 Jan 2019 01:59:50 +0100 Subject: [PATCH 61/91] Modules packages reorganization. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Made one package for each category, to share the classes & modules hierarchy. --- .../amaury/UHCReloaded/core/ModulesManager.java | 4 ++-- .../modules/core/modules/gui/MainConfigGUI.java | 4 ++-- .../modules/{ingame => cosmetics}/episodes/Config.java | 2 +- .../{ingame => cosmetics}/episodes/EpisodesModule.java | 8 ++++---- .../episodes/commands/ShiftCommand.java | 4 ++-- .../episodes/events/EpisodeChangedEvent.java | 2 +- .../killsCount/KillsCountModule.java | 2 +- .../listHealth/ListHealthModule.java | 2 +- .../{ingame => end}/deathAnnouncement/Config.java | 2 +- .../deathAnnouncement/DeathAnnouncementModule.java | 2 +- .../modules/{ingame => end}/kick/Config.java | 2 +- .../modules/{ingame => end}/kick/KickModule.java | 2 +- .../modules/{ingame => end}/xpToKillers/Config.java | 2 +- .../{ingame => end}/xpToKillers/XpToKillersModule.java | 2 +- .../modules/{cosmetics => external}/dynmap/Config.java | 2 +- .../{cosmetics => external}/dynmap/DynmapModule.java | 2 +- .../modules/{cosmetics => external}/motd/Config.java | 2 +- .../{cosmetics => external}/motd/MotdModule.java | 2 +- .../modules/{other => external}/reports/Config.java | 2 +- .../{other => external}/reports/ReportsModule.java | 2 +- .../{ingame => gameplay}/daylightCycle/Config.java | 2 +- .../daylightCycle/DaylightCycleModule.java | 2 +- .../modules/{ingame => gameplay}/hardcore/Config.java | 2 +- .../{ingame => gameplay}/hardcore/HardcoreModule.java | 2 +- .../modules/{ingame => gameplay}/weather/Config.java | 2 +- .../{ingame => gameplay}/weather/WeatherModule.java | 2 +- .../modules/{ingame => other}/AdvancementsModule.java | 2 +- .../modules/other/{pomf => }/PomfModule.java | 6 +++--- .../modules/{ingame => other}/StatisticsModule.java | 2 +- .../modules/{beginning => starting}/cages/Cage.java | 2 +- .../{beginning => starting}/cages/CagesModule.java | 2 +- .../modules/{beginning => starting}/cages/Config.java | 2 +- .../{border => utilities}/check/CheckCommand.java | 2 +- .../{border => utilities}/check/CheckModule.java | 2 +- .../modules/{ingame => utilities}/food/FoodModule.java | 6 +++--- .../food/commands/FeedAllCommand.java | 2 +- .../food/commands/FeedCommand.java | 2 +- .../{ingame => utilities}/freezer/FreezeCommand.java | 2 +- .../{ingame => utilities}/freezer/FreezerListener.java | 2 +- .../{ingame => utilities}/freezer/FreezerModule.java | 2 +- .../{ingame => utilities}/health/HealthModule.java | 6 +++--- .../health/commands/HealAllCommand.java | 2 +- .../health/commands/HealCommand.java | 2 +- .../playersLoader/LoadPlayersCommand.java | 2 +- .../playersLoader/PlayersLoaderModule.java | 2 +- .../modules/{other => utilities}/rules/Config.java | 2 +- .../{other => utilities}/rules/RulesCommand.java | 2 +- .../{other => utilities}/rules/RulesModule.java | 2 +- .../teleportation/TeleportationModule.java | 10 +++++----- .../teleportation/commands/TPDeathCommand.java | 4 ++-- .../teleportation/commands/TPSpawnCommand.java | 2 +- .../teleportation/commands/TPSpectatorsCommand.java | 2 +- .../teleportation/commands/TPTeamCommand.java | 2 +- .../teleportation/commands/WorldBasedCommand.java | 2 +- .../modules/{border => utilities}/walls/Config.java | 2 +- .../{border => utilities}/walls/WallsCommand.java | 4 ++-- .../{border => utilities}/walls/WallsModule.java | 10 +++++----- .../walls/exceptions/CannotGenerateWallsException.java | 2 +- .../walls/exceptions/UnknownWallGenerator.java | 2 +- .../walls/generators/CircularWallGenerator.java | 2 +- .../walls/generators/SquaredWallGenerator.java | 2 +- .../walls/generators/WallGenerator.java | 2 +- .../walls/generators/WallPosition.java | 2 +- .../warning/BorderWarningTask.java | 2 +- .../modules/{border => utilities}/warning/Config.java | 2 +- .../{border => utilities}/warning/WarningCommand.java | 2 +- .../{border => utilities}/warning/WarningModule.java | 2 +- .../{beginning => waitingPhase}/wait/Config.java | 2 +- .../{beginning => waitingPhase}/wait/WaitModule.java | 2 +- 69 files changed, 91 insertions(+), 91 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/episodes/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/episodes/EpisodesModule.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/episodes/commands/ShiftCommand.java (94%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/episodes/events/EpisodeChangedEvent.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/killsCount/KillsCountModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => cosmetics}/listHealth/ListHealthModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/deathAnnouncement/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/deathAnnouncement/DeathAnnouncementModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/kick/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/kick/KickModule.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/xpToKillers/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => end}/xpToKillers/XpToKillersModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{cosmetics => external}/dynmap/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{cosmetics => external}/dynmap/DynmapModule.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{cosmetics => external}/motd/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{cosmetics => external}/motd/MotdModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => external}/reports/Config.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => external}/reports/ReportsModule.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/daylightCycle/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/daylightCycle/DaylightCycleModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/hardcore/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/hardcore/HardcoreModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/weather/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => gameplay}/weather/WeatherModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => other}/AdvancementsModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/{pomf => }/PomfModule.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => other}/StatisticsModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{beginning => starting}/cages/Cage.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{beginning => starting}/cages/CagesModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{beginning => starting}/cages/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/check/CheckCommand.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/check/CheckModule.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/food/FoodModule.java (92%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/food/commands/FeedAllCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/food/commands/FeedCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/freezer/FreezeCommand.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/freezer/FreezerListener.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/freezer/FreezerModule.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/health/HealthModule.java (91%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/health/commands/HealAllCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/health/commands/HealCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => utilities}/playersLoader/LoadPlayersCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => utilities}/playersLoader/PlayersLoaderModule.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => utilities}/rules/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => utilities}/rules/RulesCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{other => utilities}/rules/RulesModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/TeleportationModule.java (88%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/commands/TPDeathCommand.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/commands/TPSpawnCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/commands/TPSpectatorsCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/commands/TPTeamCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{ingame => utilities}/teleportation/commands/WorldBasedCommand.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/WallsCommand.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/WallsModule.java (90%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/exceptions/CannotGenerateWallsException.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/exceptions/UnknownWallGenerator.java (95%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/generators/CircularWallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/generators/SquaredWallGenerator.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/generators/WallGenerator.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/walls/generators/WallPosition.java (96%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/warning/BorderWarningTask.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/warning/Config.java (97%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/warning/WarningCommand.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{border => utilities}/warning/WarningModule.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{beginning => waitingPhase}/wait/Config.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/{beginning => waitingPhase}/wait/WaitModule.java (99%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index 734c960..a8dce46 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -37,8 +37,8 @@ import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; -import eu.carrade.amaury.UHCReloaded.modules.ingame.kick.KickModule; -import eu.carrade.amaury.UHCReloaded.modules.other.pomf.PomfModule; +import eu.carrade.amaury.UHCReloaded.modules.end.kick.KickModule; +import eu.carrade.amaury.UHCReloaded.modules.other.PomfModule; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java index 3e064db..bd4db7a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java @@ -35,8 +35,8 @@ import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import eu.carrade.amaury.UHCReloaded.modules.beginning.wait.Config; -import eu.carrade.amaury.UHCReloaded.modules.beginning.wait.WaitModule; +import eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait.Config; +import eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait.WaitModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules.ModulesListGUI; import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start.StartGameGUI; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java index 0147757..83bae4e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java index 861dfb0..8684ca3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; @@ -45,9 +45,9 @@ import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.commands.ShiftCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.commands.ShiftCommand; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.i18n.I; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java index 17cfe33..d8cf537 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/commands/ShiftCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java @@ -31,11 +31,11 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.commands; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.commands; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.EpisodesModule; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.EpisodesModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java index 8c5ed40..0d192b4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/episodes/events/EpisodeChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events; import org.bukkit.command.CommandSender; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java index a87c39c..41af6d7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/killsCount/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.killsCount; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.killsCount; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java index f582077..498798a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/listHealth/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.listHealth; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics.listHealth; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java index 50fb6ef..92b3082 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.deathAnnouncement; +package eu.carrade.amaury.UHCReloaded.modules.end.deathAnnouncement; import eu.carrade.amaury.UHCReloaded.utils.UHSound; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java index bec2199..0681181 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/deathAnnouncement/DeathAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.deathAnnouncement; +package eu.carrade.amaury.UHCReloaded.modules.end.deathAnnouncement; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java index 01b3f5d..9ee0d38 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.kick; +package eu.carrade.amaury.UHCReloaded.modules.end.kick; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java index 0cdf65c..de6a763 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/kick/KickModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.kick; +package eu.carrade.amaury.UHCReloaded.modules.end.kick; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java index 9e66544..46e4e41 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.xpToKillers; +package eu.carrade.amaury.UHCReloaded.modules.end.xpToKillers; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java index 5bec3aa..c6b89d3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/xpToKillers/XpToKillersModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.xpToKillers; +package eu.carrade.amaury.UHCReloaded.modules.end.xpToKillers; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java index 382c0d3..82ae596 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.dynmap; +package eu.carrade.amaury.UHCReloaded.modules.external.dynmap; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java index b22e501..79dc8b3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/dynmap/DynmapModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.dynmap; +package eu.carrade.amaury.UHCReloaded.modules.external.dynmap; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java index 3c0845b..991804f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; +package eu.carrade.amaury.UHCReloaded.modules.external.motd; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java index 1f3263a..4242a49 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.motd; +package eu.carrade.amaury.UHCReloaded.modules.external.motd; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java index 324d5e2..e49ff03 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.reports; +package eu.carrade.amaury.UHCReloaded.modules.external.reports; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java index a0c40b5..f6664b8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.reports; +package eu.carrade.amaury.UHCReloaded.modules.external.reports; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java index 8e6bfda..1f67eb8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.daylightCycle; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.daylightCycle; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java index f213ef1..fc3cda3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.daylightCycle; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.daylightCycle; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java index a95b3d6..0b80a7e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.hardcore; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.hardcore; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java index c3d9af1..0ec2776 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/hardcore/HardcoreModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.hardcore; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.hardcore; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java index ac64d0c..8fdec29 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.weather; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.weather; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java index 836f512..d7338fa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.weather; +package eu.carrade.amaury.UHCReloaded.modules.gameplay.weather; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java index 6a16391..e0f9ef0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/AdvancementsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame; +package eu.carrade.amaury.UHCReloaded.modules.other; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java index 5111c81..649f5d4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/pomf/PomfModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.pomf; +package eu.carrade.amaury.UHCReloaded.modules.other; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.Config; -import eu.carrade.amaury.UHCReloaded.modules.ingame.episodes.events.EpisodeChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.Config; +import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java index 165bfc3..4cf7231 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/StatisticsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame; +package eu.carrade.amaury.UHCReloaded.modules.other; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java index f94c1d6..13ad7be 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; +package eu.carrade.amaury.UHCReloaded.modules.starting.cages; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.colors.ColorsUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java index 1a98e79..8005284 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; +package eu.carrade.amaury.UHCReloaded.modules.starting.cages; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java index 78c1033..6f8522f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/cages/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.beginning.cages; +package eu.carrade.amaury.UHCReloaded.modules.starting.cages; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java index d7d697f..0f9940a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.check; +package eu.carrade.amaury.UHCReloaded.modules.utilities.check; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java index b08d3d0..d765361 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/check/CheckModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.check; +package eu.carrade.amaury.UHCReloaded.modules.utilities.check; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java index 85d9200..6751fcb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.food; +package eu.carrade.amaury.UHCReloaded.modules.utilities.food; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedAllCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands.FeedCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands.FeedAllCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands.FeedCommand; import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java index a460146..75391a6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedAllCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java index 3a71683..6e7ade4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/food/commands/FeedCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.food.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java index 59aa893..90136e8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; +package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java index 144463b..05fc93a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerListener.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; +package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import org.bukkit.entity.Creature; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java index be36a52..83ccb38 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/freezer/FreezerModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.freezer; +package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java index 16f76ac..22ec402 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/HealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.health; +package eu.carrade.amaury.UHCReloaded.modules.utilities.health; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealAllCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands.HealCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands.HealAllCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands.HealCommand; import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java index fdbaf27..12a5c97 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealAllCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java index 97d1679..21a7abd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/health/commands/HealCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.health.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands; import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java index 64ef8d1..4cc85da 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/LoadPlayersCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.playersLoader; +package eu.carrade.amaury.UHCReloaded.modules.utilities.playersLoader; import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; import fr.zcraft.zlib.components.commands.Command; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java index 7861f83..88937f9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/playersLoader/PlayersLoaderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.playersLoader; +package eu.carrade.amaury.UHCReloaded.modules.utilities.playersLoader; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java index a10882c..52352c7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.rules; +package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java index 4126540..078a2a2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.other.rules; +package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java index a43dcae..f3f3c9c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/rules/RulesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.other.rules; +package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java index 73c9c30..9b25dc3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.UHModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPDeathCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpawnCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPSpectatorsCommand; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands.TPTeamCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPDeathCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPSpawnCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPSpectatorsCommand; +import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPTeamCommand; import fr.zcraft.zlib.components.commands.Command; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java index 955ef35..7c5a9c0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPDeathCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java @@ -31,9 +31,9 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; -import eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.TeleportationModule; +import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.TeleportationModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java index 6b14354..b300b94 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java index 5e6d9c9..6c271f6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPSpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java index 11d2dc5..79c842a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/TPTeamCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java index f635e6b..3d72ad7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/ingame/teleportation/commands/WorldBasedCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.ingame.teleportation.commands; +package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java index 668d010..f6dc8ff 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java index ed4623b..22f1c1e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java @@ -31,10 +31,10 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.CannotGenerateWallsException; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java index de2d434..cc214f6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions.UnknownWallGenerator; -import eu.carrade.amaury.UHCReloaded.modules.border.walls.generators.WallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.UnknownWallGenerator; +import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators.WallGenerator; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.commands.Command; @@ -52,7 +52,7 @@ @ModuleInfo ( name = "Walls Generator", - description = "Generates a solid wall around the arena.", + description = "Provides a command to generate a solid wall around the arena.", when = ModuleLoadTime.POST_WORLD, category = ModuleCategory.UTILITIES, icon = Material.BARRIER, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java index c47db3a..fdb448c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions; public class CannotGenerateWallsException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java index fa31faf..71c635a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.exceptions; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions; public class UnknownWallGenerator extends CannotGenerateWallsException { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java index e6158f6..9e0b2a4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java index 6a54e7d..4f0f2bf 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java index 225a21b..029b0e5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; import org.apache.commons.lang3.Validate; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java index 873b7b9..ff82840 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/walls/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.walls.generators; +package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; /** * Used to determine in witch wall we are, to get the "inner" block. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java index be7d87a..6149ff1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.border.warning; +package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java index 97fde42..446dfe1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.warning; +package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java index 9826f96..f0f5942 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.warning; +package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java index 5c050c2..34b2cd7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/border/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.border.warning; +package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java index 6fc45aa..cca7d5c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.beginning.wait; +package eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java index 112dd11..d721b86 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/beginning/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.beginning.wait; +package eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; From 791166d61363a5e0e5475450385888f0765596d8 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 21 Jan 2019 03:11:01 +0100 Subject: [PATCH 62/91] Runtime commands executor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → The runtime commands executor is back, with new phases support. → Adjusted divergences in cages' default configuration. --- .../carrade/amaury/UHCReloaded/UHConfig.java | 21 -- .../events/game/GamePhaseChangedEvent.java | 2 +- .../modules/starting/cages/Config.java | 2 +- .../runtimeCommandsExecutor/Config.java | 55 +++++ .../RuntimeCommandsExecutor.java | 232 +++++++++++------- .../ScheduledCommandsExecutorTask.java | 2 +- .../utilities-runtime-commands-executor.yml | 35 +++ 7 files changed, 243 insertions(+), 106 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/misc => modules/utilities/runtimeCommandsExecutor}/RuntimeCommandsExecutor.java (51%) rename src/main/java/eu/carrade/amaury/UHCReloaded/{old/task => modules/utilities/runtimeCommandsExecutor}/ScheduledCommandsExecutorTask.java (96%) create mode 100644 src/main/resources/modules/utilities-runtime-commands-executor.yml diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index 201a557..d57bb22 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -27,27 +27,6 @@ static public class WorldsSection extends ConfigurationSection } - static public final PlayersListSection PLAYERS_LIST = section("playersList", PlayersListSection.class); - - static public class PlayersListSection extends ConfigurationSection - { - public final WaitingTimeSection WAITING_TIME = section("waitingTime", WaitingTimeSection.class); - - static public class WaitingTimeSection extends ConfigurationSection - { - public final ConfigurationItem<String> HEADER = item("header", "{title}"); - public final ConfigurationItem<String> FOOTER = item("footer", ""); - } - - public final InGameTimeSection IN_GAME_TIME = section("inGameTime", InGameTimeSection.class); - - static public class InGameTimeSection extends ConfigurationSection - { - public final ConfigurationItem<String> HEADER = item("header", "{title}"); - public final ConfigurationItem<String> FOOTER = item("footer", "§a{episodeText} §7- §a{playersText} §7- §a{teamsText}"); - } - } - static public final FinishSection FINISH = section("finish", FinishSection.class); static public class FinishSection extends ConfigurationSection diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java index 35f577b..0cd0e62 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java @@ -92,7 +92,7 @@ public GamePhase getNewPhase() */ public boolean isRunningForward() { - return newPhase.ordinal() > oldPhase.ordinal(); + return oldPhase == null || newPhase.ordinal() > oldPhase.ordinal(); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java index 6f8522f..0a71ed3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java @@ -52,7 +52,7 @@ public Config(File file) public static final ConfigurationItem<Cage.CageType> TYPE = item("type", Cage.CageType.TEAM_COLOR_TRANSPARENT); public static final ConfigurationItem<Material> CUSTOM_BLOCK = item("custom-block", Material.BARRIER); public static final ConfigurationItem<Boolean> BUILD_CEILING = item("build-ceiling", false); - public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visible-walls", false); + public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visible-walls", true); public static final ConfigurationItem<Integer> RADIUS = item("radius", 2); public static final ConfigurationItem<Integer> HEIGHT = item("height", 3); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java new file mode 100644 index 0000000..6ac043e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java @@ -0,0 +1,55 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationList; + +import java.io.File; +import java.util.Map; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public final static ConfigurationList<Map> WAIT = list("wait", Map.class); + public final static ConfigurationList<Map> STARTING = list("starting", Map.class); + public final static ConfigurationList<Map> IN_GAME = list("in-game", Map.class); + public final static ConfigurationList<Map> END = list("end", Map.class); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java similarity index 51% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java index 43810aa..cd26b10 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/misc/RuntimeCommandsExecutor.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java @@ -29,116 +29,158 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.misc; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.old.task.ScheduledCommandsExecutorTask; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.zlib.tools.PluginLogger; import fr.zcraft.zlib.tools.runners.RunTask; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitTask; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; /** - * This will execute the commands to be executed during runtime, as configured in the config.yml file + * This will execute the commands to be executed during runtime, as configured in the config file * or added through the API. */ -public class RuntimeCommandsExecutor +@ModuleInfo ( + name = "Runtime Commands Executor", + description = "Executes commands during runtime, at specific times of the game, automatically. " + + "This is a powerful tool to schedule any command at any time relative to the game progression.", + when = ModuleLoadTime.STARTUP, + category = ModuleCategory.UTILITIES, + icon = Material.COMMAND, + settings = Config.class +) +public class RuntimeCommandsExecutor extends UHModule { - private final UHCReloaded p; - /** * Stores the commands to be executed later. * <p> * The first map (String->HashMap) associates a key to a group of commands launched at the same time.<br> * The sub-map (Integer->HashSet) associates a delay, in seconds, with a set containing the commands to be - * executed this number of seconds after the call of the {@link #registerCommandsInScheduler(String)} + * executed this number of seconds after the call of the {@link #runCommands(String)} * method. */ private final Map<String, HashMap<Integer, HashSet<String>>> scheduled = new HashMap<>(); - /** - * The key for the commands executed when the server starts. + * Stores the running tasks, to be able to cancel them. */ - public final static String AFTER_SERVER_START = "internal.server-start"; + private final Map<String, Set<BukkitTask>> runningTasks = new HashMap<>(); - /** - * The key for the commands executed after the beginning of the game. - */ - public final static String AFTER_GAME_START = "internal.game-start"; /** - * The key for the commands executed after the end of the game. + * Register the commands registered under the given key in the Bukkit' scheduler. + * <p> + * Delays are from the execution of this method. + * + * @param key The key to schedule. All commands previously registered under this key will be executed. */ - public final static String AFTER_GAME_END = "internal.game-end"; - - - public RuntimeCommandsExecutor() + public void runCommands(final String key) { - p = UHCReloaded.get(); - - importFromConfig("commands.execute-server-start", AFTER_SERVER_START); - importFromConfig("commands.execute-start", AFTER_GAME_START); - importFromConfig("commands.execute-end", AFTER_GAME_END); + runCommands(key, scheduled.get(key)); } /** - * Register the commands registered under the given key in the Bukkit' scheduler. + * Register the commands registered under the given phase in the Bukkit' scheduler. * <p> * Delays are from the execution of this method. * - * @param key The key to schedule. All commands previously registered under this key will be executed. + * @param phase The phase to schedule. All commands previously registered under this phase will be executed. */ - public void registerCommandsInScheduler(String key) + public void runCommands(final GamePhase phase) { - registerCommandsInScheduler(scheduled.get(key)); + runCommands(getPhaseKey(phase)); } /** * Register the given commands in the Bukkit' scheduler. * * Delays are from the execution of this method. - * @param scheduledCommands + * @param key The key to store the tasks under. + * @param scheduledCommands The commands to schedule */ - private void registerCommandsInScheduler(Map<Integer, HashSet<String>> scheduledCommands) + private void runCommands(final String key, final Map<Integer, HashSet<String>> scheduledCommands) { if (scheduledCommands != null) { + final Set<BukkitTask> tasks = runningTasks.computeIfAbsent(key, k -> new HashSet<>()); for (Entry<Integer, HashSet<String>> scheduledCommandsStack : scheduledCommands.entrySet()) { - RunTask.later( + tasks.add(RunTask.later( new ScheduledCommandsExecutorTask(scheduledCommandsStack.getValue()), scheduledCommandsStack.getKey() * 20L - ); + )); } } } + /** + * Cancels all tasks currently running for the given key. + * @param key The key. + */ + public void cancelTasks(final String key) + { + if (runningTasks.containsKey(key)) + { + runningTasks.get(key).forEach(BukkitTask::cancel); + runningTasks.get(key).clear(); + } + } + + /** + * Cancels all tasks currently running for the given phase. + * @param phase The phase. + */ + public void cancelTasks(final GamePhase phase) + { + cancelTasks(getPhaseKey(phase)); + } + /** * Schedules a command. - * <p> - * To schedule a command executed by the plugin, like in the configuration file, you will have - * to use the keys defined as static attributes of this class: - * {@link #AFTER_SERVER_START}, {@link #AFTER_GAME_END} and {@link #AFTER_GAME_START}. + * + * Commands scheduled with any non-standard key will not be executed automatically. You'll have + * to call {@link #runCommands(String)} to schedule them. * * @param key The command will be stored under this key. - * The keys internally used by the plugin start by "{@code internal.}". * @param command The command to add. - * @param delay The delay (seconds). + * @param delay The delay. + * @see #scheduleCommand(GamePhase, String, TimeDelta) to schedule a command from one game phase change. */ - public void scheduleCommand(String key, String command, Integer delay) + public void scheduleCommand(final String key, final String command, final TimeDelta delay) { final Map<Integer, HashSet<String>> commandsMap = scheduled.computeIfAbsent(key, k -> new HashMap<>()); scheduleCommand(commandsMap, command, delay); } + /** + * Schedule a command to be run when the given phase starts. + * + * @param phase The phase + * @param command The command to execute + * @param delay The delay after the phase's beginning. + */ + public void scheduleCommand(final GamePhase phase, String command, final TimeDelta delay) + { + scheduleCommand(getPhaseKey(phase), command, delay); + } + /** * Schedules a command. * @@ -146,9 +188,9 @@ public void scheduleCommand(String key, String command, Integer delay) * @param command The command to add. * @param delay The delay (seconds). */ - private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, Integer delay) + private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, TimeDelta delay) { - final Set<String> list = scheduledCommands.computeIfAbsent(delay, k -> new HashSet<>()); + final Set<String> list = scheduledCommands.computeIfAbsent((int) delay.getSeconds(), k -> new HashSet<>()); list.add(clearCommandName(command)); } @@ -157,7 +199,6 @@ private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, St * Removes the given command from everywhere. * * @param key The command will be stored under this key. - * The keys internally used by the plugin start by "{@code internal.}". * @param command The command. Not case-sensitive. */ public void removeScheduledCommand(String key, String command) @@ -189,24 +230,34 @@ private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledComma /** * Removes the given command from everywhere. * - * @param key The command will be stored under this key. - * The keys internally used by the plugin start by "{@code internal.}". + * @param key The key the command was registered under. * @param command The command. Not case-sensitive. */ - public void removeScheduledCommand(String key, String command, Integer delay) + public void removeScheduledCommand(String key, String command, TimeDelta delay) { removeScheduledCommand(scheduled.get(key), command, delay); } + /** + * Removes the given command from everywhere. + * + * @param phase The phase the command was registered under. + * @param command The command. Not case-sensitive. + */ + public void removeScheduledCommand(GamePhase phase, String command, TimeDelta delay) + { + removeScheduledCommand(getPhaseKey(phase), command, delay); + } + /** * Removes the given command from everywhere. * * @param scheduledCommands A map containing the scheduled commands, sorted by delay. * @param command The command. Not case-sensitive. */ - private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, Integer delay) + private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, TimeDelta delay) { - HashSet<String> commands = scheduledCommands.get(delay); + HashSet<String> commands = scheduledCommands.get(((int) delay.getSeconds())); if (commands != null) { @@ -219,48 +270,65 @@ private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledComma /* Utilities */ - /** - * Imports the commands stored in the configuration. - * - * @param path The path in the config file. - * @param key The command will be stored under this key. - * The keys internally used by the plugin start by "{@code internal.}". - */ - private void importFromConfig(String path, String key) + + private String clearCommandName(String command) { - List<Map<?, ?>> rawCommands = p.getConfig().getMapList(path); + if (command.startsWith("/")) + { + command = command.substring(1); + } + + return command; + } + + private String getPhaseKey(final GamePhase phase) + { + return "internal." + phase.name().toLowerCase().replace('_', '-'); + } + - if (rawCommands != null) + /* Events to launch tasks */ + + @EventHandler + protected void onGamePhaseChanged(final GamePhaseChangedEvent ev) + { + if (!ev.isRunningForward()) { - for (Map<?, ?> rawCommand : rawCommands) - { - String cmd = String.valueOf(rawCommand.get("exec")); - Integer delay; + cancelTasks(ev.getNewPhase()); + return; + } + + // We load the commands to run + final ConfigurationList<Map> commands; - if (cmd == null || cmd.isEmpty()) continue; + switch (ev.getNewPhase()) + { + case WAIT: commands = Config.WAIT; break; + case STARTING: commands = Config.STARTING; break; + case IN_GAME: commands = Config.IN_GAME; break; + case END: commands = Config.END; break; + default: return; + } + commands.stream() + .filter(command -> command.containsKey("exec") && !command.get("exec").toString().isEmpty()) + .forEach(command -> { try { - delay = UHUtils.string2Time(String.valueOf(rawCommand.get("delay"))); + scheduleCommand(ev.getNewPhase(), command.get("exec").toString(), new TimeDelta(command.get("delay").toString())); } catch (IllegalArgumentException e) { - delay = 0; + PluginLogger.error( + "Invalid delay “{0}” in scheduled command “{1}” for phase {2}", + command.get("delay").toString(), + command.get("exec").toString(), + ev.getNewPhase() + ); } + }); - scheduleCommand(key, cmd, delay); - } - } - } - - - private String clearCommandName(String command) - { - if (command.startsWith("/")) - { - command = command.substring(1); - } - - return command; + // And we schedule all of them. + runCommands(ev.getNewPhase()); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java index 7407393..880603f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/ScheduledCommandsExecutorTask.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.old.task; +package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; import eu.carrade.amaury.UHCReloaded.UHCReloaded; import fr.zcraft.zlib.tools.PluginLogger; diff --git a/src/main/resources/modules/utilities-runtime-commands-executor.yml b/src/main/resources/modules/utilities-runtime-commands-executor.yml new file mode 100644 index 0000000..e06e74b --- /dev/null +++ b/src/main/resources/modules/utilities-runtime-commands-executor.yml @@ -0,0 +1,35 @@ +# This module allows you to schedule commands at any moment during the game. They will be executed by the console +# automatically. +# For each game phase, you'll be able to configure a list of commands to run, with a delay for each of them. The +# commands will be executed when the phase is reached, after the given delay. As example, a command configured into +# the `in-game` list with a 3-minutes delay will be executed three minutes after the game's start. +# The delay's formats are "mm" (minutes), "mm:ss" or "hh:mm:ss". +# Empty commands are ignored. + + +# Commands executed from the server startup. +wait: + - exec: "" + delay: "00:12:00" + + +# Commands executed from the moment the game is launched (when the /uh start is first executed, or the corresponding +# GUI button). Beware that this phase can be cancelled, e.g. if the game cannot be started. If so, all non-executed +# commands will not be executed, but some (especially with a zero delay) may have been executed and could be executed +# twice. +starting: + - exec: "" + delay: "00:24:00" + + +# Commands executed from the moment the game starts for real, when players falls from their spawn point into the world. +in-game: + - exec: "" + delay: "00:48:00" + + +# Commands executed from the game's end. Beware that this phase can be cancelled, e.g. if someone is resurrected. If so, +# all non-executed commands will not be executed, but some ay have been executed and could be executed twice. +end: + - exec: "" + delay: "01:36:00" From cf8e31584892d83c3fe44da1752a5d3ea61991f1 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 21 Jan 2019 15:11:07 +0100 Subject: [PATCH 63/91] Added modules fireworks & end announcements. Everything is re-implemented \o/ --- .../amaury/UHCReloaded/UHCReloaded.java | 2 +- .../carrade/amaury/UHCReloaded/UHConfig.java | 11 +- .../UHCReloaded/core/ModuleCategory.java | 2 +- .../modules/end/EndAnnouncementModule.java | 127 ++++++++++++++++++ .../modules/end/FireworksModule.java | 106 +++++++++++++++ .../gameplay/noWitches/NoWitchesModule.java | 2 +- .../gameplay/potions/PotionsModule.java | 2 +- .../old/task/FireworksOnWinnersTask.java | 91 ------------- 8 files changed, 238 insertions(+), 105 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java delete mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index 9bf256a..b97839f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -136,7 +136,7 @@ public void onEnable() /* *** Built-in modules *** */ - if (UHConfig.BULT_IN_MODULES.get()) + if (UHConfig.BUILT_IN_MODULES.get()) { modulesManager.registerBuiltInModules(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index d57bb22..d08fa6e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -14,7 +14,7 @@ public class UHConfig extends Configuration static public final ConfigurationItem<String> TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); - static public final ConfigurationItem<Boolean> BULT_IN_MODULES = item("built-in-modules", true); + static public final ConfigurationItem<Boolean> BUILT_IN_MODULES = item("built-in-modules", true); static public final ConfigurationMap<String, Boolean> MODULES = map("modules", String.class, Boolean.class); static public final WorldsSection WORLDS = section("worlds", WorldsSection.class); @@ -51,13 +51,4 @@ static public class FireworksSection extends ConfigurationSection public final ConfigurationItem<Double> AREA_SIZE = item("areaSize", 6d); } } - - static public final CommandsSection COMMANDS = section("commands", CommandsSection.class); - - static public class CommandsSection extends ConfigurationSection - { - public final ConfigurationList<String> EXECUTE_SERVER_START = list("execute-server-start", String.class); - public final ConfigurationList<String> EXECUTE_START = list("execute-start", String.class); - public final ConfigurationList<String> EXECUTE_END = list("execute-end", String.class); - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java index 60cee4b..393e216 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java @@ -74,7 +74,7 @@ public enum ModuleCategory END ( I.t("Game End"), - I.t("These modules alter the game end (either player deaths or whole game end)."), + I.t("These modules alter the game end (either player deaths or whole game end)."), Material.SKULL_ITEM, ChatColor.RED ), diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java new file mode 100644 index 0000000..011f113 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java @@ -0,0 +1,127 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.end; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.tools.runners.RunTask; +import fr.zcraft.zlib.tools.text.Titles; +import fr.zcraft.zteams.ZTeam; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; + +@ModuleInfo ( + name = "End Announcement", + description = "Announces the winner's name to the whole server when the game ends.", + when = ModuleLoadTime.ON_GAME_END, + category = ModuleCategory.END, + icon = Material.ITEM_FRAME +) +public class EndAnnouncementModule extends UHModule +{ + @Override + protected void onEnable() + { + RunTask.later(() -> + { + if (UR.game().getPhase() != GamePhase.END) return; + + final ZTeam winnerTeam = UR.game().getWinner(); + + if (winnerTeam == null) return; // No winner + + Bukkit.broadcastMessage(""); + + if (UR.game().isTeamsGame()) + { + final StringBuilder winners = new StringBuilder(); + int j = 0; + + for (final OfflinePlayer winner : winnerTeam.getPlayers()) + { + if (j != 0) + { + if (j == winnerTeam.size() - 1) + { + /// The "and" in the winners players list (like "player1, player2 and player3"). + winners.append(" ").append(I.tc("winners_list", "and")).append(" "); + } + else + { + winners.append(", "); + } + } + + winners.append(winner.getName()); + j++; + } + + Bukkit.broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", winners.toString(), winnerTeam.getDisplayName())); + } + else + { + Bukkit.broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", winnerTeam.getName())); + } + + Bukkit.broadcastMessage(""); + + + final String title; + final String subtitle; + + if (UR.game().isTeamsGame()) + { + /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). + title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); + /// The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). + subtitle = I.t("{green}This team wins the game!", winnerTeam.getDisplayName()); + } + else + { + /// The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). + title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); + /// The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). + subtitle = I.t("{green}wins the game!", winnerTeam.getDisplayName()); + } + + Titles.broadcastTitle(5, 142, 21, title, subtitle); + }, 6 * 20L); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java new file mode 100644 index 0000000..f4543cc --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java @@ -0,0 +1,106 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.end; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import fr.zcraft.zlib.tools.runners.RunTask; +import org.apache.commons.lang.math.RandomUtils; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.scheduler.BukkitRunnable; + + +@ModuleInfo ( + name = "Fireworks", + description = "When the game ends, this module sends some fireworks from the winners o/", + when = ModuleLoadTime.ON_GAME_END, + category = ModuleCategory.END, + icon = Material.FIREWORK +) +public class FireworksModule extends UHModule +{ + private final int area = 6; // Fireworks launched on a 6×6 area around the winners + private final TimeDelta duration = new TimeDelta(10); + + @Override + protected void onEnable() + { + RunTask.later(() -> + { + if (UR.game().getPhase() != GamePhase.END) return; + + final long start = System.currentTimeMillis(); + + RunTask.timer(new BukkitRunnable() { + @Override + public void run() + { + if (UR.game().getWinner() == null) return; + + UR.game().getWinner().getOnlinePlayers().forEach(winner -> + { + final Location fireworkLocation = winner.getLocation(); + + fireworkLocation.add( + // a number between -area/2 and area/2 + RandomUtils.nextDouble() * area - (area >> 1), + + // y+2 for a clean vision of the winner. + 2, + + // a number between -area/2 and area/2 + RandomUtils.nextDouble() * area - (area >> 1) + ); + + UHUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); + UHUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); + }); + + if ((System.currentTimeMillis() - start) / 1000 > duration.getSeconds()) + { + cancel(); + } + } + }, 0L, 30L); + + }, 5 * 20L); + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java index b10ae87..925304b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java @@ -48,7 +48,7 @@ description = "Prevents witches from spawning, either naturally, from lightning strike on a villager, or both.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.GLASS_BOTTLE, + icon = Material.POTION, settings = Config.class ) public class NoWitchesModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java index 265374f..563ccd5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java @@ -51,7 +51,7 @@ "splash or lingering potions.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.POTION, + icon = Material.BREWING_STAND_ITEM, settings = Config.class ) public class PotionsModule extends UHModule diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java b/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java deleted file mode 100644 index 548ca36..0000000 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/old/task/FireworksOnWinnersTask.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.UHCReloaded.old.task; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.Random; -import java.util.Set; - - -public class FireworksOnWinnersTask extends BukkitRunnable -{ - private final Set<OfflinePlayer> winners; - - private Double areaSize; - private Random rand; - - private long startTime; - - public FireworksOnWinnersTask(final Set<OfflinePlayer> listWinners) - { - this.winners = listWinners; - - this.areaSize = UHConfig.FINISH.FIREWORKS.AREA_SIZE.get(); - this.rand = new Random(); - - this.startTime = System.currentTimeMillis(); - } - - @Override - public void run() - { - // The fireworks are launched in a square centered on the player. - final double halfAreaSize = areaSize / 2; - - for (final OfflinePlayer winner : winners) - { - if (winner.isOnline()) - { - Location fireworkLocation = ((Player) winner).getLocation(); - - fireworkLocation.add(rand.nextDouble() * areaSize - halfAreaSize, // a number between -halfAreaSize and halfAreaSize - 2, // y+2 for a clean vision of the winner. - rand.nextDouble() * areaSize - halfAreaSize); - - UHUtils.generateRandomFirework(fireworkLocation.add(0.2, 0d, 0.2), 5, 15); - UHUtils.generateRandomFirework(fireworkLocation.add(-0.2, 0d, 0.2), 5, 15); - } - } - - if ((System.currentTimeMillis() - startTime) / 1000 > UHConfig.FINISH.FIREWORKS.DURATION.get()) - { - this.cancel(); - } - } -} From 77b8d3d2b9b5e20e4f95eb9ebc71b8f893521d73 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 23 Jan 2019 18:44:11 +0100 Subject: [PATCH 64/91] Alliances fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → A little mistake on alliances request confirmers list. → Renamed language files to ISO names. → Removed unused configurations. --- .../amaury/UHCReloaded/UHCReloaded.java | 6 +- .../carrade/amaury/UHCReloaded/UHConfig.java | 25 ----- .../scenarii/alliances/AllianceRequest.java | 1 + .../commands/AllianceRequestCommand.java | 5 +- src/main/resources/config.yml | 97 ++----------------- .../resources/i18n/{cs_CZ.po => cs-CZ.po} | 0 .../resources/i18n/{en_US.po => en-US.po} | 0 .../resources/i18n/{fr_FR.po => fr-FR.po} | 2 +- .../resources/i18n/{pt_BR.po => pt-BR.po} | 0 .../resources/i18n/{pt_PT.po => pt-PT.po} | 0 .../resources/i18n/{zh_CN.po => zh-CN.po} | 0 .../resources/i18n/{zh_CN.yml => zh-CN.yml} | 0 12 files changed, 13 insertions(+), 123 deletions(-) rename src/main/resources/i18n/{cs_CZ.po => cs-CZ.po} (100%) rename src/main/resources/i18n/{en_US.po => en-US.po} (100%) rename src/main/resources/i18n/{fr_FR.po => fr-FR.po} (99%) rename src/main/resources/i18n/{pt_BR.po => pt-BR.po} (100%) rename src/main/resources/i18n/{pt_PT.po => pt-PT.po} (100%) rename src/main/resources/i18n/{zh_CN.po => zh-CN.po} (100%) rename src/main/resources/i18n/{zh_CN.yml => zh-CN.yml} (100%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java index b97839f..f23af95 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java @@ -63,7 +63,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.function.BiConsumer; @@ -98,10 +97,9 @@ public void onEnable() /* *** Internationalization *** */ - if (UHConfig.LANG.get() == null) I18n.useDefaultPrimaryLocale(); - else I18n.setPrimaryLocale(UHConfig.LANG.get()); + if (UHConfig.LANG.isDefined()) I18n.setPrimaryLocale(UHConfig.LANG.get()); - I18n.setFallbackLocale(Locale.US); + PluginLogger.info("Using locale {0} (fallback on {1})", I18n.getPrimaryLocale(), I18n.getFallbackLocale()); /* *** Core events *** */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java index d08fa6e..e6df271 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java @@ -26,29 +26,4 @@ static public class WorldsSection extends ConfigurationSection public final ConfigurationItem<String> THE_END = item("the-end", "world_the_end"); } - - static public final FinishSection FINISH = section("finish", FinishSection.class); - - static public class FinishSection extends ConfigurationSection - { - public final AutoSection AUTO = section("auto", AutoSection.class); - - static public class AutoSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> DO = item("do", true); - public final ConfigurationItem<Integer> TIME_AFTER_LAST_DEATH = item("timeAfterLastDeath", 3); - } - - public final ConfigurationItem<Boolean> MESSAGE = item("message", true); - public final ConfigurationItem<Boolean> TITLE = item("title", true); - - public final FireworksSection FIREWORKS = section("fireworks", FireworksSection.class); - - static public class FireworksSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Long> DURATION = item("duration", 10l); - public final ConfigurationItem<Double> AREA_SIZE = item("areaSize", 6d); - } - } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java index 1ecd673..ef880be 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java @@ -168,6 +168,7 @@ else if (!checkGameEnd()) (requestedTeam.size() > 1 ? requestedTeam : requesterTeam) .getPlayers().stream() .map(OfflinePlayer::getUniqueId) + .filter(uuid -> !uuid.equals(requesterID)) .forEach(player -> approvalsIDs.put(player, false)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java index 8c77abc..d793922 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java @@ -58,7 +58,7 @@ protected void run() throws CommandException { if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { - error("The game is not started."); + error(I.t("The game is not started.")); } else if (args.length == 0) { @@ -80,7 +80,7 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge final AllianceRequest request = new AllianceRequest(playerSender().getUniqueId(), requested.getUniqueId()); - UR.log(AlliancesModule.class).info("New request: {0} - {1}", request, request.getError()); + UR.log().info("New request: {0} - {1}", request, request.getError()); // The rule to send error messages is: no answer should not be distinguishable from // errors linked to existing alliances, because the alliances are secret. @@ -142,7 +142,6 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge case OK: yourRequestHasBeenSent(requested); - request.sendApprovalRequests(); break; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b688661..a20b7bd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,19 +1,15 @@ # # ## Welcome in the UltraHardcore Reloaded configuration file ## -# -# -# About the "sound" configuration, the format is always the same: -# sound: -# name: The name of the sound. Names: see http://l.carrade.eu/bukkit-sounds . Set to "NONE" to disable. -# volume: The volume of the sound. 1 is the normal volume. You can use a decimal value. -# pitch: The pitch of the sound. 1 is the normal pitch. You can use a decimal value. -# -# Warning: NEVER USE TABS in this file, always spaces, to indent. +# +# Configuration for modules is available in the `modules/` sub-folder. You should take a look, as this +# file only contains basic configuration. There's a lot mode available there. +# +# Warning: NEVER USE TABS in these files, always spaces, to indent. -# Available languages: en_US, fr_FR, pt_PT, pt_BR, cs_CZ, zh_CN. +# Available languages: en-US, fr-FR, pt-PT, pt-BR, cs-CZ, zh-CN. # Empty value: system language. -lang: fr +lang: # If set to false, no built-in modules (except core ones) will be loaded (except if # re-specified in the `modules` configuration below). @@ -36,82 +32,3 @@ worlds: overworld: world nether: world_nether the_end: world_the_end - - -# Controls what is displayed in the tab list headers and footers. -# Tags: -# - {title}: contains the scoreboard title (key scoreboard.title). -# - {episodeText}: contains the localized “Episode x” text. -# - {playersText}: contains the localized “x players left” text. -# - {teamsText}: contains the localized “x teams left” text. -# - {episodeNumber}: contains the raw episode number (e.g. “2”). -# - {playersCount}: contains the raw alive players count (e.g. “18”). -# - {teamsCount}: contains the raw alive teams count (e.g. “6”). -# You can use color & formatting codes with either & or §. -# If you want, you can use "\n" to create a new line. -playersList: - waitingTime: - header: "{title}" - footer: "" - inGameTime: - header: "{title}" - footer: "§a{episodeText} §7- §a{playersText} §7- §a{teamsText}" - - -achievements: - # When a player joins the game before the beginning of the game, his achievements are reset? - resetAchievementsAtStartup: true - - # A player cannot award an achievement if the game is not started? - disableAchievementsBeforeStart: true - - -# Controls the behavior of the /uh finish command -finish: - auto: - do: true # Execute /uh finish automatically a few seconds after the final death? - timeAfterLastDeath: 3 # The command will be executed this amount of seconds after the last death. - - message: true # If true, the name of the winner(s) will be broadcasted. - title: true # If true, a title will display the winner(s) of the game. - - fireworks: - enabled: true # If true, some fireworks will be launched at the location of the winners. - duration: 10 # In seconds. - areaSize: 6 # The size of the square, centered on each player, where the fireworks will be launched. - - -# Rules are a way to display rules & other informations to the players. -# The content is completly up to you, formatting included (using standard -# formatting codes with either § or &). It will be displayed as a list to -# the players (one bullet per line in the `rules.rules` entry). -# Empty entries (« - "" ») are replaced by a completly blank line, if you -# need a separator. -rules: - display: - onJoin: false - onStart: true - rules: - - - - -# Execute commands during the game or after the end of it, and after a configurable delay? -# Format explained below. -# Respect the spaces before the keywords ("exec" and "delay" need to be aligned). -commands: - # Commands executed when the server starts. - # These commands are also executed when the server is reloaded. - execute-server-start: - #- exec: command args - # delay: "40:00" (format: "mm", "mm:ss" or "hh:mm:ss". If invalid or not present, 0 seconds.) - - - - # Commands executed after the beginning of the game. - # (The moment when /uh start or /uh start slow go is executed.) - execute-start: - - - - # Commands executed after the end of the game. - # (After the last kill, when only one team is left.) - execute-end: - - diff --git a/src/main/resources/i18n/cs_CZ.po b/src/main/resources/i18n/cs-CZ.po similarity index 100% rename from src/main/resources/i18n/cs_CZ.po rename to src/main/resources/i18n/cs-CZ.po diff --git a/src/main/resources/i18n/en_US.po b/src/main/resources/i18n/en-US.po similarity index 100% rename from src/main/resources/i18n/en_US.po rename to src/main/resources/i18n/en-US.po diff --git a/src/main/resources/i18n/fr_FR.po b/src/main/resources/i18n/fr-FR.po similarity index 99% rename from src/main/resources/i18n/fr_FR.po rename to src/main/resources/i18n/fr-FR.po index e9e750c..c703376 100644 --- a/src/main/resources/i18n/fr_FR.po +++ b/src/main/resources/i18n/fr-FR.po @@ -994,7 +994,7 @@ msgid "" "to accept." msgstr "" "{gray}Cette requête a été envoyée à {0}, mais l'ensemble des membres de " -"l'alliance doivent également l'accepter." +"l'alliance doit également l'accepter." #: src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java:208 msgid "{darkgreen}{bold}» {green}{bold}Accept {darkgreen}{bold}«" diff --git a/src/main/resources/i18n/pt_BR.po b/src/main/resources/i18n/pt-BR.po similarity index 100% rename from src/main/resources/i18n/pt_BR.po rename to src/main/resources/i18n/pt-BR.po diff --git a/src/main/resources/i18n/pt_PT.po b/src/main/resources/i18n/pt-PT.po similarity index 100% rename from src/main/resources/i18n/pt_PT.po rename to src/main/resources/i18n/pt-PT.po diff --git a/src/main/resources/i18n/zh_CN.po b/src/main/resources/i18n/zh-CN.po similarity index 100% rename from src/main/resources/i18n/zh_CN.po rename to src/main/resources/i18n/zh-CN.po diff --git a/src/main/resources/i18n/zh_CN.yml b/src/main/resources/i18n/zh-CN.yml similarity index 100% rename from src/main/resources/i18n/zh_CN.yml rename to src/main/resources/i18n/zh-CN.yml From 13d4b9f1f387b560ce3b86a7416b2bcbf296b6c2 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 25 Jan 2019 00:57:16 +0100 Subject: [PATCH 65/91] DamagesLogger is now Hawk + added first golden apple in reports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Updated code and module name to reflect DamagesLogger's new name (Hawk). → Added “first golden head” event in timeline. → Added a way to execute a lambda if a module is loaded, this lambda being a consumer of the given module instance. --- pom.xml | 8 +- .../amaury/UHCReloaded/core/ModuleLogger.java | 6 +- .../UHCReloaded/core/ModulesManager.java | 15 +++- .../cosmetics/episodes/EpisodesModule.java | 15 ++-- .../external/{reports => hawk}/Config.java | 2 +- .../HawkModule.java} | 77 +++++++++++-------- .../goldenHeads/GoldenHeadsModule.java | 12 ++- .../amaury/UHCReloaded/shortcuts/UR.java | 30 ++++++++ 8 files changed, 111 insertions(+), 54 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/{reports => hawk}/Config.java (99%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/{reports/ReportsModule.java => hawk/HawkModule.java} (92%) diff --git a/pom.xml b/pom.xml index 5cb654a..8c6db3a 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ <includes> <include>fr.zcraft:zlib</include> <include>fr.zcraft:zteams</include> - <include>me.cassayre.florian:DamagesLogger</include> + <include>me.cassayre.florian:Hawk</include> </includes> </artifactSet> <relocations> @@ -113,8 +113,8 @@ <shadedPattern>eu.carrade.amaury.UHCReloaded.zteams</shadedPattern> </relocation> <relocation> - <pattern>me.cassayre.florian.damageslogger</pattern> - <shadedPattern>eu.carrade.amaury.UHCReloaded.damageslogger</shadedPattern> + <pattern>me.cassayre.florian.hawk</pattern> + <shadedPattern>eu.carrade.amaury.UHCReloaded.hawk</shadedPattern> </relocation> </relocations> </configuration> @@ -176,7 +176,7 @@ </dependency> <dependency> <groupId>me.cassayre.florian</groupId> - <artifactId>DamagesLogger</artifactId> + <artifactId>Hawk</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java index d1d47f7..c257d1e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java @@ -122,11 +122,7 @@ public void broadcastAdministrative(final String message) public void broadcastAdministrative(final RawText message) { // TODO use permissions - Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> { - player.sendMessage(""); - RawMessage.send(player, message); - }); - + Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> RawMessage.send(player, message)); info(ChatColor.stripColor(message.toPlainText())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index a8dce46..059ab8a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -262,6 +262,19 @@ public boolean isLoaded(final ModuleLoadTime loadTime) return loadedPriorities.contains(loadTime); } + /** + * Checks if the given module is loaded. + * + * @param module The module's class. + * @return {@code true} if loaded. + */ + public boolean isLoaded(final Class<? extends UHModule> module) + { + final ModuleWrapper wrapper = modules.get(module); + + return wrapper != null && wrapper.isLoaded(); + } + /** * Gets a module's instance. This may return null if the module is not currently * enabled. @@ -275,7 +288,7 @@ public static <M extends UHModule> M getModule(final Class<M> moduleClass) { final ModuleWrapper module = UR.get().getModulesManager().modules.get(moduleClass); - if (module == null) return null; + if (module == null || !module.isLoaded()) return null; else return (M) module.get(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java index 8684ca3..50c4dca 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java @@ -76,7 +76,6 @@ public class EpisodesModule extends UHModule { private final GameModule game = UR.game(); private final TimersModule timers = UR.module(TimersModule.class); - private final PlayerListHeaderFooterModule headFoot = UR.module(PlayerListHeaderFooterModule.class); private Timer episodesTimer; private int episode = 1; @@ -95,11 +94,10 @@ protected void onEnable() episodesTimer.start(); - if (headFoot != null) - { + UR.ifLoaded(PlayerListHeaderFooterModule.class, headFoot -> { headFoot.registerPlaceholder("episodeText", () -> I.t("Episode {0}", episode)); headFoot.registerPlaceholder("episodeNumber", () -> String.valueOf(episode)); - } + }); } @Override @@ -158,18 +156,15 @@ public void onEpisodeChange(final EpisodeChangedEvent ev) { Titles.broadcastTitle( 5, 32, 8, + "", /// The title displayed when the episode change. {0} = new episode number; {1} = old. - I.t("{darkaqua}Episode {aqua}{0}", ev.getNewEpisode(), ev.getOldEpisode()), - "" + I.t("{darkaqua}Episode {aqua}{0}", ev.getNewEpisode(), ev.getOldEpisode()) ); } // Update headers & footers - if (headFoot != null) - { - headFoot.update(); - } + UR.ifLoaded(PlayerListHeaderFooterModule.class, PlayerListHeaderFooterModule::update); } public int getEpisode() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java index e49ff03..bcb4443 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.reports; +package eu.carrade.amaury.UHCReloaded.modules.external.hawk; import fr.zcraft.zlib.components.configuration.ConfigurationInstance; import fr.zcraft.zlib.components.configuration.ConfigurationItem; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java index f6664b8..8272b89 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/reports/ReportsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.reports; +package eu.carrade.amaury.UHCReloaded.modules.external.hawk; import eu.carrade.amaury.UHCReloaded.UHConfig; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; @@ -44,6 +44,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; +import eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads.GoldenHeadsModule; import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import fr.zcraft.zlib.components.events.FutureEventHandler; @@ -58,11 +59,11 @@ import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.events.*; -import me.cassayre.florian.damageslogger.ReportsManager; -import me.cassayre.florian.damageslogger.report.InvalidReportException; -import me.cassayre.florian.damageslogger.report.Report; -import me.cassayre.florian.damageslogger.report.ReportEvent; -import me.cassayre.florian.damageslogger.report.ReportTeam; +import me.cassayre.florian.hawk.ReportsManager; +import me.cassayre.florian.hawk.report.InvalidReportException; +import me.cassayre.florian.hawk.report.Report; +import me.cassayre.florian.hawk.report.ReportEvent; +import me.cassayre.florian.hawk.report.ReportTeam; import org.bukkit.*; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; @@ -86,22 +87,18 @@ @ModuleInfo ( - name = "Reports", - short_description = "Generates reports of the game, including history, damages, " + - "heals, statistics, etc., displayed on a web page, and gives the URL " + - "when the match ends.", + name = "Hawk Reports", description = "Generates reports of the game, including history, damages, " + "heals, statistics, etc., displayed on a web page, and gives the URL " + - "when the match ends.\n\n" + - "Using DamagesLogger by Florian Cassayre & Amaury Carrade.", - authors = "Florian Cassayre & Amaury Carrade", + "when the match ends.", + authors = "Florian Cassayre & Amaury Carrade through the Hawk Project", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.EXTERNAL, icon = Material.BOOK_AND_QUILL, settings = Config.class, can_be_unloaded = false ) -public class ReportsModule extends UHModule +public class HawkModule extends UHModule { private GameModule game; @@ -118,7 +115,7 @@ public class ReportsModule extends UHModule private boolean firstNether = false; private boolean firstEnd = false; private boolean firstGoldenApple = false; - private boolean firstGoldenHead = false; // FIXME not implemented + private boolean firstGoldenHead = false; /* * Used to know who used the brewing stands last to know to who the “first @@ -132,7 +129,7 @@ public class ReportsModule extends UHModule */ private BukkitTask waitAfterEndTask = null; private TimeDelta waitAfterEndDelay = new TimeDelta(30); - private boolean waitingfterEnd = false; + private boolean waitingAfterEnd = false; @Override @@ -235,7 +232,7 @@ private void updateReportTeams() if (game.isTeamsGame()) { ZTeams.get().getTeams().stream() - .map(team -> new ReportTeam(team.getName(), team.getColorOrWhite().toChatColor(), team.getPlayers())) + .map(team -> new ReportTeam(team.getName(), team.getColor() != null ? team.getColor().toChatColor() : null, team.getPlayers())) .forEach(report::registerTeam); } } @@ -248,11 +245,11 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) final ZTeam winner = game.getWinner(); if (winner != null) report.setWinners(winner.getPlayers()); - waitingfterEnd = true; + waitingAfterEnd = true; waitAfterEndTask = RunTask.later(() -> { - waitingfterEnd = false; + waitingAfterEnd = false; report.autoTrack(false); @@ -301,13 +298,14 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) log().broadcastAdministrative(I.t("{darkaqua}You can share it using the following URL. It was not broadcast to other players.")); log().broadcastAdministrative(""); - RawMessage.broadcast( + log().broadcastAdministrative( new RawText().uri(uri).hover(I.t("Open {aqua}{0}", uri.toString())) .then("» ").style(ChatColor.DARK_AQUA, ChatColor.BOLD) .then(uri.toString()).style(ChatColor.AQUA) .build() ); + log().broadcastAdministrative(""); break; case CONSOLE: @@ -342,7 +340,7 @@ else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) report.resetWinners(); report.autoTrack(true); - waitingfterEnd = false; + waitingAfterEnd = false; if (waitAfterEndTask != null) { @@ -356,7 +354,7 @@ else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) public void onPlayerDeath(final AlivePlayerDeathEvent ev) { report - .untrackPlayer(ev.getPlayer()) + .untrack(ev.getPlayer()) .record(ReportEvent.withPlayer( ReportEvent.EventType.GOLD, /// Title of the death event on the game report's timeline. @@ -373,13 +371,13 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerDeath(final PlayerDeathEvent ev) { - // Recording cross-kills and other deaths after the game end (i.e. from fire) + // Recording cross-kills and other deaths after the game end (e.g. from fire) // during a 30-seconds period. - if (!waitingfterEnd) return; + if (!waitingAfterEnd) return; report - .untrackPlayer(ev.getEntity()) + .untrack(ev.getEntity()) .record(ReportEvent.withPlayer( ReportEvent.EventType.GOLD, /// Title of the death event on the game report's timeline. @@ -393,7 +391,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) public void onPlayerResurrected(final PlayerResurrectedEvent ev) { report - .trackPlayer(ev.getPlayer()) + .track(ev.getPlayer()) .record(ReportEvent.withPlayer( ReportEvent.EventType.GREEN, /// Title of the resurrection event on the game report's timeline. @@ -567,14 +565,29 @@ else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(UR.get().getWor @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemConsumed(final PlayerItemConsumeEvent ev) { - if (firstGoldenApple || !game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) + if (!game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) return; - report.record(ReportEvent.withIcon( - I.t("{0} used the first golden apple", ev.getPlayer().getName()), - "item-apple-golden" - )); + final SkullType headType = UR.loaded(GoldenHeadsModule.class) ? UR.module(GoldenHeadsModule.class).readHeadType(ev.getItem()) : null; + + if (headType == SkullType.PLAYER && !firstGoldenHead) + { + report.record(ReportEvent.withIcon( + I.t("{0} ate the first golden head", ev.getPlayer().getName()), + "item-apple-golden" + )); - firstGoldenApple = true; + firstGoldenHead = true; + } + + else if (!firstGoldenApple) + { + report.record(ReportEvent.withIcon( + I.t("{0} ate the first golden apple", ev.getPlayer().getName()), + "item-apple-golden" + )); + + firstGoldenApple = true; + } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java index 433e7c7..a5b2ed7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -156,7 +156,17 @@ private void writeHeadType(final ItemStack stack, final SkullType type) } } - private SkullType readHeadType(final ItemStack stack) + /** + * From a golden apple, reads the head type written in it, so you can know + * if it's a regular golden apple, a Wither golden head or a Player golden + * head. + * + * @param stack The ItemStack to analyze. + * @return Either {@link SkullType#PLAYER} (Player golden head), + * {@link SkullType#WITHER} (Wither golden head) or {@code null} (regular + * golden apple). + */ + public SkullType readHeadType(final ItemStack stack) { try { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java index a276a33..eb6e412 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java @@ -47,6 +47,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.function.Consumer; /** @@ -110,6 +111,35 @@ public static GameModule game() return module(GameModule.class); } + /** + * Checks if a module is loaded. If this test is positive, the + * {@link #module(Class)} method called with the same class will be + * non-null and available. + * + * @param moduleClass The module's class. + * @param <M> The module's type. + * + * @return {@code true} if the given module is loaded. + */ + public static <M extends UHModule> boolean loaded(Class<M> moduleClass) + { + return get().getModulesManager().isLoaded(moduleClass); + } + + /** + * Checks if a module is loaded; if so, executes the consumer with the module's + * instance as argument. + * + * @param moduleClass The module's class. + * @param consumer The module's instance consumer. + * @param <M> The module's type. + */ + public static <M extends UHModule> void ifLoaded(final Class<M> moduleClass, Consumer<M> consumer) + { + final M module = module(moduleClass); + if (module != null) consumer.accept(module); + } + /** * Returns the logger for a given module. This may return null if the module is not * currently loaded. From 2acfb389d3b839aa0e28cad701316edb120ae36e Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Fri, 25 Jan 2019 12:35:32 +0100 Subject: [PATCH 66/91] Added alliances to the report. --- .../scenarii/alliances/AllianceRequest.java | 54 +++++++++++++++++++ .../scenarii/alliances/AlliancesModule.java | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java index ef880be..b178da9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java @@ -34,6 +34,7 @@ package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; +import eu.carrade.amaury.UHCReloaded.modules.external.hawk.HawkModule; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.UHSound; @@ -44,6 +45,7 @@ import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; +import me.cassayre.florian.hawk.report.ReportEvent; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -437,6 +439,58 @@ private void applyApprovedRequest() .collect(Collectors.toSet()) ) ); + + + // Also in the timeline + + UR.ifLoaded(HawkModule.class, hawk -> { + if (allianceTeam.size() == 2) + { + final Iterator<OfflinePlayer> players = allianceTeam.getPlayers().iterator(); + + hawk.getReport().record(ReportEvent.withIcon( + I.t("A new alliance is founded!"), + I.t("Between {0} and {1}", players.next().getName(), players.next().getName()), + "block-structure-block-data" + )); + } + else + { + @SuppressWarnings("OptionalGetWithoutIsPresent") + final OfflinePlayer joiningPlayer = requestedTeam.size() == 1 ? requestedTeam.getPlayers().stream().findFirst().get() : requesterTeam.getPlayers().stream().findFirst().get(); + + final List<String> playersNames = allianceTeam.getPlayers().stream().filter(player -> !player.equals(joiningPlayer)).map(OfflinePlayer::getName).collect(Collectors.toList()); + final int size = playersNames.size(); + + final StringBuilder sentence = new StringBuilder(size * 16); + + for (int i = 0; i < size; i++) + { + sentence.append(playersNames.get(i)); + + if (i == size - 2) + { + sentence.append(" ").append(I.t("and")).append(" "); + } + else if (i != size - 1) + { + sentence.append(", "); + } + } + + hawk.getReport().record(ReportEvent.withIcon( + I.t("The alliance is growing!"), + I.t("{0} joins {1}", joiningPlayer.getName(), sentence), + "block-structure-block" + )); + } + + allianceTeam.getPlayers().forEach(player -> hawk.getReport().getPlayer(player).setTagLine( + I.t("Allied"), + null, + I.t("Players in the (latest) alliance: {0}", String.join(", ", allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet()))) + )); + }); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java index 00495f7..3d019c6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java @@ -234,7 +234,7 @@ public int allianceSize(final ZTeam team) * everyone in solo. */ @EventHandler (priority = EventPriority.LOWEST) - public void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) + private void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) { final SpectatorsModule spectators = UR.module(SpectatorsModule.class); From 5cd3b418f209051c7f3d7904ffb77255ef448a18 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sun, 27 Jan 2019 14:29:05 +0100 Subject: [PATCH 67/91] Added Creatures Spawn Control module. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added a module to patch the server's creatures spawn rules from a simple configuration file. --- .../UHCReloaded/core/ModulesManager.java | 12 +- .../core/game/submanagers/GameBeginning.java | 11 +- .../modules/worldgen/creatures/Config.java | 52 ++ .../worldgen/creatures/CreaturesModule.java | 548 ++++++++++++++++++ .../modules/world-generation-creatures.yml | 115 ++++ 5 files changed, 729 insertions(+), 9 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java create mode 100644 src/main/resources/modules/world-generation-creatures.yml diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java index 059ab8a..9c99c34 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java @@ -40,6 +40,7 @@ import eu.carrade.amaury.UHCReloaded.modules.end.kick.KickModule; import eu.carrade.amaury.UHCReloaded.modules.other.PomfModule; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures.CreaturesModule; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; import fr.zcraft.zlib.components.commands.Command; @@ -69,13 +70,18 @@ public class ModulesManager extends ZLibComponent implements Listener private final static String MODULES_PACKAGE = "eu.carrade.amaury.UHCReloaded.modules"; /** - * These built-in modules will not be enabled by default. It includes all scenarii, so the default game - * is a standard one, and the kick module, as spectators are better for most admins. + * These built-in modules will not be enabled by default. It includes all scenarii and world generation modules, + * so the default game is a standard one, and the kick module, as spectators are better for most admins. */ private final static List<Class<? extends UHModule>> DISABLED_BY_DEFAULT = Arrays.asList( KickModule.class, PomfModule.class, - AlliancesModule.class + + // Scenarii + AlliancesModule.class, + + // World generation + CreaturesModule.class ); /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index 4955284..a621758 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -34,7 +34,6 @@ package eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers; import eu.carrade.amaury.UHCReloaded.modules.core.game.Config; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; @@ -68,7 +67,7 @@ public class GameBeginning extends ZLibComponent implements Listener @EventHandler(priority = EventPriority.LOWEST) - public void onGameStarts(GamePhaseChangedEvent ev) + private void onGameStarts(GamePhaseChangedEvent ev) { if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; @@ -89,7 +88,7 @@ public void onGameStarts(GamePhaseChangedEvent ev) I.t("{green}All damages are disabled"), second -> I.tn("{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", (int) second), I.t("{yellow}{bold}Ended! {yellow}You are now vulnerable..."), - () -> UR.module(GameModule.class).getAliveConnectedPlayers(), + () -> UR.game().getAliveConnectedPlayers(), () -> { inGracePeriod = false; @@ -114,7 +113,7 @@ public void onGameStarts(GamePhaseChangedEvent ev) second -> I.tn("{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", (int) second), I.t("{yellow}{bold}Now allowed! {yellow}Beware..."), (short) 10, - () -> UR.module(GameModule.class).getAliveConnectedPlayers(), + () -> UR.game().getAliveConnectedPlayers(), () -> { setPVP(true); Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); @@ -140,7 +139,7 @@ public void onGameStarts(GamePhaseChangedEvent ev) * Used to disable all damages if the game is not started. */ @EventHandler - public void onEntityDamage(final EntityDamageEvent ev) + private void onEntityDamage(final EntityDamageEvent ev) { if (ev.getEntity() instanceof Player && inGracePeriod) { @@ -152,7 +151,7 @@ public void onEntityDamage(final EntityDamageEvent ev) * Used to cancel the spawn of hostile entities on the surface only, at the beginning of the game. */ @EventHandler - public void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) + private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) { if (inMobsFreePeriod && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) && EntitiesUtils.isHostile(ev.getEntityType())) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java new file mode 100644 index 0000000..3d751db --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java @@ -0,0 +1,52 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures; + +import fr.zcraft.zlib.components.configuration.ConfigurationInstance; +import fr.zcraft.zlib.components.configuration.ConfigurationList; + +import java.io.File; +import java.util.Map; + +import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; + +public class Config extends ConfigurationInstance +{ + public Config(File file) + { + super(file); + } + + public static final ConfigurationList<Map> SPAWN_RULES = list("spawn_rules", Map.class); +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java new file mode 100644 index 0000000..a23e09c --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java @@ -0,0 +1,548 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import fr.zcraft.zlib.components.configuration.ConfigurationParseException; +import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; +import fr.zcraft.zlib.exceptions.IncompatibleMinecraftVersionException; +import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.zlib.tools.reflection.Reflection; +import org.bukkit.Material; +import org.bukkit.block.Biome; +import org.bukkit.entity.EntityType; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; + +@ModuleInfo ( + name = "Creatures Spawn Control", + description = "Alters creatures spawn rules for all or some biomes. " + + "This include disabling spawn of some creatures completely.\n\n" + + "For best results, enable before generating the worlds.", + when = ModuleLoadTime.STARTUP, + category = ModuleCategory.WORLD_GENERATION, + icon = Material.MOB_SPAWNER, + settings = Config.class +) +public class CreaturesModule extends UHModule +{ + /** + * {@code true} if successfully hooked into NMS. + */ + private static boolean hooked; + + private static Class<?> WEIGHTED_RANDOM_CHOICE_CLASS; + private static Class<?> CREATURE_TYPE_ENUM; + + private static Field CREATURE_TYPE_ENUM_CLASS_FIELD; + private static Constructor<?> BIOME_META_CONSTRUCTOR; + + /** + * Map {@link EntityType} -> {@code Class<? extends net.minecraft.server.Entity>} + */ + private final static Map<EntityType, Class<?>> NMS_ENTITY_CLASSES = new HashMap<>(); + + /** + * Map {@link EntityType} -> {@code net.minecraft.server.EntityTypes} + */ + private final static Map<EntityType, Object> NMS_ENTITY_TYPES = new HashMap<>(); + + /** + * Map {@link Biome} -> {@code net.minecraft.server.BiomeBase} + */ + private final static Map<Biome, Object> NMS_BIOMES = new HashMap<>(); + + + static + { + try + { + final Class<?> ENTITY_TYPES_CLASS = Reflection.getMinecraftClassByName("EntityTypes"); + final Class<?> BIOME_BASE_BIOME_META_CLASS = Reflection.getMinecraftClassByName("BiomeBase$BiomeMeta"); + + WEIGHTED_RANDOM_CHOICE_CLASS = Reflection.getMinecraftClassByName("WeightedRandom$WeightedRandomChoice"); + CREATURE_TYPE_ENUM = Reflection.getMinecraftClassByName("EnumCreatureType"); + + CREATURE_TYPE_ENUM_CLASS_FIELD = Arrays.stream(CREATURE_TYPE_ENUM.getDeclaredFields()) + .filter(field -> field.getType().equals(Class.class)).findFirst() + .orElseThrow(() -> new IncompatibleMinecraftVersionException(new Exception("Cannot find the field containing the super class in EnumCreatureType"))); + + CREATURE_TYPE_ENUM_CLASS_FIELD.setAccessible(true); + + try + { + BIOME_META_CONSTRUCTOR = BIOME_BASE_BIOME_META_CLASS.getConstructor(Class.class, int.class, int.class, int.class); + } + catch (final NoSuchMethodException | SecurityException e) + { + BIOME_META_CONSTRUCTOR = BIOME_BASE_BIOME_META_CLASS.getConstructor(ENTITY_TYPES_CLASS, int.class, int.class, int.class); + } + + BIOME_META_CONSTRUCTOR.setAccessible(true); + + // We build the two above maps to access the classes & types faster in all patches. + // We first loop over `EntityTypes` fields to detect the version we have. + + EntityTypesClassVersion version = null; + boolean hadMaps = false; + + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) + { + if (field.getType().equals(ENTITY_TYPES_CLASS)) + { + version = EntityTypesClassVersion.STATIC_ATTRIBUTES; + break; + } + else if (field.getType().getSimpleName().equals("RegistryMaterials")) + { + version = EntityTypesClassVersion.MINECRAFT_KEYS; + break; + } + else if (Map.class.isAssignableFrom(field.getType())) + { + hadMaps = true; + } + } + + if (version == null && hadMaps) version = EntityTypesClassVersion.MAPS; + if (version == null) throw new IncompatibleMinecraftVersionException(new Exception("EntityTypes class version unsupported")); + + switch (version) + { + // FIXME UNTESTED + case MAPS: + // We loop over all maps to check the values inside. + // We want to find the map String -> Class<? extends net.minecraft.server.Entity> + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) + { + if (!Map.class.isAssignableFrom(field.getType())) continue; + field.setAccessible(true); + + final Map<?, ?> map = (Map) field.get(null); + final Map.Entry entry = map.entrySet().stream().findFirst().orElse(null); + + if (entry == null) continue; + + if (entry.getKey().getClass().equals(String.class) && entry.getValue().getClass().equals(Class.class)) + { + // We found the one, let's save all of this. + // We can't extract EntityTypes for this version because the instances doesn't even exist, + // and we don't need them anyway. + final Map<String, Class<?>> keyToClass = (Map<String, Class<?>>) map; + + for (final EntityType entityType : EntityType.values()) + { + final String name = (String) Reflection.getFieldValue(entityType, "name"); + if (name == null) continue; + NMS_ENTITY_CLASSES.put(entityType, keyToClass.get(name)); + } + + break; + } + } + break; + + case MINECRAFT_KEYS: + // Here we can load this class + final Class<?> REGISTRY_CLASS = Reflection.getMinecraftClassByName("RegistryMaterials"); + final Method REGISTRY_METHOD_GET = REGISTRY_CLASS.getDeclaredMethod("get", Object.class); + final Class<?> MINECRAFT_KEY_CLASS = Reflection.getMinecraftClassByName("MinecraftKey"); + + Object registry = null; + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) + { + if (field.getType().equals(REGISTRY_CLASS)) + { + registry = field.get(null); + break; + } + } + + // Should be impossible + if (registry == null) + { + throw new IncompatibleMinecraftVersionException(new NoSuchFieldException("Cannot retrieve the EntityTypes registry.")); + } + + for (final EntityType entityType : EntityType.values()) + { + // We can't extract EntityTypes for this version because the instances doesn't even exist, + // and we don't need them anyway. + final String name = (String) Reflection.getFieldValue(entityType, "name"); + if (name == null) continue; + + NMS_ENTITY_CLASSES.put(entityType, (Class<?>) REGISTRY_METHOD_GET.invoke(registry, Reflection.instantiate(MINECRAFT_KEY_CLASS, name))); + } + + break; + + // FIXME UNTESTED (can only be tested with 1.13 support) + case STATIC_ATTRIBUTES: + // Intermediate map key -> bukkit entity type + final Map<String, EntityType> BY_KEY = Arrays.stream(EntityType.values()) + .map(entityType -> { + try + { + return new AbstractMap.SimpleEntry<>((String) Reflection.getFieldValue(entityType, "name"), entityType); + } + catch (NoSuchFieldException | IllegalAccessException e) + { + return null; + } + }) + .filter(Objects::nonNull) + .filter(entry -> entry.getKey() != null) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + for (Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) + { + if (!field.getType().equals(ENTITY_TYPES_CLASS)) continue; + + final Object type = field.get(null); + final String key = (String) Reflection.call(type, "d"); // Returns the key (String) + final Class<?> clazz = (Class<?>) Reflection.call(type, "c"); // Returns the class (Class<? extends Entity>) + + final EntityType bukkitType = BY_KEY.get(key); + if (bukkitType == null) continue; + + NMS_ENTITY_CLASSES.put(bukkitType, clazz); + NMS_ENTITY_TYPES.put(bukkitType, type); + } + + break; + } + + // We also build a map from Bukkit's to NMS' biomes. + final Class<?> CRAFT_BLOCK_CLASS = Reflection.getBukkitClassByName("block.CraftBlock"); + + for (final Biome biome : Biome.values()) + { + NMS_BIOMES.put(biome, Reflection.call(CRAFT_BLOCK_CLASS, "biomeToBiomeBase", biome)); + } + + hooked = true; + } + catch (final Exception e) + { + PluginLogger.error("Unable to hook into NMS to patch creatures spawn.", e); + hooked = false; + } + } + + @Override + protected void onEnable() + { + for (final Map rule : Config.SPAWN_RULES) + { + try + { + if (!rule.containsKey("entity")) + { + log().warning("Skipping spawn rule without entity."); + continue; + } + + final EntityType entity = ConfigurationValueHandlers.handleValue(rule.get("entity"), EntityType.class); + + final int weight = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("weight", -1)); + final int minPackSize = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("minimal_pack_size", -1)); + final int maxPackSize = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("maximal_pack_size", -1)); + + final Biome[] biomes; + final boolean onlyIfPresent; + + if (!rule.containsKey("biomes")) + { + biomes = null; + onlyIfPresent = true; + } + else + { + final Object rawBiomes = rule.get("biomes"); + + if (rawBiomes instanceof String && ((String) rawBiomes).trim().equalsIgnoreCase("ALL")) + { + biomes = null; + onlyIfPresent = false; + } + else if (rawBiomes instanceof List) + { + final List<Biome> biomesList = new ArrayList<>(((List) rawBiomes).size()); + + for (final Object biome : ((List) rawBiomes)) + { + try + { + biomesList.add(ConfigurationValueHandlers.handleValue(biome, Biome.class)); + } + catch (ConfigurationParseException e) + { + log().warning("Ignoring unknown biome {0} in spawn rules.", e.getValue()); + } + } + + biomes = biomesList.toArray(new Biome[0]); + onlyIfPresent = false; + } + else + { + log().warning("Invalid `biomes` key in spawn rule (neither a string nor a list); ignoring."); + + biomes = null; + onlyIfPresent = true; + } + } + + patchAnimalsSpawn(entity, weight, minPackSize, maxPackSize, onlyIfPresent, biomes); + } + catch (ConfigurationParseException e) + { + log().warning("Invalid spawn rule, skipping. {0} (erroneous value: {1}).", e.getMessage(), e.getValue()); + } + } + } + + /* + CREATURES SPAWN PATCH METHOD + + 1. final BiomeBase base = CraftBlock.biomeToBiomeBase(bukkitBiome); + 2. final Entity entity = craftEntity.getHandle(); + 3. loop EnumCreatureType, check if entity type.a() is subclass of entity + 3b. If given EntityType, + 4. if so, we have ctype = the type + 5. List<BiomeBase.BiomeMeta> metas = base.getMobs(ctype); + 6. Loop over metas to find in meta.b: if it's a class, the entity class; if it's a `EntityTypes` (1.13+), a type + 6b. if it's type, check the class with etypes.c() + 7. If good type found in the biome base metas, update the instance. + meta.a = weight + meta.c = spawnPackMin + meta.d = spawnPackMax + (meta.b = type or class) + 8. If not found, create the instance and att it to the list. Constructors: + 8a. BiomeMeta(Class<? extends Entity> entityClass, int weight, int spawnPackMin, int spawnPackMax); + 8b. BiomeMeta(EntityTypes entityType, int weight, int spawnPackMin, int spawnPackMax); + In this case, loop over static fields of type `EntityTypes` in `EntityTypes` and check their `c()` method + to get the class and compare it (maybe add this into a cache class -> type). + */ + + /** + * Patches the Minecraft Server to update spawning rules for the given entity, in all biomes where the given entity + * already spawn. + * + * If integer values (weight, min & max) are negative, their values will be left untouched (excepted if a new rule + * is created from scratch if {@code onlyIfPresent = false}, then 1 will be used for all of them). + * + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the + * minimal size of these spawn groups. + * During natural generation, entities are spawned alone, and these parameters are ignored. + * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). + */ + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax) + { + patchAnimalsSpawn(entity, weight, spawnPackMin, spawnPackMax, true, (Biome[]) null); + } + + /** + * Patches the Minecraft Server to update spawning rules for the given entity, in all biomes. + * + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the + * minimal size of these spawn groups. + * During natural generation, entities are spawned alone, and these parameters are ignored. + * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). + * @param onlyIfPresent If true, the entity spawning rule will only be altered if the creature spawns in the biome. + * Else, if the creature doesn't already spawn in the given biome, it will be added to the + * biome's entities. This is especially useful for all-biomes alterations. + */ + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax, final boolean onlyIfPresent) + { + patchAnimalsSpawn(entity, weight, spawnPackMin, spawnPackMax, onlyIfPresent, (Biome[]) null); + } + + /** + * Patches the Minecraft Server to update spawning rules for the given entity, in the given biome(s). + * + * If integer values (weight, min & max) are negative, their values will be left untouched (excepted if a new rule + * is created from scratch if {@code onlyIfPresent = false}, then 1 will be used for all of them). + * + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the + * minimal size of these spawn groups. + * During natural generation, entities are spawned alone, and these parameters are ignored. + * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). + * @param onlyIfPresent If true, the entity spawning rule will only be altered if the creature spawns in the biome. + * Else, if the creature doesn't already spawn in the given biome, it will be added to the + * biome's entities. This is especially useful for all-biomes alterations. + * @param biomes The biomes to alter. Spawning rules are specific to biomes and only these biomes will be patched. + * If {@code null} or empty, all biomes will be patched. + */ + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax, final boolean onlyIfPresent, final Biome... biomes) + { + if (!hooked) return; // Incompatible Minecraft version + + final Class<?> nmsEntityClass = NMS_ENTITY_CLASSES.get(entity); + final Object nmsEntityType = NMS_ENTITY_TYPES.get(entity); + + if (nmsEntityClass == null) return; // Unsupported entity + + final Enum creatureType = getCreatureType(nmsEntityClass); + if (creatureType == null) return; // Non-naturally-spawnable entity + + final Biome[] patchedBiomes = biomes != null && biomes.length > 0 ? biomes : Biome.values(); + + for (final Biome biome : patchedBiomes) + { + final Object base = NMS_BIOMES.get(biome); + if (base == null) continue; + + try + { + final List<Object> metas = (List<Object>) Reflection.call(base, "getMobs", creatureType); + boolean found = false; + + for (final Object meta : metas) + { + final Object entityClassOrType = Reflection.getFieldValue(meta, "b"); + if (!Objects.equals(entityClassOrType, nmsEntityClass) && !Objects.equals(entityClassOrType, nmsEntityType)) continue; // Not the meta we're looking for + + if (weight >= 0) Reflection.setFieldValue(WEIGHTED_RANDOM_CHOICE_CLASS, meta, "a", weight); + if (spawnPackMin >= 0) Reflection.setFieldValue(meta, "c", spawnPackMin); + if (spawnPackMax >= 0) Reflection.setFieldValue(meta, "d", spawnPackMax); + + found = true; + } + + // If the entity meta was not present and we want it to be added in this case + if (!found && !onlyIfPresent) + { + Object meta; + + try + { + meta = BIOME_META_CONSTRUCTOR.newInstance( + nmsEntityClass, + weight >= 0 ? weight : 1, + spawnPackMin >= 0 ? spawnPackMin : 1, + spawnPackMax >= 0 ? spawnPackMax : 1 + ); + } + catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e) + { + try + { + + if (nmsEntityType == null) + { + throw new IncompatibleMinecraftVersionException(new Exception("Unknown entity type for " + entity)); + } + + meta = BIOME_META_CONSTRUCTOR.newInstance(nmsEntityType, weight, spawnPackMin, spawnPackMax); + } + catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e1) + { + log().warning("Unable to construct a new BiomeBase.BiomeMeta (tested two constructors). Nag UHCReloaded authors about this.", e1); + log().warning("Previous exception was:", e); + continue; + } + } + + metas.add(meta); + } + } + catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) + { + log().error("Unable to patch entities spawn rules for entity {0} and biome {1}", e, entity, biome); + } + } + } + + private Enum getCreatureType(final Class<?> nmsEntityClass) + { + try + { + for (final Object creatureType : CREATURE_TYPE_ENUM.getEnumConstants()) + { + final Class<?> clazz = (Class<?>) CREATURE_TYPE_ENUM_CLASS_FIELD.get(creatureType); + if (clazz.isAssignableFrom(nmsEntityClass)) return (Enum) creatureType; + } + + return null; + } + catch (IllegalAccessException e) + { + return null; + } + } + + + /** + * Represents the version of the class storing the entity types, used to access + * the NMS' entity base class from a Bukkit's EntityType. + */ + private enum EntityTypesClassVersion + { + /** + * Entity types stored in maps in the `EntityTypes` class. + * Covers 1.8 -> 1.10. + */ + MAPS, + + /** + * Entity types stored in a registry in `EntityTypes`. + * Covers 1.11 -> 1.12. + */ + MINECRAFT_KEYS, + + /** + * Entity types stored as static attributes of `EntityTypes`. + * Covers 1.13+. + */ + STATIC_ATTRIBUTES + } +} diff --git a/src/main/resources/modules/world-generation-creatures.yml b/src/main/resources/modules/world-generation-creatures.yml new file mode 100644 index 0000000..8ccf9c9 --- /dev/null +++ b/src/main/resources/modules/world-generation-creatures.yml @@ -0,0 +1,115 @@ +# +# This module tweaks the creatures spawn in the worlds (any creature; any biome). +# You can increase, decrease or even remove completely an entity to/from a specific or all biomes. +# +# This mainly act on **chunk generation** (it is also effective for natural spawns to refill the world +# with new creatures, but way less). It works by patching the Minecraft Biomes registry to update the +# spawning rules. So, you should generate (using WorldBorder and its fill command, for example) the world with this +# plugin running and this module enabled, for best results. +# +# To enable ths module at startup, add it into the main `config.yml` file, like so: +# +# modules: +# "worldgen.creatures": true +# +# +# +# Each spawning rule have these properties. Except if specified, unset properties will be left as-is. +# +# - The entity, obviously. +# The list is available here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html +# +# - The weight of the entity in the biome. +# The higher the weight is, the likelier the mob is to be selected when the server looks for a mob to spawn (in all +# cases). If set to 0, the entity will not spawn at all. +# +# - The minimal pack size. +# While generating the chunks (and only while generating the chunks), the server will spawn entities in groups; this +# is the minimal size of such groups. +# +# - The maximal pack size. +# Same, but it's the max. +# +# - The biomes where this rule is active. +# If you precise nothing at all about the biomes (only the previous properties), the rule will be updated for +# all biomes already having a rule for the given entity (so the entity will not spawn in *new* biomes). +# +# If you want the rule to be applied to *all* biomes, add `biomes: ALL`. This will tell Minecraft to spawn the +# entity in all biomes, including these where the entity does not spawn in vanilla. This includes the Nether and the +# End. In this example, Mushroom Cows will rarely spawn in all biomes (not only Mushroom Islands). +# +# spawn_rules: +# - entity: MUSHROOM_COW +# weight: 1 +# biomes: ALL +# +# If you want to apply this rule to some specific biomes (leaving rules for this entity in other biomes untouched, +# list the biomes in a `biomes` key, like in the following example. This example will tell Minecraft to spawn +# blazes with a very, very high weight in deserts & savannas (including plateaux). +# +# spawn_rules: +# - entity: BLAZE +# weight: 250 # This would basically mean “blazes everywhere” (in the biomes below, at least) +# biomes: +# - DESERT +# - SAVANNA +# - SAVANNA_PLATEAU +# +# The biomes' list is available here: https://gist.github.com/AmauryCarrade/667ada6cbba41b3c3475217247ab9715 +# +# +# +# The default spawn rules below are a bit heavier for passive useful creature in typical survival games. Feel free to +# alter them to your preferences, of course. +# +# This module alters the spawning rules when enabled **for the whole server lifetime**. Even if disabled, the rules will +# still be there. If the server is rebooted without this module, the rules will be reset to Minecraft default. +# +# If you remove all spawn rules, the behavior will be vanilla. +# +# In case of conflicts (i.e. multiples rules for the same entity and the same biome), the last rule in the list wins. +# +# As a finale note, please remember that entities will still spawn according to their environmental rules. As example, +# cows spawn on grass. This imply that some rules may not work as you intended. As example, if you configure rabbits +# to spawn in the Nether, the rule will be saved into the Minecraft server, but you'll never see any rabbit in there, +# because there is no grass or sand in the Nether. +# + +spawn_rules: + - entity: SHEEP + weight: 15 + minimal_pack_size: 3 + maximal_pack_size: 8 + + - entity: RABBIT + weight: 4 + minimal_pack_size: 2 + maximal_pack_size: 5 + + - entity: PIG + weight: 15 + minimal_pack_size: 6 + maximal_pack_size: 14 + + - entity: CHICKEN + weight: 18 + minimal_pack_size: 8 + maximal_pack_size: 16 + + - entity: COW + weight: 18 + minimal_pack_size: 5 + maximal_pack_size: 12 + + - entity: WOLF + weight: 5 + minimal_pack_size: 1 + maximal_pack_size: 6 + + - entity: HORSE + weight: 5 + minimal_pack_size: 2 + maximal_pack_size: 8 + + - entity: OCELOT + weight: 5 From d7310e105ff909a67ba6d391c2a72873c8c020d4 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 28 Jan 2019 12:34:25 +0100 Subject: [PATCH 68/91] =?UTF-8?q?B=C3=AAta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amaury/UHCReloaded/modules/other/about/AboutModule.java | 2 ++ src/main/resources/modules/world-generation-creatures.yml | 2 +- src/main/resources/plugin.yml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java index b75c5a9..eb3618a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java @@ -239,6 +239,8 @@ private void computeVersion() stability = Stability.STABLE; } } + + else stability = Stability.STABLE; } public enum Stability diff --git a/src/main/resources/modules/world-generation-creatures.yml b/src/main/resources/modules/world-generation-creatures.yml index 8ccf9c9..01dc701 100644 --- a/src/main/resources/modules/world-generation-creatures.yml +++ b/src/main/resources/modules/world-generation-creatures.yml @@ -21,7 +21,7 @@ # # - The weight of the entity in the biome. # The higher the weight is, the likelier the mob is to be selected when the server looks for a mob to spawn (in all -# cases). If set to 0, the entity will not spawn at all. +# cases). If set to 0, the entity will not spawn at all from natural spawning. # # - The minimal pack size. # While generating the chunks (and only while generating the chunks), the server will spawn entities in groups; this diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ee66354..c5bd683 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: UHPlugin description: UltraHardcore Reloaded main: eu.carrade.amaury.UHCReloaded.UHCReloaded load: STARTUP -version: 2.0-alpha +version: 2.0-beta author: "Amaury Carrade" authors: [azenet, "João Roda"] From 157117bfa11931b1f4fde949ca62f8c981214b7a Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 28 Jan 2019 13:42:17 +0100 Subject: [PATCH 69/91] Fixed/improved compass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Moved errors and status messages to action bar. When the message indicate a distance, because the player may want to remember it (and because another plugin or module might be using the action bar at the same time), we display that in the chat. Else, in the action bar. → Fixed formattings. → The vanilla recipe is disabled when the recipe is not DEFAULT. --- .../gameplay/compass/CompassModule.java | 211 ++++++++++-------- .../gameplay/compass/CompassRecipes.java | 21 ++ .../amaury/UHCReloaded/utils/UHUtils.java | 16 ++ .../resources/modules/gameplay-compass.yml | 20 +- 4 files changed, 166 insertions(+), 102 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java index 660ad71..4b4d010 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java @@ -42,17 +42,20 @@ import eu.carrade.amaury.UHCReloaded.utils.UHSound; import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.zlib.components.i18n.I18n; import fr.zcraft.zlib.components.rawtext.RawText; import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.RawMessage; +import fr.zcraft.zlib.tools.text.MessageSender; import fr.zcraft.zteams.ZTeams; import org.apache.commons.lang.math.RandomUtils; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -94,138 +97,158 @@ protected void onDisable() /** * Used to update the compass. */ - @EventHandler (ignoreCancelled = true) + @EventHandler (priority = EventPriority.LOWEST) public void onPlayerInteract(final PlayerInteractEvent ev) { - if (compassLocked.contains(ev.getPlayer().getUniqueId())) return; - else + if (ev.getAction() != Action.PHYSICAL) { - compassLocked.add(ev.getPlayer().getUniqueId()); - RunTask.later(() -> compassLocked.remove(ev.getPlayer().getUniqueId()), 20L); + ev.setCancelled(activateCompass(ev.getPlayer())); } + } - if ((ev.getAction() == Action.RIGHT_CLICK_AIR || ev.getAction() == Action.RIGHT_CLICK_BLOCK) - && ev.getPlayer().getItemInHand().getType() == Material.COMPASS - && UR.module(GameModule.class).isAlive(ev.getPlayer())) - { - final Player compassUser = ev.getPlayer(); + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev) + { + ev.setCancelled(activateCompass(ev.getPlayer())); + } - // We check if the player have what needed + /** + * Activates the compass for the player. + * + * @param compassUser The player. + * @return {@code true} if the compass was activated. + */ + private boolean activateCompass(final Player compassUser) + { + if (!UR.game().isAlive(compassUser) || compassUser.getItemInHand().getType() != Material.COMPASS) return false; + if (compassLocked.contains(compassUser.getUniqueId())) return false; - int feeAvailable = Arrays.stream(compassUser.getInventory().getContents()) - .filter(item -> item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) - .mapToInt(ItemStack::getAmount) - .sum(); + compassLocked.add(compassUser.getUniqueId()); + RunTask.later(() -> compassLocked.remove(compassUser.getUniqueId()), 10L); - if (feeAvailable < Config.COMPASS_FEE_AMOUNT.get()) - { - RawMessage.send(compassUser, new RawText(I.t("To use the compass, you must have the following: ")) - .then().translate(new ItemStack(Config.COMPASS_FEE_ITEM.get(), Config.COMPASS_FEE_AMOUNT.get())) - .then(Config.COMPASS_FEE_AMOUNT.get() > 1 ? " × " + Config.COMPASS_FEE_AMOUNT.get() + "." : ".") - .build() - ); - new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); - return; - } + final Locale locale = I18n.getPlayerLocale(compassUser); - // We consume the fee + // We check if the player have what needed - int feeLeft = Config.COMPASS_FEE_AMOUNT.get(); + int feeAvailable = Arrays.stream(compassUser.getInventory().getContents()) + .filter(item -> item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) + .mapToInt(ItemStack::getAmount) + .sum(); - for (final ItemStack item : compassUser.getInventory().getContents()) - { - if (item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) - { - final int consumed = item.getAmount() - feeLeft; + if (feeAvailable < Config.COMPASS_FEE_AMOUNT.get()) + { + MessageSender.sendActionBarMessage(compassUser, new RawText() + /// The singular is in the sentence « To use the compass, you must have one rotten flesh ». The plural: « […] you must have Rotten Flesh × 2 »? + .then(I.tln(locale, "To use the compass, you must have one ", "To use the compass, you must have ", Config.COMPASS_FEE_AMOUNT.get())).color(ChatColor.RED) + .then().translate(new ItemStack(Config.COMPASS_FEE_ITEM.get(), Config.COMPASS_FEE_AMOUNT.get())).color(ChatColor.RED) + .then(Config.COMPASS_FEE_AMOUNT.get() > 1 ? " × " + Config.COMPASS_FEE_AMOUNT.get() : "").color(ChatColor.RED) + .then(".").color(ChatColor.RED) + .build() + ); + new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + return false; + } - if (consumed <= 0) - { - feeLeft -= item.getAmount(); - item.setAmount(0); - item.setType(Material.AIR); - } - else - { - feeLeft = 0; - item.setAmount(consumed); - } + // We consume the fee - if (feeLeft == 0) break; + int feeLeft = Config.COMPASS_FEE_AMOUNT.get(); + + for (final ItemStack item : compassUser.getInventory().getContents()) + { + if (item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) + { + final int consumed = item.getAmount() - feeLeft; + + if (consumed <= 0) + { + feeLeft -= item.getAmount(); + item.setAmount(0); + item.setType(Material.AIR); + } + else + { + feeLeft = 0; + item.setAmount(consumed); } + + if (feeLeft == 0) break; } + } - // We lookup for the nearest player + // We lookup for the nearest player - Player nearest = null; - Double distance = Double.MAX_VALUE; + Player nearest = null; + Double distance = Double.MAX_VALUE; - for (Player otherPlayer : UR.module(GameModule.class).getAliveConnectedPlayers()) + for (final Player otherPlayer : UR.module(GameModule.class).getAliveConnectedPlayers()) + { + try { - try + Double calc = compassUser.getLocation().distanceSquared(otherPlayer.getLocation()); + + if (calc > 1 && calc < distance) { - Double calc = compassUser.getLocation().distanceSquared(otherPlayer.getLocation()); + distance = calc; - if (calc > 1 && calc < distance) + if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(ZTeams.get().getTeamForPlayer(compassUser), ZTeams.get().getTeamForPlayer(otherPlayer)))) { - distance = calc; - - if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(ZTeams.get().getTeamForPlayer(compassUser), ZTeams.get().getTeamForPlayer(otherPlayer)))) - { - nearest = otherPlayer.getPlayer(); - } + nearest = otherPlayer.getPlayer(); } } - catch (Exception ignored) {} // Different worlds } + catch (Exception ignored) {} // Different worlds + } - if (nearest == null) - { - /// Error message if a player tries to use his pointing compass without a player nearby. - compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("Only silence answers your request."))); // TODO update language files + if (nearest == null) + { + /// Error message if a player tries to use his pointing compass without a player nearby. + MessageSender.sendActionBarMessage(compassUser, UHUtils.prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); // TODO update language files - new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); - return; - } + new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + return false; + } - CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); + CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); - if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) - { - final double r = RandomUtils.nextDouble(); + if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) + { + final double r = RandomUtils.nextDouble(); - if (r < .45) behavior = CompassBehavior.GIVE_DIRECTION; - else if (r < .9) behavior = CompassBehavior.GIVE_DISTANCE; - else behavior = CompassBehavior.GIVE_BOTH; - } + if (r < .45) behavior = CompassBehavior.GIVE_DIRECTION; + else if (r < .9) behavior = CompassBehavior.GIVE_DISTANCE; + else behavior = CompassBehavior.GIVE_BOTH; + } - if (behavior == CompassBehavior.GIVE_BOTH) - { - compassUser.setCompassTarget(nearest.getLocation()); - compassUser.sendMessage(UHUtils.prefixedMessage( - I.t("Compass"), - ChatColor.YELLOW + I.tn( + if (behavior == CompassBehavior.GIVE_BOTH) + { + compassUser.setCompassTarget(nearest.getLocation()); + compassUser.sendMessage(UHUtils.prefixedMessage( + I.tl(locale, "Compass"), + ChatColor.YELLOW + I.tln( + locale, "The compass now points to the closest player, {gold}{0} block {yellow}from you.", "The compass now points to the closest player, {gold}{0} blocks {yellow}from you.", (int) nearest.getLocation().distanceSquared(compassUser.getLocation()) ) - )); - } - - else if (behavior == CompassBehavior.GIVE_DIRECTION) - { - compassUser.setCompassTarget(nearest.getLocation()); + )); + } - /// Success message when a player uses his pointing compass. - compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), ChatColor.YELLOW + I.t("The compass now points to the closest player."))); // TODO update language files - } + else if (behavior == CompassBehavior.GIVE_DIRECTION) + { + compassUser.setCompassTarget(nearest.getLocation()); - else - { - compassUser.sendMessage(UHUtils.prefixedMessage(I.t("Compass"), I.tn("{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); - } + /// Success message when a player uses his pointing compass. + MessageSender.sendActionBarMessage(compassUser, ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "The compass now points to the closest player.")); // TODO update language files + } - new UHSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); + else + { + compassUser.sendMessage(UHUtils.prefixedMessage(I.tl(locale, "Compass"), I.tln(locale, "{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); } + + new UHSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); + + return true; } public enum CompassBehavior diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java index cf164bc..fc11dc1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java @@ -33,7 +33,9 @@ */ package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; +import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; import fr.zcraft.zlib.core.ZLibComponent; +import fr.zcraft.zlib.tools.items.CraftingRecipes; import fr.zcraft.zlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -43,14 +45,24 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; import java.util.ArrayList; public class CompassRecipes extends ZLibComponent implements Listener { + private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( + new ItemStack(Material.COMPASS), + " A ", + "ABA", + " A ", + Material.IRON_INGOT, Material.REDSTONE + ); + /** * Checks if the recipe is a valid compass recipe. * <p> @@ -231,6 +243,15 @@ public void onInventoryDrag(final InventoryDragEvent ev) } } + @EventHandler + private void onPreCraft(final PrepareItemCraftEvent ev) + { + if (Config.RECIPE.get() != CompassRecipe.DEFAULT && ev.getRecipe() != null && RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) + { + ev.getInventory().setResult(new ItemStack(Material.AIR)); + } + } + public enum CompassRecipe { /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java index 7faf635..bbb9305 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java @@ -32,6 +32,8 @@ package eu.carrade.amaury.UHCReloaded.utils; +import fr.zcraft.zlib.components.rawtext.RawText; +import fr.zcraft.zlib.components.rawtext.RawTextPart; import fr.zcraft.zlib.tools.Callback; import fr.zcraft.zlib.tools.PluginLogger; import org.apache.commons.lang.Validate; @@ -462,4 +464,18 @@ public static String prefixedMessage(final String prefix, final String message) { return ChatColor.GREEN + prefix + ChatColor.GRAY + " \u2758 " + ChatColor.RESET + message; } + + /** + * Generates a RawText containing the prefix of a message plus the separator. Just like {@link #prefixedMessage(String, String)}, + * but compatible with RawTexts. + * + * @param prefix The prefix. + * @return The RawText, ready to be extended. + */ + public static RawTextPart prefixedRaxText(final String prefix) + { + return new RawText() + .then(prefix).color(ChatColor.GREEN) + .then(" \u2758 ").color(ChatColor.GRAY); + } } diff --git a/src/main/resources/modules/gameplay-compass.yml b/src/main/resources/modules/gameplay-compass.yml index dbfc1d9..6ab6897 100644 --- a/src/main/resources/modules/gameplay-compass.yml +++ b/src/main/resources/modules/gameplay-compass.yml @@ -1,10 +1,14 @@ +# The recipe can either be the default Minecraft recipe, or a custom special, harder, recipe. +# # The special recipe is with an ingredient in the center, and then, # from the top, clockwise: iron, spider eye, iron, rotten flesh, iron, bone, iron, gunpowder. # This field change the central ingredient. -# "easy": redstone (like the normal compass). -# "medium": ender pearl. -# "hard": eye of ender. -recipe: "medium" +# +# DEFAULT: The vanilla compass recipe, without all these extra things. +# EASY: The center is redstone (like the normal compass). +# MEDIUM: The center is an ender pearl. +# HARD: The center is an eye of ender. +recipe: DEFAULT # This item will be required to be able to use the compass, and for each use # of it. @@ -18,8 +22,8 @@ compass-fee-amount: 1 never-target-teammates: true # The behavior of the compass. -# GIVE_DIRECTION: gives the target's direction by updating the compass. -# GIVE_DISTANCE: Gives the target's distance from the player. -# GIVE_BOTH: gives both the direction and the distance. -# GIVE_EITHER_RANDOMLY: gives either the direction or the distance, randomly, with a small chance of getting both. +# GIVE_DIRECTION: Gives the target's direction by updating the compass. +# GIVE_DISTANCE: Gives the target's distance from the player. +# GIVE_BOTH: Gives both the direction and the distance. +# GIVE_EITHER_RANDOMLY: Gives either the direction or the distance, randomly, with a small chance of getting both. compass-behavior: GIVE_DIRECTION From f5c62d4317fcfbaf281284a5b1eca152b44265c8 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 28 Jan 2019 14:05:24 +0100 Subject: [PATCH 70/91] Onerous Glistering Melon module. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Added module to update glistering melon recipe from gold nuggets to gold ingots. --- .../gameplay/OnerousGlisteringMelon.java | 88 +++++++++++++++++++ .../gameplay/compass/CompassRecipes.java | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java new file mode 100644 index 0000000..74a9906 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java @@ -0,0 +1,88 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ +package eu.carrade.amaury.UHCReloaded.modules.gameplay; + +import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; +import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; +import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; +import fr.zcraft.zlib.tools.items.CraftingRecipes; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; + + +@ModuleInfo ( + name = "Onerous Glistering Melon", + description = "Changes the vanilla recipe for glistering melon, replacing gold nuggets by gold ingots, to make healing potions harder to get.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.SPECKLED_MELON // FIXME 1.13 +) +public class OnerousGlisteringMelon extends UHModule +{ + private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( + new ItemStack(Material.SPECKLED_MELON), + "AAA", + "ABA", + "AAA", + Material.GOLD_NUGGET, Material.MELON // FIXME 1.13 + ); + + private final Recipe ONEROUS_RECIPE = CraftingRecipes.shaped( + new ItemStack(Material.SPECKLED_MELON), + "AAA", + "ABA", + "AAA", + Material.GOLD_INGOT, Material.MELON // FIXME 1.13 + ); + + @Override + protected void onEnable() + { + CraftingRecipes.add(ONEROUS_RECIPE); + } + + @EventHandler + private void onPreCraft(final PrepareItemCraftEvent ev) + { + if (RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) + { + ev.getInventory().setResult(new ItemStack(Material.AIR)); + } + } +} diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java index fc11dc1..cc2a418 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java @@ -246,7 +246,7 @@ public void onInventoryDrag(final InventoryDragEvent ev) @EventHandler private void onPreCraft(final PrepareItemCraftEvent ev) { - if (Config.RECIPE.get() != CompassRecipe.DEFAULT && ev.getRecipe() != null && RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) + if (Config.RECIPE.get() != CompassRecipe.DEFAULT && RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) { ev.getInventory().setResult(new ItemStack(Material.AIR)); } From fcf88fc4039bb4f023799d9d41f77a78ff1562e5 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 28 Jan 2019 14:10:49 +0100 Subject: [PATCH 71/91] More granularity in sidebar priorities. --- .../UHCReloaded/modules/core/border/BorderModule.java | 2 +- .../modules/core/sidebar/SidebarInjector.java | 10 ++++++++++ .../cosmetics/{killsCount => }/KillsCountModule.java | 2 +- .../cosmetics/{listHealth => }/ListHealthModule.java | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/{killsCount => }/KillsCountModule.java (98%) rename src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/{listHealth => }/ListHealthModule.java (98%) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 8d46038..642f96e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -166,7 +166,7 @@ public void prepareInjectionIntoSidebar() public void injectIntoSidebar(Player player, SidebarInjector injector) { if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; - injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, sidebar); + injector.injectLines(SidebarInjector.SidebarPriority.MIDDLE_BOTTOM, true, sidebar); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java index 70879e0..e22d761 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java @@ -317,11 +317,21 @@ public enum SidebarPriority */ TOP, + /** + * Places the lines somewhere between the top and the middle. + */ + MIDDLE_TOP, + /** * Places the lines at the middle, without any strong preferences on placement. */ MIDDLE, + /** + * Places the lines somewhere between the middle and the bottom. + */ + MIDDLE_BOTTOM, + /** * Places the lines on the bottom part of the scoreboard. */ diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java index 41af6d7..c2c809b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/killsCount/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.killsCount; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java rename to src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java index 498798a..6832960 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/listHealth/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.listHealth; +package eu.carrade.amaury.UHCReloaded.modules.cosmetics; import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; From f29f94f43daf7fbdbe842d7e12cd0f9125a673fb Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Mon, 28 Jan 2019 14:36:29 +0100 Subject: [PATCH 72/91] Improved texts & fixed translations from TODOs. --- .../modules/core/border/BorderModule.java | 11 ++--- .../core/border/commands/BorderCommand.java | 9 ++-- .../UHCReloaded/modules/core/game/Config.java | 2 +- .../modules/core/game/GameModule.java | 4 -- .../core/game/submanagers/GameBeginning.java | 6 +-- .../gameplay/compass/CompassModule.java | 4 +- .../goldenHeads/GoldenHeadsModule.java | 8 ++-- .../utilities/freezer/FreezeCommand.java | 9 ++-- src/main/resources/i18n/cs-CZ.po | 30 +++--------- src/main/resources/i18n/fr-FR.po | 47 +++---------------- src/main/resources/i18n/pt-BR.po | 31 +++--------- src/main/resources/i18n/pt-PT.po | 31 +++--------- src/main/resources/i18n/zh-CN.po | 31 +++--------- 13 files changed, 54 insertions(+), 169 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java index 642f96e..50f943d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java @@ -50,10 +50,7 @@ import fr.zcraft.zlib.core.ZLib; import fr.zcraft.zlib.tools.runners.RunTask; import fr.zcraft.zlib.tools.text.Titles; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -336,8 +333,8 @@ private void scheduleBorderReduction() Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); - Bukkit.broadcastMessage(I.t("{red}{bold}The border begins to shrink...")); - Bukkit.broadcastMessage(I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())); + Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.t("{red}{bold}The border begins to shrink..."))); + Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get()))); }, Config.SHRINKING.STARTS_AFTER.get().getSeconds() * 20L); scheduleBorderReductionWarning(new TimeDelta(1, 0, 0)); @@ -354,7 +351,7 @@ private void scheduleBorderReductionWarning(final TimeDelta warnBefore) if (UR.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; Bukkit.broadcastMessage(""); - Bukkit.broadcastMessage(I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60))); + Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60)))); Bukkit.broadcastMessage(""); }, Config.SHRINKING.STARTS_AFTER.get().subtract(warnBefore).getSeconds() * 20L); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java index 543cbc4..88cf573 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java @@ -80,11 +80,10 @@ protected void run() throws CommandException sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); -// TODO WorldBorder plugin -// if (!p.getWorldBorderIntegration().isWBIntegrationEnabled()) -// { -// sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); -// } + if (!UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) + { + sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); + } border.sendCheckMessage(sender, newDiameter); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java index 441d4b9..2e11528 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java @@ -49,7 +49,7 @@ public Config(File file) super(file); } - public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 1); // TODO 12 Recommended: 7 or 12 + public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 7); public static final ConfigurationItem<Boolean> STARTUP_TITLE = item("startup-title", true); public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = item("random-color-in-solo-games", true); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java index bec2bef..384d1ba 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java @@ -602,8 +602,6 @@ public void onGameStarting(final GamePhaseChangedEvent ev) { if (teleportationMode == TeleportationMode.NORMAL && teamsGame) { - // TODO re-add dynmap integration in dedicated module using events. - final Location teamSpawn = unusedSpawnPoints.poll(); // Should never happen @@ -631,8 +629,6 @@ public void onGameStarting(final GamePhaseChangedEvent ev) { team.getPlayersUUID().forEach(player -> { - // TODO re-add dynmap integration in dedicated module using events. - final Location playerSpawn = unusedSpawnPoints.poll(); final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java index a621758..66ce759 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java @@ -86,15 +86,15 @@ private void onGameStarts(GamePhaseChangedEvent ev) Run.withCountdown( I.t("{green}{bold}Grace period"), I.t("{green}All damages are disabled"), - second -> I.tn("{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Ends in {gold}{bold}{0}{yellow}{bold} second", (int) second), - I.t("{yellow}{bold}Ended! {yellow}You are now vulnerable..."), + second -> I.tn("{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", (int) second), + I.t("{yellow}{bold}Over! {yellow}You are now vulnerable..."), () -> UR.game().getAliveConnectedPlayers(), () -> { inGracePeriod = false; if (Config.BEGINNING.BROADCAST_GRACE_END.get()) { - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period ended, you are now vulnerable.")); + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period is over, you are now vulnerable.")); } }, grace diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java index 4b4d010..12adb18 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java @@ -202,7 +202,7 @@ private boolean activateCompass(final Player compassUser) if (nearest == null) { /// Error message if a player tries to use his pointing compass without a player nearby. - MessageSender.sendActionBarMessage(compassUser, UHUtils.prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); // TODO update language files + MessageSender.sendActionBarMessage(compassUser, UHUtils.prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); return false; @@ -238,7 +238,7 @@ else if (behavior == CompassBehavior.GIVE_DIRECTION) compassUser.setCompassTarget(nearest.getLocation()); /// Success message when a player uses his pointing compass. - MessageSender.sendActionBarMessage(compassUser, ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "The compass now points to the closest player.")); // TODO update language files + MessageSender.sendActionBarMessage(compassUser, ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "The compass now points to the closest player.")); } else diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java index a5b2ed7..6bf1bb3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -94,16 +94,16 @@ protected void onEnable() Bukkit.addRecipe(getOldEnchantedGoldenAppleRecipe()); if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); // FIXME Translation + Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); if (Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); // FIXME Translation + Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); if (Config.WITHER_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); // FIXME Translation + Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); if (Config.WITHER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); // FIXME Translation + Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); } private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted, final int amount, final String resultDisplayName) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java index 90136e8..6f89bd8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java @@ -32,6 +32,7 @@ package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.UHCReloaded.utils.UHUtils; import fr.zcraft.zlib.components.commands.Command; import fr.zcraft.zlib.components.commands.CommandException; import fr.zcraft.zlib.components.commands.CommandInfo; @@ -105,12 +106,12 @@ else if (args.length == 2) if (on) { - player.sendMessage(I.t("{cst}You where frozen by {0}.", sender.getName())); + player.sendMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where frozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now frozen.", player.getName())); } else { - player.sendMessage(I.t("{cst}You where unfrozen by {0}.", sender.getName())); + player.sendMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where unfrozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now unfrozen.", player.getName())); } } @@ -126,11 +127,11 @@ else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none Bukkit.broadcastMessage(""); if (on) { - Bukkit.broadcastMessage(I.t("{darkaqua}The entire game is now frozen.")); + Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The entire game is now frozen."))); } else { - Bukkit.broadcastMessage(I.t("{darkaqua}The game is now unfrozen.")); + Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The game is now unfrozen."))); } Bukkit.broadcastMessage(""); } diff --git a/src/main/resources/i18n/cs-CZ.po b/src/main/resources/i18n/cs-CZ.po index e84c473..73f26bc 100644 --- a/src/main/resources/i18n/cs-CZ.po +++ b/src/main/resources/i18n/cs-CZ.po @@ -706,13 +706,13 @@ msgstr "{gray}{italic}Nemas zadne shnile maso (rotten flesh)." #. Error message if a player tries to use his pointing compass without a #. player nearby. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:335 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}Tva zadost zmizela v tichu." +msgid "Only silence answers your request." +msgstr "Tva zadost zmizela v tichu." #. Success message when a player uses his pointing compass. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:342 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}Kompas nyni ukazuje smer k nejblizsimu hraci." +msgid "The compass now points to the closest player." +msgstr "Kompas nyni ukazuje smer k nejblizsimu hraci." #. Dynmap marker label of a death point #: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:152 @@ -749,26 +749,8 @@ msgstr "Vyrobeno z hlavy padleho hrace {0}" #. Item name of a golden head (from a player) #: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:393 msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Zlate jablko" - -#. Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:399 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Zlata hlava" - -#. Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:426 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Zlate jablko" - -#. Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:432 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Zlata hlava" +msgid "Golden head" +msgstr "Zlate jablko" #. Current episode in the sidebar #: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:141 diff --git a/src/main/resources/i18n/fr-FR.po b/src/main/resources/i18n/fr-FR.po index c703376..cf1c3e4 100644 --- a/src/main/resources/i18n/fr-FR.po +++ b/src/main/resources/i18n/fr-FR.po @@ -95,7 +95,7 @@ msgstr "{ce}Veuillez patienter, les équipes sont en train d'être téléportée #: src/main/java/eu/carrade/amaury/UHCReloaded/game/UHGameManager.java:591 #: src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java:100 msgid "" -"{red}{bold}Warning!{white} The grace period ended, you are now vulnerable." +"{red}{bold}Warning!{white} The grace period is over, you are now vulnerable." msgstr "" "{red}{bold}Attention !{white} La période de grâce est terminée ; vous êtes " "désormais vulnérable." @@ -420,27 +420,8 @@ msgstr "Fabriquée depuis la tête tranchée de {0}" #. / Item name of a golden head (from a player) #: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:388 -msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" - -#. / Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:394 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" - -#. / Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:421 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" - -#. / Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/recipes/RecipesManager.java:427 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" +msgid "Golden head" +msgstr "Tête d'or" #: src/main/java/eu/carrade/amaury/UHCReloaded/old/protips/ProTips.java:42 msgctxt "protip" @@ -570,16 +551,6 @@ msgstr "{darkgreen}C'est parti !" msgid "{green}Good luck, and have fun" msgstr "{green}Bonne chance et bon jeu à tous" -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:205 -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:259 -msgid "{aqua}Golden head" -msgstr "{aqua}Tête d'or" - -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:206 -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:260 -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Tête d'or" - #. / Error message if a player tries to use his pointing compass without rotten flesh. #: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:311 msgid "{gray}{italic}You do not have rotten flesh." @@ -587,17 +558,13 @@ msgstr "{gray}{italic}Vous n'avez pas de chair de zombie." #. / Error message if a player tries to use his pointing compass without a player nearby. #: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:342 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}Seul le silence comble votre requête." +msgid "Only silence answers your request." +msgstr "Seul le silence comble votre requête." #. / Success message when a player uses his pointing compass. #: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/GameplayListener.java:349 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}Le compas pointe désormais vers le joueur le plus proche." - -#: src/main/java/eu/carrade/amaury/UHCReloaded/old/listeners/CraftingListener.java:258 -msgid "Golden head" -msgstr "Tête d'or" +msgid "The compass now points to the closest player." +msgstr "La boussole cible désormais le joueur le plus proche." #. / Dynmap marker label of a death point #: src/main/java/eu/carrade/amaury/UHCReloaded/old/integration/UHDynmapIntegration.java:151 diff --git a/src/main/resources/i18n/pt-BR.po b/src/main/resources/i18n/pt-BR.po index 6ae3798..5ab5fe2 100644 --- a/src/main/resources/i18n/pt-BR.po +++ b/src/main/resources/i18n/pt-BR.po @@ -713,13 +713,13 @@ msgstr "{gray}{italic}Para a bússola é necessária carne podre." #. Error message if a player tries to use his pointing compass without a #. player nearby. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:335 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}Nenhum jogador encontrado nas proximidades." +msgid "Only silence answers your request." +msgstr "Nenhum jogador encontrado nas proximidades." #. Success message when a player uses his pointing compass. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:342 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}A bússola está apotando para o jogador mais próximo de você." +msgid "The compass now points to the closest player." +msgstr "A bússola está apotando para o jogador mais próximo de você." #. Dynmap marker label of a death point #: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:152 @@ -755,27 +755,8 @@ msgstr "Feita da cabeça de {0}" #. Item name of a golden head (from a player) #: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:393 -msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Maçã Dourada" - -#. Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:399 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Maçã Dourada" - -#. Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:426 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Maçã Dourada" - -#. Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:432 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Maçã Dourada" +msgid "Golden head" +msgstr "Maçã Dourada" #. Current episode in the sidebar #: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:141 diff --git a/src/main/resources/i18n/pt-PT.po b/src/main/resources/i18n/pt-PT.po index 699ef0e..b814f50 100644 --- a/src/main/resources/i18n/pt-PT.po +++ b/src/main/resources/i18n/pt-PT.po @@ -708,13 +708,13 @@ msgstr "{gray}{italic}Precisas de Carne Podre para utilizares a Bussola." #. Error message if a player tries to use his pointing compass without a #. player nearby. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:335 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}Nao foram encontrados jogadores por perto." +msgid "Only silence answers your request." +msgstr "Nao foram encontrados jogadores por perto." #. Success message when a player uses his pointing compass. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:342 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}A Bussola aponta agora para o jogador mais proximo." +msgid "The compass now points to the closest player." +msgstr "A Bussola aponta agora para o jogador mais proximo." #. Dynmap marker label of a death point #: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:152 @@ -750,27 +750,8 @@ msgstr "Feita da cabeca de {0}" #. Item name of a golden head (from a player) #: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:393 -msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Maca Dourada" - -#. Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:399 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Maca Dourada" - -#. Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:426 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}Maca Dourada" - -#. Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:432 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}Maca Dourada" +msgid "Golden head" +msgstr "Maca Dourada" #. Current episode in the sidebar #: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:141 diff --git a/src/main/resources/i18n/zh-CN.po b/src/main/resources/i18n/zh-CN.po index 6a9ba23..f81ce1c 100644 --- a/src/main/resources/i18n/zh-CN.po +++ b/src/main/resources/i18n/zh-CN.po @@ -684,13 +684,13 @@ msgstr "{gray}{italic}你没有腐肉." #. Error message if a player tries to use his pointing compass without a #. player nearby. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:335 -msgid "{gray}{italic}Only silence answers your request." -msgstr "{gray}{italic}指南针没找到任何特殊事物." +msgid "Only silence answers your request." +msgstr "指南针没找到任何特殊事物." #. Success message when a player uses his pointing compass. #: src/main/java/eu/carrade/amaury/UHCReloaded/listeners/GameplayListener.java:342 -msgid "{gray}The compass now points to the closest player." -msgstr "{gray}指南针正指向离你最近的玩家." +msgid "The compass now points to the closest player." +msgstr "指南针正指向离你最近的玩家." #. Dynmap marker label of a death point #: src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHDynmapIntegration.java:152 @@ -726,27 +726,8 @@ msgstr "用玩家 {0} 掉落的头颅制作" #. Item name of a golden head (from a player) #: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:393 -msgctxt "player_head" -msgid "{aqua}Golden head" -msgstr "{aqua}金苹果(金头颅)" - -#. Item name of an enchanted golden head (from a player) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:399 -msgctxt "player_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}金苹果(金头颅)" - -#. Item name of a golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:426 -msgctxt "monster_head" -msgid "{aqua}Golden head" -msgstr "{aqua}金苹果(金头颅)" - -#. Item name of an enchanted golden head (from a monster) -#: src/main/java/eu/carrade/amaury/UHCReloaded/recipes/RecipesManager.java:432 -msgctxt "monster_head" -msgid "{lightpurple}Golden head" -msgstr "{lightpurple}金苹果(金头颅)" +msgid "Golden head" +msgstr "金苹果(金头颅)" #. Current episode in the sidebar #: src/main/java/eu/carrade/amaury/UHCReloaded/scoreboard/GameSidebar.java:141 From dfd8772b100095b051dc8dfd00879f4eb62c697a Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 31 Jan 2019 17:30:23 +0100 Subject: [PATCH 73/91] Improved Hawk integration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit → Removed teams from report if Alliances Scenario is used. → Write the title of the report just before save/publication, to use the latest title in case of runtime-update. --- .../amaury/UHCReloaded/modules/external/hawk/HawkModule.java | 4 ++-- .../modules/scenarii/alliances/AlliancesModule.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java index 8272b89..4daab51 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java @@ -251,7 +251,7 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { waitingAfterEnd = false; - report.autoTrack(false); + report.autoTrack(false).title(UHConfig.TITLE.get()); report.save( saved -> @@ -482,7 +482,7 @@ else if (!firstApple && item == Material.APPLE) { report.record(ReportEvent.withIcon( I.t("{0} harvested the first apple", player.getName()), - "" + "item-apple" )); firstApple = true; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java index 3d019c6..b1c5c60 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java @@ -41,6 +41,7 @@ import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.UHCReloaded.modules.external.hawk.HawkModule; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.AllianceRequestCommand; import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; import eu.carrade.amaury.UHCReloaded.shortcuts.UR; @@ -95,7 +96,7 @@ protected void onEnable() { game = UR.module(GameModule.class); - // We update some teams settings + // We update some settings eu.carrade.amaury.UHCReloaded.modules.core.game.Config.SIDEBAR.TEAMS.set(false); eu.carrade.amaury.UHCReloaded.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); @@ -109,6 +110,7 @@ protected void onEnable() ) .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_ALLIANCE.get()); + UR.ifLoaded(HawkModule.class, hawk -> hawk.getReport().settings().enableSummary(true, true, false)); // ...And permissions From f1a135722bcc03e77eb5705dd765caf4126b4066 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 25 Nov 2020 14:47:36 +0100 Subject: [PATCH 74/91] Rename from UHCReloaded to Quartz Survival Games --- pom.xml | 32 +- .../QSGConfig.java} | 16 +- .../QuartzSurvivalGames.java} | 66 ++-- .../core/ModuleCategory.java | 6 +- .../core/ModuleInfo.java | 25 +- .../core/ModuleLoadTime.java | 4 +- .../core/ModuleLogger.java | 66 ++-- .../core/ModuleWrapper.java | 297 ++++++++---------- .../core/ModulesManager.java | 58 ++-- .../core/QSGModule.java} | 48 +-- .../core/events/AllModulesLoadedEvent.java | 26 +- .../core/events/ModuleDisabledEvent.java | 29 +- .../core/events/ModuleEnabledEvent.java | 27 +- .../core/events/ModuleLoadedEvent.java | 34 +- .../core/events/ModuleUnloadedEvent.java | 29 +- .../modules/core/border/BorderModule.java | 70 ++--- .../modules/core/border/Config.java | 16 +- .../modules/core/border/MapShape.java | 8 +- .../core/border/WorldBorderDependency.java | 6 +- .../core/border/commands/BorderCommand.java | 24 +- .../border/events/BorderChangedEvent.java | 2 +- .../core/border/shapes/CircularMapShape.java | 2 +- .../border/shapes/MapShapeDescriptor.java | 2 +- .../core/border/shapes/SquaredMapShape.java | 2 +- .../worldborders/BrettflanWorldBorder.java | 14 +- .../border/worldborders/FakeWorldBorder.java | 4 +- .../worldborders/VanillaWorldBorder.java | 6 +- .../core/border/worldborders/WorldBorder.java | 14 +- .../modules/core/game/Config.java | 14 +- .../modules/core/game/GameModule.java | 72 ++--- .../modules/core/game/GamePhase.java | 2 +- .../core/game/commands/KillCommand.java | 20 +- .../core/game/commands/ResurrectCommand.java | 18 +- .../core/game/commands/StartCommand.java | 22 +- .../events/game/GamePhaseChangedEvent.java | 4 +- .../events/players/AlivePlayerDeathEvent.java | 2 +- .../players/PlayerResurrectedEvent.java | 2 +- .../game/events/players/TeamDeathEvent.java | 2 +- .../start/AfterTeleportationPhaseEvent.java | 2 +- .../start/BeforeTeleportationPhaseEvent.java | 2 +- ...rAboutToBeTeleportedToSpawnPointEvent.java | 2 +- .../start/PlayerSpawnPointSelectedEvent.java | 2 +- .../PlayerTeleportedToSpawnPointEvent.java | 2 +- .../core/game/submanagers/GameBeginning.java | 30 +- .../game/teleporter/TeleportationMode.java | 2 +- .../teleporter/TeleportationRunnable.java | 14 +- .../core/game/teleporter/Teleporter.java | 8 +- .../modules/core/modules/ModulesModule.java | 32 +- .../commands/ConfigurationCommand.java | 12 +- .../core/modules/commands/ModuleCommand.java | 19 +- .../core/modules/commands/ModulesCommand.java | 24 +- .../core/modules/gui/MainConfigGUI.java | 63 ++-- .../gui/modules/ConfirmModuleDisableGUI.java | 14 +- .../modules/gui/modules/FramedModuleGUI.java | 8 +- .../modules/gui/modules/ModulesListGUI.java | 40 +-- .../core/modules/gui/start/StartGameGUI.java | 32 +- .../modules/core/sidebar/GameSidebar.java | 22 +- .../modules/core/sidebar/SidebarInjector.java | 2 +- .../modules/core/sidebar/SidebarModule.java | 10 +- .../modules/core/spawns/Config.java | 12 +- .../modules/core/spawns/Generator.java | 14 +- .../modules/core/spawns/SpawnsModule.java | 48 +-- .../core/spawns/commands/SpawnsCommand.java | 50 +-- .../CannotGenerateSpawnPointsException.java | 2 +- .../exceptions/UnknownGeneratorException.java | 2 +- .../CircularSpawnPointsGenerator.java | 17 +- .../generators/GridSpawnPointsGenerator.java | 21 +- .../RandomSpawnPointsGenerator.java | 19 +- .../generators/SpawnPointsGenerator.java | 4 +- .../modules/core/spectators/Config.java | 8 +- .../spectators/SpectatorPlusDependency.java | 6 +- .../core/spectators/SpectatorsModule.java | 48 +-- .../commands/SpectatorsCommand.java | 28 +- .../managers/SPlusSpectatorsManager.java | 2 +- .../managers/SpectatorsManager.java | 6 +- .../managers/VanillaSpectatorsManager.java | 2 +- .../modules/core/teams/Config.java | 12 +- .../modules/core/teams/TeamsModule.java | 51 +-- .../teams/sidebar/SidebarCacheListener.java | 18 +- .../teams/sidebar/SidebarPlayerCache.java | 12 +- .../modules/core/timers/TimeDelta.java | 8 +- .../modules/core/timers/Timer.java | 8 +- .../modules/core/timers/TimersModule.java | 20 +- .../core/timers/commands/TimersCommand.java | 36 +-- .../core/timers/events/TimerEndsEvent.java | 4 +- .../core/timers/events/TimerStartsEvent.java | 4 +- .../modules/cosmetics/KillsCountModule.java | 20 +- .../modules/cosmetics/ListHealthModule.java | 22 +- .../modules/cosmetics/episodes/Config.java | 10 +- .../cosmetics/episodes/EpisodesModule.java | 52 +-- .../episodes/commands/ShiftCommand.java | 24 +- .../episodes/events/EpisodeChangedEvent.java | 2 +- .../cosmetics/hardcoreHearts/Config.java | 12 +- .../hardcoreHearts/HardcoreHeartsModule.java | 12 +- .../hardcoreHearts/PacketsListener.java | 11 +- .../playerListHeaderFooter/Config.java | 10 +- .../ListPlaceholdersCommand.java | 18 +- .../PlayerListHeaderFooterModule.java | 56 ++-- .../modules/end/EndAnnouncementModule.java | 30 +- .../modules/end/FireworksModule.java | 32 +- .../modules/end/deathAnnouncement/Config.java | 12 +- .../DeathAnnouncementModule.java | 32 +- .../modules/end/kick/Config.java | 12 +- .../modules/end/kick/KickModule.java | 16 +- .../modules/end/xpToKillers/Config.java | 8 +- .../end/xpToKillers/XpToKillersModule.java | 14 +- .../modules/external/dynmap/Config.java | 8 +- .../modules/external/dynmap/DynmapModule.java | 30 +- .../modules/external/hawk/Config.java | 14 +- .../modules/external/hawk/HawkModule.java | 66 ++-- .../modules/external/motd/Config.java | 8 +- .../modules/external/motd/MotdModule.java | 22 +- .../gameplay/NoEnderPearlDamagesModule.java | 12 +- .../modules/gameplay/NoGhastTearsModule.java | 18 +- .../gameplay/OnerousGlisteringMelon.java | 16 +- .../gameplay/compass/CompassModule.java | 51 +-- .../gameplay/compass/CompassRecipes.java | 10 +- .../modules/gameplay/compass/Config.java | 8 +- .../gameplay/daylightCycle/Config.java | 10 +- .../daylightCycle/DaylightCycleModule.java | 32 +- .../modules/gameplay/goldenHeads/Config.java | 12 +- .../goldenHeads/GoldenHeadsModule.java | 32 +- .../modules/gameplay/hardcore/Config.java | 8 +- .../gameplay/hardcore/HardcoreModule.java | 18 +- .../modules/gameplay/killerRabbit/Config.java | 8 +- .../killerRabbit/KillerRabbitModule.java | 12 +- .../modules/gameplay/noWitches/Config.java | 8 +- .../gameplay/noWitches/NoWitchesModule.java | 12 +- .../gameplay/potions/CancelBrewTask.java | 4 +- .../modules/gameplay/potions/Config.java | 8 +- .../gameplay/potions/PotionsModule.java | 14 +- .../modules/gameplay/weather/Config.java | 8 +- .../gameplay/weather/WeatherModule.java | 24 +- .../modules/other/AdvancementsModule.java | 36 +-- .../modules/other/PomfModule.java | 18 +- .../modules/other/StatisticsModule.java | 22 +- .../modules/other/about/AboutCommand.java | 16 +- .../modules/other/about/AboutModule.java | 38 +-- .../scenarii/alliances/AllianceRequest.java | 52 +-- .../scenarii/alliances/AlliancesModule.java | 42 +-- .../modules/scenarii/alliances/Config.java | 8 +- .../alliances/TeamsPermissionsChecker.java | 2 +- .../commands/AllianceRequestCommand.java | 30 +- .../commands/RequestAnswerCommand.java | 26 +- .../modules/starting/cages/Cage.java | 2 +- .../modules/starting/cages/CagesModule.java | 22 +- .../modules/starting/cages/Config.java | 8 +- .../modules/utilities/check/CheckCommand.java | 16 +- .../modules/utilities/check/CheckModule.java | 14 +- .../modules/utilities/food/FoodModule.java | 18 +- .../food/commands/FeedAllCommand.java | 10 +- .../utilities/food/commands/FeedCommand.java | 10 +- .../utilities/freezer/FreezeCommand.java | 38 +-- .../utilities/freezer/FreezerListener.java | 24 +- .../utilities/freezer/FreezerModule.java | 38 +-- .../utilities/health/HealthModule.java | 18 +- .../health/commands/HealAllCommand.java | 16 +- .../health/commands/HealCommand.java | 18 +- .../playersLoader/LoadPlayersCommand.java | 10 +- .../playersLoader/PlayersLoaderModule.java | 12 +- .../modules/utilities/rules/Config.java | 14 +- .../modules/utilities/rules/RulesCommand.java | 18 +- .../modules/utilities/rules/RulesModule.java | 30 +- .../runtimeCommandsExecutor/Config.java | 8 +- .../RuntimeCommandsExecutor.java | 26 +- .../ScheduledCommandsExecutorTask.java | 10 +- .../teleportation/TeleportationModule.java | 22 +- .../commands/TPDeathCommand.java | 26 +- .../commands/TPSpawnCommand.java | 24 +- .../commands/TPSpectatorsCommand.java | 14 +- .../teleportation/commands/TPTeamCommand.java | 8 +- .../commands/WorldBasedCommand.java | 8 +- .../modules/utilities/walls/Config.java | 12 +- .../modules/utilities/walls/WallsCommand.java | 20 +- .../modules/utilities/walls/WallsModule.java | 26 +- .../CannotGenerateWallsException.java | 2 +- .../exceptions/UnknownWallGenerator.java | 2 +- .../generators/CircularWallGenerator.java | 2 +- .../generators/SquaredWallGenerator.java | 2 +- .../walls/generators/WallGenerator.java | 4 +- .../walls/generators/WallPosition.java | 2 +- .../utilities/warning/BorderWarningTask.java | 14 +- .../modules/utilities/warning/Config.java | 10 +- .../utilities/warning/WarningCommand.java | 16 +- .../utilities/warning/WarningModule.java | 34 +- .../modules/waitingPhase/wait/Config.java | 12 +- .../modules/waitingPhase/wait/WaitModule.java | 57 ++-- .../modules/worldgen/creatures/Config.java | 8 +- .../worldgen/creatures/CreaturesModule.java | 24 +- .../shortcuts/QSG.java} | 50 +-- .../utils/CommandUtils.java | 4 +- .../utils/EntitiesUtils.java | 2 +- .../utils/ModulesUtils.java | 2 +- .../utils/OfflinePlayersComparator.java | 2 +- .../utils/OfflinePlayersLoader.java | 18 +- .../utils/QSGSound.java} | 36 +-- .../utils/QSGUtils.java} | 12 +- .../utils/RecipesUtils.java | 2 +- .../utils/Run.java | 10 +- .../utils/TextUtils.java | 2 +- src/main/resources/plugin.yml | 13 +- .../SidebarInjectorTest.java | 4 +- 202 files changed, 1951 insertions(+), 1998 deletions(-) rename src/main/java/eu/carrade/amaury/{UHCReloaded/UHConfig.java => quartzsurvivalgames/QSGConfig.java} (59%) rename src/main/java/eu/carrade/amaury/{UHCReloaded/UHCReloaded.java => quartzsurvivalgames/QuartzSurvivalGames.java} (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModuleCategory.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModuleInfo.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModuleLoadTime.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModuleLogger.java (78%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModuleWrapper.java (65%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/ModulesManager.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded/core/UHModule.java => quartzsurvivalgames/core/QSGModule.java} (81%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/events/AllModulesLoadedEvent.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/events/ModuleDisabledEvent.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/events/ModuleEnabledEvent.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/events/ModuleLoadedEvent.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/core/events/ModuleUnloadedEvent.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/BorderModule.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/Config.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/MapShape.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/WorldBorderDependency.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/commands/BorderCommand.java (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/events/BorderChangedEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/shapes/CircularMapShape.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/shapes/MapShapeDescriptor.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/shapes/SquaredMapShape.java (98%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/worldborders/BrettflanWorldBorder.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/worldborders/FakeWorldBorder.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/worldborders/VanillaWorldBorder.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/border/worldborders/WorldBorder.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/Config.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/GameModule.java (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/GamePhase.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/commands/KillCommand.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/commands/ResurrectCommand.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/commands/StartCommand.java (81%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/game/GamePhaseChangedEvent.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/players/AlivePlayerDeathEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/players/PlayerResurrectedEvent.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/players/TeamDeathEvent.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/start/AfterTeleportationPhaseEvent.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/submanagers/GameBeginning.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/teleporter/TeleportationMode.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/teleporter/TeleportationRunnable.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/game/teleporter/Teleporter.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/ModulesModule.java (71%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/commands/ConfigurationCommand.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/commands/ModuleCommand.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/commands/ModulesCommand.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/gui/MainConfigGUI.java (77%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/gui/modules/FramedModuleGUI.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/gui/modules/ModulesListGUI.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/modules/gui/start/StartGameGUI.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/sidebar/GameSidebar.java (77%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/sidebar/SidebarInjector.java (99%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/sidebar/SidebarModule.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/Config.java (81%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/Generator.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/SpawnsModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/commands/SpawnsCommand.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/exceptions/UnknownGeneratorException.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/generators/CircularSpawnPointsGenerator.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/generators/GridSpawnPointsGenerator.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/generators/RandomSpawnPointsGenerator.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spawns/generators/SpawnPointsGenerator.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/SpectatorPlusDependency.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/SpectatorsModule.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/commands/SpectatorsCommand.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/managers/SPlusSpectatorsManager.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/managers/SpectatorsManager.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/spectators/managers/VanillaSpectatorsManager.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/teams/Config.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/teams/TeamsModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/teams/sidebar/SidebarCacheListener.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/teams/sidebar/SidebarPlayerCache.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/TimeDelta.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/Timer.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/TimersModule.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/commands/TimersCommand.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/events/TimerEndsEvent.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/core/timers/events/TimerStartsEvent.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/KillsCountModule.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/ListHealthModule.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/episodes/Config.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/episodes/EpisodesModule.java (76%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/episodes/commands/ShiftCommand.java (73%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/episodes/events/EpisodeChangedEvent.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/hardcoreHearts/Config.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/hardcoreHearts/PacketsListener.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/playerListHeaderFooter/Config.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java (76%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/EndAnnouncementModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/FireworksModule.java (76%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/deathAnnouncement/Config.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/deathAnnouncement/DeathAnnouncementModule.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/kick/Config.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/kick/KickModule.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/xpToKillers/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/end/xpToKillers/XpToKillersModule.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/dynmap/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/dynmap/DynmapModule.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/hawk/Config.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/hawk/HawkModule.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/motd/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/external/motd/MotdModule.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/NoEnderPearlDamagesModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/NoGhastTearsModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/OnerousGlisteringMelon.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/compass/CompassModule.java (80%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/compass/CompassRecipes.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/compass/Config.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/daylightCycle/Config.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/daylightCycle/DaylightCycleModule.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/goldenHeads/Config.java (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/goldenHeads/GoldenHeadsModule.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/hardcore/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/hardcore/HardcoreModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/killerRabbit/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/killerRabbit/KillerRabbitModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/noWitches/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/noWitches/NoWitchesModule.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/potions/CancelBrewTask.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/potions/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/potions/PotionsModule.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/weather/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/gameplay/weather/WeatherModule.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/other/AdvancementsModule.java (77%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/other/PomfModule.java (80%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/other/StatisticsModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/other/about/AboutCommand.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/other/about/AboutModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/AllianceRequest.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/AlliancesModule.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/TeamsPermissionsChecker.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/commands/AllianceRequestCommand.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/scenarii/alliances/commands/RequestAnswerCommand.java (72%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/starting/cages/Cage.java (99%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/starting/cages/CagesModule.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/starting/cages/Config.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/check/CheckCommand.java (81%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/check/CheckModule.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/food/FoodModule.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/food/commands/FeedAllCommand.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/food/commands/FeedCommand.java (92%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/freezer/FreezeCommand.java (78%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/freezer/FreezerListener.java (80%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/freezer/FreezerModule.java (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/health/HealthModule.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/health/commands/HealAllCommand.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/health/commands/HealCommand.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/playersLoader/LoadPlayersCommand.java (91%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/playersLoader/PlayersLoaderModule.java (86%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/rules/Config.java (81%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/rules/RulesCommand.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/rules/RulesModule.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/runtimeCommandsExecutor/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java (93%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/TeleportationModule.java (77%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/commands/TPDeathCommand.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/commands/TPSpawnCommand.java (83%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/commands/TPSpectatorsCommand.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/commands/TPTeamCommand.java (94%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/teleportation/commands/WorldBasedCommand.java (89%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/Config.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/WallsCommand.java (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/WallsModule.java (79%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/exceptions/CannotGenerateWallsException.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/exceptions/UnknownWallGenerator.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/generators/CircularWallGenerator.java (98%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/generators/SquaredWallGenerator.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/generators/WallGenerator.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/walls/generators/WallPosition.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/warning/BorderWarningTask.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/warning/Config.java (84%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/warning/WarningCommand.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/utilities/warning/WarningModule.java (85%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/waitingPhase/wait/Config.java (88%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/waitingPhase/wait/WaitModule.java (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/worldgen/creatures/Config.java (87%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/modules/worldgen/creatures/CreaturesModule.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded/shortcuts/UR.java => quartzsurvivalgames/shortcuts/QSG.java} (82%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/CommandUtils.java (96%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/EntitiesUtils.java (98%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/ModulesUtils.java (99%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/OfflinePlayersComparator.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/OfflinePlayersLoader.java (95%) rename src/main/java/eu/carrade/amaury/{UHCReloaded/utils/UHSound.java => quartzsurvivalgames/utils/QSGSound.java} (90%) rename src/main/java/eu/carrade/amaury/{UHCReloaded/utils/UHUtils.java => quartzsurvivalgames/utils/QSGUtils.java} (98%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/RecipesUtils.java (99%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/Run.java (97%) rename src/main/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/utils/TextUtils.java (98%) rename src/test/java/eu/carrade/amaury/{UHCReloaded => quartzsurvivalgames}/SidebarInjectorTest.java (98%) diff --git a/pom.xml b/pom.xml index 8c6db3a..6506b29 100644 --- a/pom.xml +++ b/pom.xml @@ -32,10 +32,10 @@ <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>eu.carrade.amaury</groupId> - <artifactId>UHCReloaded</artifactId> + <artifactId>quartz-survival-games</artifactId> <version>2.0-SNAPSHOT</version> - <name>UHCReloaded</name> - <description>Ultra Hardcore plugin</description> + <name>Quartz Survival Games</name> + <description>Survival games plugin, able to handle most Minecraft survival games (like UHC) through combined modules</description> <url>https://github.com/zDevelopers/UHPlugin/</url> <issueManagement> @@ -105,16 +105,16 @@ </artifactSet> <relocations> <relocation> - <pattern>fr.zcraft.zlib</pattern> - <shadedPattern>eu.carrade.amaury.UHCReloaded.zlib</shadedPattern> + <pattern>fr.zcraft.quartzlib</pattern> + <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzlib</shadedPattern> </relocation> <relocation> - <pattern>fr.zcraft.zteams</pattern> - <shadedPattern>eu.carrade.amaury.UHCReloaded.zteams</shadedPattern> + <pattern>fr.zcraft.quartzteams</pattern> + <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzteams</shadedPattern> </relocation> <relocation> <pattern>me.cassayre.florian.hawk</pattern> - <shadedPattern>eu.carrade.amaury.UHCReloaded.hawk</shadedPattern> + <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.hawk</shadedPattern> </relocation> </relocations> </configuration> @@ -153,25 +153,29 @@ <url>http://raw.carrade.eu/maven2/</url> </repository> <repository> - <id>zDevelopers</id> - <url>http://maven.carrade.eu/artifactory/snapshots</url> + <id>zdevelpers-quartzlib</id> + <url>https://maven.zcraft.fr/QuartzLib</url> + </repository> + <repository> + <id>zdevelpers-quartzteams</id> + <url>https://maven.zcraft.fr/QuartzTeams</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.bukkit</groupId> <artifactId>bukkit</artifactId> - <version>1.8.3-R0.1-SNAPSHOT</version> + <version>1.15.2-R0.1-SNAPSHOT</version> <type>jar</type> </dependency> <dependency> <groupId>fr.zcraft</groupId> - <artifactId>zlib</artifactId> - <version>0.99-SNAPSHOT</version> + <artifactId>quartzlib</artifactId> + <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>fr.zcraft</groupId> - <artifactId>zteams</artifactId> + <artifactId>quartzteams</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java similarity index 59% rename from src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java index e6df271..42ccc18 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHConfig.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java @@ -1,14 +1,18 @@ -package eu.carrade.amaury.UHCReloaded; +package eu.carrade.amaury.quartzsurvivalgames; -import fr.zcraft.zlib.components.configuration.*; -import org.bukkit.ChatColor; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.map; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; +import fr.zcraft.quartzlib.components.configuration.Configuration; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationMap; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.util.Locale; - -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.*; +import org.bukkit.ChatColor; -public class UHConfig extends Configuration +public class QSGConfig extends Configuration { static public final ConfigurationItem<Locale> LANG = item("lang", Locale.class); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java index f23af95..a57bb80 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/UHCReloaded.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java @@ -29,29 +29,29 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded; - -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.ModulesManager; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.ModulesModule; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.commands.Commands; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.i18n.I18n; -import fr.zcraft.zlib.components.scoreboard.SidebarScoreboard; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.core.ZPlugin; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.ModulesManager; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.ModulesModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; +import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; +import fr.zcraft.quartzlib.components.commands.Commands; +import fr.zcraft.quartzlib.components.gui.Gui; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.i18n.I18n; +import fr.zcraft.quartzlib.components.scoreboard.SidebarScoreboard; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.ZPlugin; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -66,9 +66,9 @@ import java.util.function.BiConsumer; -public class UHCReloaded extends ZPlugin implements Listener +public class QuartzSurvivalGames extends ZPlugin implements Listener { - private static UHCReloaded instance; + private static QuartzSurvivalGames instance; private ModulesManager modulesManager = null; private Scoreboard scoreboard = null; @@ -90,14 +90,14 @@ public void onEnable() /* *** Required zLib base components *** */ - loadComponents(UHConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, OfflinePlayersLoader.class); + loadComponents(QSGConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, OfflinePlayersLoader.class); modulesManager = loadComponent(ModulesManager.class); /* *** Internationalization *** */ - if (UHConfig.LANG.isDefined()) I18n.setPrimaryLocale(UHConfig.LANG.get()); + if (QSGConfig.LANG.isDefined()) I18n.setPrimaryLocale(QSGConfig.LANG.get()); PluginLogger.info("Using locale {0} (fallback on {1})", I18n.getPrimaryLocale(), I18n.getFallbackLocale()); @@ -134,7 +134,7 @@ public void onEnable() /* *** Built-in modules *** */ - if (UHConfig.BUILT_IN_MODULES.get()) + if (QSGConfig.BUILT_IN_MODULES.get()) { modulesManager.registerBuiltInModules(); } @@ -142,7 +142,7 @@ public void onEnable() /* *** Config modules *** */ - UHConfig.MODULES.forEach((BiConsumer<String, Boolean>) modulesManager::registerModule); + QSGConfig.MODULES.forEach((BiConsumer<String, Boolean>) modulesManager::registerModule); /* *** Loads modules from startup time *** */ @@ -176,9 +176,9 @@ private void onEnableWhenWorldsAvailable() scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); RunTask.nextTick(() -> { - worldNormal = setDefaultWorld(World.Environment.NORMAL, UHConfig.WORLDS.OVERWORLD.get()); - worldNether = setDefaultWorld(World.Environment.NETHER, UHConfig.WORLDS.NETHER.get()); - worldTheEnd = setDefaultWorld(World.Environment.THE_END, UHConfig.WORLDS.THE_END.get()); + worldNormal = setDefaultWorld(World.Environment.NORMAL, QSGConfig.WORLDS.OVERWORLD.get()); + worldNether = setDefaultWorld(World.Environment.NETHER, QSGConfig.WORLDS.NETHER.get()); + worldTheEnd = setDefaultWorld(World.Environment.THE_END, QSGConfig.WORLDS.THE_END.get()); modulesManager.loadModules(ModuleLoadTime.POST_WORLD); }); @@ -285,7 +285,7 @@ private World setDefaultWorld(final World.Environment environment, final String /** * Returns the plugin's instance. */ - public static UHCReloaded get() + public static QuartzSurvivalGames get() { return instance; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java index 393e216..a2d7186 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleCategory.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java @@ -31,10 +31,10 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.core; +package eu.carrade.amaury.quartzsurvivalgames.core; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java index bb71ecd..1066e53 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java @@ -29,21 +29,20 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import org.bukkit.Material; +package eu.carrade.amaury.quartzsurvivalgames.core; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.bukkit.Material; @Retention(RetentionPolicy.RUNTIME) -@Target ({ElementType.TYPE}) -public @interface ModuleInfo -{ +@Target({ElementType.TYPE}) +public @interface ModuleInfo { /** * @return A name for the module (optional). */ @@ -97,17 +96,17 @@ /** * @return The settings's default filename, containing the default configuration written * to the server's plugins/UHPlugin/modules directory if the file does not exists. - * + * <p> * The format can either be a simple filename without extension, like “moduleName“, and * the file will be copied from the UHCReloaded's JAR, from modules/moduleName.yml; or * the filename prefixed by the plugin name like so: “OtherPlugin:moduleName”, and the * file will be copied from the given plugin's JAR, from modules/moduleName.yml too. - * + * <p> * If left empty, it will be derived from the module name and category, by converting * the module's class name into hyphened-snake-case, removing the “-module” suffix (if * any) and prefixing by the category converted to hyphened-snake-case. * Example: “external-reports”. - * + * <p> * In all cases, the file will be copied into UHPlugin's data directory, under module/. */ String settings_default_filename() default ""; @@ -127,10 +126,10 @@ * @return {@code true} if the module can be unloaded and re-loaded. This reflects the status change * from inside the game, as all modules can always be disabled on the configuration file (or not loaded * at all). - * - * If this is {@code true}, when disabled, a module will have its {@link UHModule#onDisable()} onDisable()} + * <p> + * If this is {@code true}, when disabled, a module will have its {@link QSGModule#onDisable()} onDisable()} * method called, and after that, its listener will be unregistered and the module instance removed from the system. - * + * <p> * When re-loaded, a whole new instance will be created. */ boolean can_be_unloaded() default true; @@ -139,7 +138,7 @@ * @return {@code true} if the module can be loaded after the moment it was declared to be loaded. If {@code false}, * and an user tries to enable/load it during the game and the module is configured to be loaded, let's say, on * {@link ModuleLoadTime#ON_GAME_STARTING game starting}, the operation will fail. Use this if you depends on the - * fact that the {@link UHModule#onEnable()} method is called at a specific time. + * fact that the {@link QSGModule#onEnable()} method is called at a specific time. */ boolean can_be_loaded_late() default true; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java index 3adf9f3..a4d852a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLoadTime.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java @@ -31,9 +31,9 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.core; +package eu.carrade.amaury.quartzsurvivalgames.core; -import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.quartzlib.components.i18n.I; public enum ModuleLoadTime { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java similarity index 78% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java index c257d1e..f2c0c79 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java @@ -31,27 +31,25 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.core; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.text.RawMessage; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; +package eu.carrade.amaury.quartzsurvivalgames.core; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.text.RawMessage; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; -public class ModuleLogger extends Logger -{ +public class ModuleLogger extends Logger { private final String moduleName; private final String loggerName; - public ModuleLogger(Class<?extends UHModule> module) - { + public ModuleLogger(Class<? extends QSGModule> module) { super(ZLib.getPlugin().getClass().getCanonicalName(), null); setParent(ZLib.getPlugin().getLogger()); @@ -62,77 +60,63 @@ public ModuleLogger(Class<?extends UHModule> module) } @Override - public void log(LogRecord logRecord) - { + public void log(LogRecord logRecord) { logRecord.setMessage(loggerName + logRecord.getMessage()); super.log(logRecord); } - public void log(Level level, String message, Throwable ex, Object... args) - { + public void log(Level level, String message, Throwable ex, Object... args) { log(level, message, args); log(level, "Exception : ", ex); } - public void info(String message, Object...args) - { + public void info(String message, Object... args) { log(Level.INFO, message, args); } - public void warning(String message, Object... args) - { + public void warning(String message, Object... args) { log(Level.WARNING, message, args); } - public void warning(String message, Throwable ex) - { + public void warning(String message, Throwable ex) { log(Level.WARNING, message, ex); } - public void warning(String message, Throwable ex, Object... args) - { + public void warning(String message, Throwable ex, Object... args) { log(Level.WARNING, message, ex, args); } - public void error(String message) - { + public void error(String message) { log(Level.SEVERE, message); } - public void error(String message, Throwable ex) - { + public void error(String message, Throwable ex) { log(Level.SEVERE, message, ex); } - public void error(String message, Throwable ex, Object... args) - { + public void error(String message, Throwable ex, Object... args) { log(Level.SEVERE, message, ex, args); } - public void error(String message, Object... args) - { + public void error(String message, Object... args) { log(Level.SEVERE, message, args); } - public void broadcastAdministrative(final String message) - { + public void broadcastAdministrative(final String message) { broadcastAdministrative(message, ChatColor.stripColor(message)); } - public void broadcastAdministrative(final RawText message) - { + public void broadcastAdministrative(final RawText message) { // TODO use permissions Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> RawMessage.send(player, message)); info(ChatColor.stripColor(message.toPlainText())); } - public void broadcastAdministrativePrefixed(final String message) - { - broadcastAdministrative(UHUtils.prefixedMessage(moduleName, message), ChatColor.stripColor(message)); + public void broadcastAdministrativePrefixed(final String message) { + broadcastAdministrative(QSGUtils.prefixedMessage(moduleName, message), ChatColor.stripColor(message)); } - private void broadcastAdministrative(final String messagePlayers, final String messageConsole) - { + private void broadcastAdministrative(final String messagePlayers, final String messageConsole) { // TODO use permissions Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(player -> player.sendMessage(messagePlayers)); info(messageConsole); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java similarity index 65% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java index 67fae70..cf95a16 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java @@ -29,21 +29,22 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core; + +package eu.carrade.amaury.quartzsurvivalgames.core; import com.google.common.base.CaseFormat; import com.google.common.base.Charsets; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleDisabledEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleEnabledEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.reflection.Reflection; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleDisabledEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleEnabledEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleLoadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; @@ -57,8 +58,7 @@ import java.util.stream.Stream; -public class ModuleWrapper -{ +public class ModuleWrapper { private final String name; private final String shortDescription; private final String description; @@ -71,7 +71,7 @@ public class ModuleWrapper private boolean enabled; - private final Class<? extends UHModule> moduleClass; + private final Class<? extends QSGModule> moduleClass; private final Class<? extends ConfigurationInstance> moduleConfiguration; private final String settingsFileName; @@ -82,23 +82,20 @@ public class ModuleWrapper private final boolean canBeUnloaded; private final boolean canBeLoadedLate; - private UHModule instance = null; + private QSGModule instance = null; - public ModuleWrapper(final Class<? extends UHModule> moduleClass) - { + public ModuleWrapper(final Class<? extends QSGModule> moduleClass) { this(moduleClass, true); } - public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enabled) - { + public ModuleWrapper(final Class<? extends QSGModule> moduleClass, boolean enabled) { this.name = computeModuleName(moduleClass); this.moduleClass = moduleClass; this.enabled = enabled; final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); - if (info == null) - { + if (info == null) { description = ""; shortDescription = ""; authors = ""; @@ -112,9 +109,7 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable settingsFileName = null; settingsDefaultFileName = null; dependencies = new String[] {}; - } - else - { + } else { description = info.description(); shortDescription = info.short_description(); authors = info.authors(); @@ -126,7 +121,8 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable icon = info.icon(); moduleConfiguration = info.settings().equals(ConfigurationInstance.class) ? null : info.settings(); settingsFileName = info.settings_filename().isEmpty() ? null : info.settings_filename(); - settingsDefaultFileName = info.settings_default_filename().isEmpty() ? null : info.settings_default_filename(); + settingsDefaultFileName = + info.settings_default_filename().isEmpty() ? null : info.settings_default_filename(); dependencies = info.depends(); } @@ -138,32 +134,27 @@ public ModuleWrapper(final Class<? extends UHModule> moduleClass, boolean enable * Enables this module. * * @param late {@code true} if the module is not loaded when specified in - * its {@link ModuleInfo properties}. + * its {@link ModuleInfo properties}. */ - public boolean load(boolean late) - { - if (isLoaded()) return true; + public boolean load(boolean late) { + if (isLoaded()) { + return true; + } // Check dependencies - for (final String dependency : dependencies) - { + for (final String dependency : dependencies) { final Plugin plugin = Bukkit.getPluginManager().getPlugin(dependency); - if (plugin == null) - { - if (dependencies.length >= 2) - { - PluginLogger.error("Cannot enable module {0}: missing dependency {1} (depends on {2}).", name, dependency, String.join(", ", dependencies)); - } - else - { + if (plugin == null) { + if (dependencies.length >= 2) { + PluginLogger.error("Cannot enable module {0}: missing dependency {1} (depends on {2}).", name, + dependency, String.join(", ", dependencies)); + } else { PluginLogger.error("Cannot enable module {0}: missing dependency {1}.", name, dependency); } return false; - } - else if (!plugin.isEnabled()) - { + } else if (!plugin.isEnabled()) { // Ensures every dependency is available when a module is loaded. Bukkit.getPluginManager().enablePlugin(plugin); } @@ -173,7 +164,9 @@ else if (!plugin.isEnabled()) Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this, late)); - if (late) instance.onLateEnable(); + if (late) { + instance.onLateEnable(); + } return true; } @@ -181,9 +174,10 @@ else if (!plugin.isEnabled()) /** * Disable this module. */ - public void unload() - { - if (instance == null) return; + public void unload() { + if (instance == null) { + return; + } instance.setEnabled(false); ZLib.unregisterEvents(instance); @@ -202,39 +196,30 @@ public void unload() * module is loaded and marked as un-loadable, or if you try to enable the * module and it is marked as un-loadable after its auto-load moment. */ - public boolean setEnabled(boolean enabled) - { - if (this.enabled != enabled) - { + public boolean setEnabled(boolean enabled) { + if (this.enabled != enabled) { // Can we enabled this module? - if (enabled) - { - if (!canBeEnabled()) - { + if (enabled) { + if (!canBeEnabled()) { return false; } } // Can we disable this module? - else if (!canBeDisabled()) - { + else if (!canBeDisabled()) { return false; } this.enabled = enabled; - if (enabled) - { + if (enabled) { Bukkit.getPluginManager().callEvent(new ModuleEnabledEvent(this)); - if (UR.get().getModulesManager().isLoaded(when)) - { + if (QSG.get().getModulesManager().isLoaded(when)) { return load(true); } - } - else - { + } else { Bukkit.getPluginManager().callEvent(new ModuleDisabledEvent(this)); unload(); } @@ -247,64 +232,56 @@ else if (!canBeDisabled()) * @return {@code true} if after being disabled, this module will be reloadable * (can depends on the moment this method is called). */ - public boolean canBeEnabled() - { - return canBeLoadedLate || !UR.get().getModulesManager().isLoaded(when); + public boolean canBeEnabled() { + return canBeLoadedLate || !QSG.get().getModulesManager().isLoaded(when); } /** * @return {@code true} if, at the moment this method is called, this module can be disabled. */ - public boolean canBeDisabled() - { + public boolean canBeDisabled() { return !internal && !(isLoaded() && !canBeUnloaded); } /** * @return A name for this module. Either the provided name using {@link ModuleInfo} or a name derived from the class name. */ - public String getName() - { + public String getName() { return name; } /** * @return A description for the module, or {@code null} if none provided. */ - public String getDescription() - { + public String getDescription() { return description != null && !description.isEmpty() ? description : null; } /** * @return A short description for the module, or {@code null} if none provided. */ - public String getShortDescription() - { + public String getShortDescription() { return shortDescription != null && !shortDescription.isEmpty() ? shortDescription : null; } /** * @return The authors of the module, or {@code null} if not provided. */ - public String getAuthors() - { + public String getAuthors() { return authors != null && !authors.isEmpty() ? authors : null; } /** * @return This module's category. */ - public ModuleCategory getCategory() - { + public ModuleCategory getCategory() { return category; } /** * @return This module's icon: either the declared one, or the category's. */ - public ItemStack getIcon() - { + public ItemStack getIcon() { return icon == Material.AIR ? category.getIcon() : new ItemStack(icon); } @@ -317,37 +294,38 @@ public ItemStack getIcon() * the long one. * @return The icon. */ - public ItemStackBuilder getFullIcon(final boolean complete) - { + public ItemStackBuilder getFullIcon(final boolean complete) { final ItemStackBuilder icon = new ItemStackBuilder(getIcon()) .title( - (isLoaded() ? ChatColor.GREEN : (isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + "" + ChatColor.BOLD + "\u2758 ", - category.getColor() + "" + ChatColor.BOLD + name + (isLoaded() ? ChatColor.GREEN : (isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + "" + + ChatColor.BOLD + "\u2758 ", + category.getColor() + "" + ChatColor.BOLD + name ) .loreLine( - ChatColor.DARK_GRAY + category.getDisplayName(), - ChatColor.DARK_GRAY + " - ", - ChatColor.DARK_GRAY + (enabled ? (isLoaded() ? I.t("Enabled and loaded") : I.t("Enabled")) : I.t("Disabled")) + ChatColor.DARK_GRAY + category.getDisplayName(), + ChatColor.DARK_GRAY + " - ", + ChatColor.DARK_GRAY + + (enabled ? (isLoaded() ? I.t("Enabled and loaded") : I.t("Enabled")) : I.t("Disabled")) ); String description; - if (((description = getShortDescription()) != null && !complete) || (description = getDescription()) != null) - { + if (((description = getShortDescription()) != null && !complete) || (description = getDescription()) != null) { icon.loreSeparator().longLore(ChatColor.WHITE, description, complete ? 100 : 42); } - icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Load time")).longLore(ChatColor.WHITE, when.getDescription(), 42); + icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Load time")) + .longLore(ChatColor.WHITE, when.getDescription(), 42); - if (dependencies.length != 0) - { + if (dependencies.length != 0) { icon.loreSeparator().longLore(ChatColor.BLUE, I.t("External dependencies")); - Stream.of(dependencies).forEach(dep -> icon.loreLine(ChatColor.GRAY + "- ", (Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED) + dep)); + Stream.of(dependencies).forEach(dep -> icon.loreLine(ChatColor.GRAY + "- ", + (Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED) + dep)); } String authors; - if ((authors = getAuthors()) != null) - { - icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Brought to you by")).longLore(ChatColor.WHITE, authors, 42); + if ((authors = getAuthors()) != null) { + icon.loreSeparator().longLore(ChatColor.BLUE, I.t("Brought to you by")) + .longLore(ChatColor.WHITE, authors, 42); } return icon.hideAttributes(); @@ -356,38 +334,35 @@ public ItemStackBuilder getFullIcon(final boolean complete) /** * @return A list of external plugins this module depends on. */ - public String[] getDependencies() - { + public String[] getDependencies() { return dependencies; } /** * @return When this module should be loaded. */ - public ModuleLoadTime getWhen() - { + public ModuleLoadTime getWhen() { return when; } /** * @return This module's base class. */ - public Class<? extends UHModule> getModuleClass() - { + public Class<? extends QSGModule> getModuleClass() { return moduleClass; } - private String getDefaultSettingsFileName() - { - return String.format("%s-%s", category.name().toLowerCase().replace('_', '-'), StringUtils.removeEnd(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, moduleClass.getSimpleName()), "-module")); + private String getDefaultSettingsFileName() { + return String.format("%s-%s", category.name().toLowerCase().replace('_', '-'), StringUtils + .removeEnd(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, moduleClass.getSimpleName()), "-module")); } /** * @return A {@link File} representing the configuration file on the server's filesystem. */ - private File getConfigurationFile() - { - final String settingsFileName = this.settingsFileName != null ? this.settingsFileName + ".yml" : getDefaultSettingsFileName() + ".yml"; + private File getConfigurationFile() { + final String settingsFileName = + this.settingsFileName != null ? this.settingsFileName + ".yml" : getDefaultSettingsFileName() + ".yml"; return new File(ZLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); } @@ -395,57 +370,57 @@ private File getConfigurationFile() * Saves the default configuration file into the plugin's directory, if it * does not exists ad the default configuration file does exist. */ - public void saveDefaultConfig() - { + public void saveDefaultConfig() { final File targetSettingsFile = getConfigurationFile(); - if (targetSettingsFile.exists()) return; + if (targetSettingsFile.exists()) { + return; + } - final String settingsDefaultFileName = this.settingsDefaultFileName != null ? this.settingsDefaultFileName : getDefaultSettingsFileName(); + final String settingsDefaultFileName = + this.settingsDefaultFileName != null ? this.settingsDefaultFileName : getDefaultSettingsFileName(); final Plugin plugin; final String settingsDefaultFilePath; // If the default file is in another plugin - if (settingsDefaultFileName.contains(":")) - { + if (settingsDefaultFileName.contains(":")) { final String[] parts = settingsDefaultFileName.split(":"); final Plugin pl = Bukkit.getPluginManager().getPlugin(parts[0]); - if (pl != null) - { + if (pl != null) { plugin = pl; - settingsDefaultFilePath = "modules" + File.separator + String.join(":", (String[]) ArrayUtils.remove(parts, 0)) + ".yml"; + settingsDefaultFilePath = + "modules" + File.separator + String.join(":", (String[]) ArrayUtils.remove(parts, 0)) + ".yml"; + } else { + return; } - else return; - } - else - { - plugin = UR.get(); + } else { + plugin = QSG.get(); settingsDefaultFilePath = "modules" + File.separator + settingsDefaultFileName + ".yml"; } final InputStream stream = plugin.getResource(settingsDefaultFilePath); - if (stream == null) return; + if (stream == null) { + return; + } - try (final InputStreamReader reader = new InputStreamReader(stream, Charsets.UTF_8)) - { + try (final InputStreamReader reader = new InputStreamReader(stream, Charsets.UTF_8)) { final StringBuilder buffer = new StringBuilder(); int currentChar; - while((currentChar = reader.read()) != -1) - { + while ((currentChar = reader.read()) != -1) { buffer.append((char) currentChar); } targetSettingsFile.getParentFile().mkdirs(); - if (!targetSettingsFile.createNewFile()) return; + if (!targetSettingsFile.createNewFile()) { + return; + } - try (final PrintWriter writer = new PrintWriter(targetSettingsFile)) - { + try (final PrintWriter writer = new PrintWriter(targetSettingsFile)) { writer.write(buffer.toString()); } } - catch (final IOException e) - { + catch (final IOException e) { PluginLogger.error("Cannot create {0}'s default configuration file.", e, getName()); } } @@ -453,32 +428,28 @@ public void saveDefaultConfig() /** * Loads the configuration from its file and initialize the class. */ - private void loadConfiguration() - { - if (moduleConfiguration != null ) - { + private void loadConfiguration() { + if (moduleConfiguration != null) { final File settingsFile = getConfigurationFile(); - try - { - if (!settingsFile.exists()) - { - try - { + try { + if (!settingsFile.exists()) { + try { settingsFile.getParentFile().mkdirs(); settingsFile.createNewFile(); } - catch (IOException e) - { - PluginLogger.error("Cannot create and populate {0}'s module configuration file - using default values.", e, getName()); + catch (IOException e) { + PluginLogger + .error("Cannot create and populate {0}'s module configuration file - using default values.", + e, getName()); } } final ConfigurationInstance settings = Reflection.instantiate(moduleConfiguration, settingsFile); settings.setEnabled(true); } - catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) - { - PluginLogger.info("Cannot initialize the configuration for the module {0} ({1})!", e, getName(), moduleClass.getName()); + catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) { + PluginLogger.info("Cannot initialize the configuration for the module {0} ({1})!", e, getName(), + moduleClass.getName()); } } } @@ -486,16 +457,14 @@ private void loadConfiguration() /** * @return {@code true} if this module is internal. */ - public boolean isInternal() - { + public boolean isInternal() { return internal; } /** * @return {@code true} if this module can be disabled at runtime. */ - public boolean canBeUnloaded() - { + public boolean canBeUnloaded() { return canBeUnloaded; } @@ -503,34 +472,32 @@ public boolean canBeUnloaded() * @return {@code true} if the module is enabled. Disabled modules will not be * loaded when the time comes. */ - public boolean isEnabled() - { + public boolean isEnabled() { return enabled; } /** * @return {@code true} if the module was loaded and enabled. */ - public boolean isLoaded() - { + public boolean isLoaded() { return instance != null && instance.isEnabled(); } /** * @return This module's instance. */ - public UHModule get() - { + public QSGModule get() { return instance; } - static String computeModuleName(Class<? extends UHModule> moduleClass) - { + static String computeModuleName(Class<? extends QSGModule> moduleClass) { final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); - if (info == null || info.name().isEmpty()) - return StringUtils.capitalize(String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); - - else return info.name(); + if (info == null || info.name().isEmpty()) { + return StringUtils.capitalize( + String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); + } else { + return info.name(); + } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java index 9c99c34..7778989 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java @@ -31,24 +31,24 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.core; +package eu.carrade.amaury.quartzsurvivalgames.core; import com.google.common.reflect.ClassPath; -import eu.carrade.amaury.UHCReloaded.core.events.AllModulesLoadedEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleLoadedEvent; -import eu.carrade.amaury.UHCReloaded.core.events.ModuleUnloadedEvent; -import eu.carrade.amaury.UHCReloaded.modules.end.kick.KickModule; -import eu.carrade.amaury.UHCReloaded.modules.other.PomfModule; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; -import eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures.CreaturesModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.ModulesUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.Commands; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.core.ZLibComponent; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; +import eu.carrade.amaury.quartzsurvivalgames.core.events.AllModulesLoadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleLoadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.end.kick.KickModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.other.PomfModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.worldgen.creatures.CreaturesModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.ModulesUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.Commands; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.bukkit.Bukkit; import org.bukkit.command.CommandMap; import org.bukkit.command.PluginCommand; @@ -73,7 +73,7 @@ public class ModulesManager extends ZLibComponent implements Listener * These built-in modules will not be enabled by default. It includes all scenarii and world generation modules, * so the default game is a standard one, and the kick module, as spectators are better for most admins. */ - private final static List<Class<? extends UHModule>> DISABLED_BY_DEFAULT = Arrays.asList( + private final static List<Class<? extends QSGModule>> DISABLED_BY_DEFAULT = Arrays.asList( KickModule.class, PomfModule.class, @@ -87,7 +87,7 @@ public class ModulesManager extends ZLibComponent implements Listener /** * All the registered modules. */ - private Map<Class<? extends UHModule>, ModuleWrapper> modules = new HashMap<>(); + private Map<Class<? extends QSGModule>, ModuleWrapper> modules = new HashMap<>(); /** * These loads times were loaded using {@link #loadModules(ModuleLoadTime)} and are stored to not @@ -112,9 +112,9 @@ public void registerBuiltInModules() { final Class<?> potentialModuleClass = classInfo.load(); - if (UHModule.class.isAssignableFrom(potentialModuleClass)) + if (QSGModule.class.isAssignableFrom(potentialModuleClass)) { - registerModule((Class<? extends UHModule>) potentialModuleClass, !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); + registerModule((Class<? extends QSGModule>) potentialModuleClass, !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); i++; } } @@ -142,7 +142,7 @@ public Collection<ModuleWrapper> getModules() * @param modules the module's class, that must accept a zero-arguments constructor. */ @SafeVarargs - public final void registerModules(final Class<? extends UHModule>... modules) + public final void registerModules(final Class<? extends QSGModule>... modules) { Arrays.stream(modules).forEach(module -> registerModule(module, true)); } @@ -153,7 +153,7 @@ public final void registerModules(final Class<? extends UHModule>... modules) * @param module the module's class, that must accept a zero-arguments constructor. * @param initiallyEnabled {@code true} if this module, according to the configuration file, should be enabled at startup. */ - public void registerModule(final Class<? extends UHModule> module, final boolean initiallyEnabled) + public void registerModule(final Class<? extends QSGModule> module, final boolean initiallyEnabled) { if (!modules.containsKey(module)) { @@ -206,11 +206,11 @@ public void registerModule(final String module) */ public void registerModule(final String module, boolean initiallyEnabled) { - final Class<? extends UHModule> moduleClass = ModulesUtils.getClassFromName( + final Class<? extends QSGModule> moduleClass = ModulesUtils.getClassFromName( module.replace('-', '.'), MODULES_PACKAGE, "Module", - UHModule.class + QSGModule.class ); if (moduleClass != null) @@ -274,7 +274,7 @@ public boolean isLoaded(final ModuleLoadTime loadTime) * @param module The module's class. * @return {@code true} if loaded. */ - public boolean isLoaded(final Class<? extends UHModule> module) + public boolean isLoaded(final Class<? extends QSGModule> module) { final ModuleWrapper wrapper = modules.get(module); @@ -290,9 +290,9 @@ public boolean isLoaded(final Class<? extends UHModule> module) * * @return The module's instance. */ - public static <M extends UHModule> M getModule(final Class<M> moduleClass) + public static <M extends QSGModule> M getModule(final Class<M> moduleClass) { - final ModuleWrapper module = UR.get().getModulesManager().modules.get(moduleClass); + final ModuleWrapper module = QSG.get().getModulesManager().modules.get(moduleClass); if (module == null || !module.isLoaded()) return null; else return (M) module.get(); @@ -344,8 +344,8 @@ private void collectCommandsFromModules() { final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); - String mutPrefix = UR.get().getDescription().getPrefix(); - if (mutPrefix == null) mutPrefix = UR.get().getDescription().getName().toLowerCase(); + String mutPrefix = QSG.get().getDescription().getPrefix(); + if (mutPrefix == null) mutPrefix = QSG.get().getDescription().getName().toLowerCase(); final String prefix = mutPrefix; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java index 554c2e5..2764840 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/UHModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java @@ -29,25 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.scoreboard.Sidebar; -import fr.zcraft.zlib.core.ZLibComponent; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; +package eu.carrade.amaury.quartzsurvivalgames.core; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.scoreboard.Sidebar; +import fr.zcraft.quartzlib.core.ZLibComponent; import java.util.List; import java.util.Map; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; -public abstract class UHModule extends ZLibComponent implements Listener -{ +public abstract class QSGModule extends ZLibComponent implements Listener { protected ModuleLogger logger; - public UHModule() - { + public QSGModule() { logger = new ModuleLogger(getClass()); } @@ -55,48 +53,54 @@ public UHModule() * Called only when the module is enabled late, i.e. not when configured in * the {@link ModuleInfo}. This happens for modules loaded manually by the * players, if the module allows such late load. - * + * <p> * This method will not be called for normal loads following the module info. - * + * <p> * It will be called after {@link #onEnable()}. */ - public void onLateEnable() {} + public void onLateEnable() { + } /** * Use this method to register sub-commands into the /uh command. * * @return A list of command classes to register. */ - public List<Class<? extends Command>> getCommands() { return null; } + public List<Class<? extends Command>> getCommands() { + return null; + } /** * Use this method to register new commands aliases. * * @return The command aliases to add, map from the alias to the command class. */ - public Map<String, Class<? extends Command>> getCommandsAliases() { return null; } + public Map<String, Class<? extends Command>> getCommandsAliases() { + return null; + } /** * This method will be called before calling {@link #injectIntoSidebar(Player, SidebarInjector)} so you can * prepare and cache lines shared between all players. - * + * <p> * Be careful as this method will be called every ten ticks. * * @see Sidebar#preRender() */ - public void prepareInjectionIntoSidebar() {} + public void prepareInjectionIntoSidebar() { + } /** * Use this method to inject content into the game's sidebar. - * + * <p> * Be careful as this method will be called every ten ticks for each player. * * @param injector The injector will allows you to inject content in specific parts of the sidebar. */ - public void injectIntoSidebar(final Player player, final SidebarInjector injector) {} + public void injectIntoSidebar(final Player player, final SidebarInjector injector) { + } - public ModuleLogger log() - { + public ModuleLogger log() { return logger; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/AllModulesLoadedEvent.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/AllModulesLoadedEvent.java index 107ffa8..1ec8f6e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/AllModulesLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/AllModulesLoadedEvent.java @@ -29,9 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; +package eu.carrade.amaury.quartzsurvivalgames.core.events; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -39,35 +40,30 @@ /** * Fired when all modules registered in the config are loaded (both at startup and post-world). */ -public class AllModulesLoadedEvent extends Event -{ +public class AllModulesLoadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final ModuleLoadTime loadTime; - public AllModulesLoadedEvent(ModuleLoadTime loadTime) - { + public AllModulesLoadedEvent(ModuleLoadTime loadTime) { this.loadTime = loadTime; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * This event is launched for each batch of modules load. This represents the batch. * * @return the moment when these modules were all loaded. */ - public ModuleLoadTime getLoadTime() - { + public ModuleLoadTime getLoadTime() { return loadTime; } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleDisabledEvent.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleDisabledEvent.java index 2d26bf0..8644f3f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleDisabledEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleDisabledEvent.java @@ -29,48 +29,43 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +package eu.carrade.amaury.quartzsurvivalgames.core.events; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** * Fired after a module was disabled. - * + * <p> * The module can be loaded at this point. If so, it will be unloaded soon after * this event was called. */ -public class ModuleDisabledEvent extends Event -{ +public class ModuleDisabledEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final ModuleWrapper module; - public ModuleDisabledEvent(final ModuleWrapper module) - { + public ModuleDisabledEvent(final ModuleWrapper module) { this.module = module; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * @return the unloaded module. */ - public ModuleWrapper getModule() - { + public ModuleWrapper getModule() { return module; } - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleEnabledEvent.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleEnabledEvent.java index 9f84e51..79bcbf5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleEnabledEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleEnabledEvent.java @@ -29,9 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +package eu.carrade.amaury.quartzsurvivalgames.core.events; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -40,35 +41,29 @@ * Fired after a module was enabled. * This does not implies that the module is loaded. */ -public class ModuleEnabledEvent extends Event -{ +public class ModuleEnabledEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final ModuleWrapper module; - public ModuleEnabledEvent(final ModuleWrapper module) - { + public ModuleEnabledEvent(final ModuleWrapper module) { this.module = module; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * @return the enabled module. */ - public ModuleWrapper getModule() - { + public ModuleWrapper getModule() { return module; } - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleLoadedEvent.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleLoadedEvent.java index af37e41..b240dc2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleLoadedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleLoadedEvent.java @@ -29,9 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +package eu.carrade.amaury.quartzsurvivalgames.core.events; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -39,50 +40,43 @@ /** * Fired after a module was loaded. */ -public class ModuleLoadedEvent extends Event -{ +public class ModuleLoadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final ModuleWrapper module; private final boolean loadedLate; - public ModuleLoadedEvent(final ModuleWrapper module) - { + public ModuleLoadedEvent(final ModuleWrapper module) { this(module, false); } - public ModuleLoadedEvent(final ModuleWrapper module, boolean loadedLate) - { + public ModuleLoadedEvent(final ModuleWrapper module, boolean loadedLate) { this.module = module; this.loadedLate = loadedLate; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * @return the loaded module. */ - public ModuleWrapper getModule() - { + public ModuleWrapper getModule() { return module; } /** * @return {@code true} if the module is not loaded when specified in its - * {@link eu.carrade.amaury.UHCReloaded.core.ModuleInfo properties}. + * {@link eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo properties}. */ - public boolean isLoadedLate() - { + public boolean isLoadedLate() { return loadedLate; } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleUnloadedEvent.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleUnloadedEvent.java index 6793dce..8d0eae0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/core/events/ModuleUnloadedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/events/ModuleUnloadedEvent.java @@ -29,50 +29,45 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.core.events; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; +package eu.carrade.amaury.quartzsurvivalgames.core.events; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** * Fired after a module was unloaded. - * + * <p> * When this event is called, the embed instance is dying, unregistered from all * events managers and soon-to-be-deleted. At the time the event is called, you * can still get the instance using {@link ModuleWrapper#get()}, but don't try * that on a delayed task as the instance will no longer be available. */ -public class ModuleUnloadedEvent extends Event -{ +public class ModuleUnloadedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final ModuleWrapper module; - public ModuleUnloadedEvent(final ModuleWrapper module) - { + public ModuleUnloadedEvent(final ModuleWrapper module) { this.module = module; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * @return the unloaded module. */ - public ModuleWrapper getModule() - { + public ModuleWrapper getModule() { return module; } - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java index 50f943d..e597eca 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java @@ -29,27 +29,27 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.commands.BorderCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.Titles; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; + +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.commands.BorderCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.events.BorderChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.Titles; import org.bukkit.*; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -71,7 +71,7 @@ can_be_unloaded = false, internal = true ) -public class BorderModule extends UHModule +public class BorderModule extends QSGModule { private MapShape mapShape = null; private WorldBorder border = null; @@ -90,7 +90,7 @@ public void onEnable() mapShape = Config.SHAPE.get(); - final World world = UHCReloaded.get().getWorld(World.Environment.NORMAL); + final World world = QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL); border = WorldBorder.getInstance(world, Config.MOTOR.get(), mapShape); @@ -112,7 +112,7 @@ public List<Class<? extends Command>> getCommands() @Override public void prepareInjectionIntoSidebar() { - if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) return; + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) return; sidebar.clear(); @@ -146,14 +146,14 @@ public void prepareInjectionIntoSidebar() if (minX == minZ && maxX == maxZ) { /// Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxZ))); + sidebar.add(I.t("{white}{0} {1}", QSGUtils.integerToStringWithSign(minX), QSGUtils.integerToStringWithSign(maxZ))); } else { /// Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}X: {white}{0} {1}", UHUtils.integerToStringWithSign(minX), UHUtils.integerToStringWithSign(maxX))); + sidebar.add(I.t("{gray}X: {white}{0} {1}", QSGUtils.integerToStringWithSign(minX), QSGUtils.integerToStringWithSign(maxX))); /// Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}Z: {white}{0} {1}", UHUtils.integerToStringWithSign(minZ), UHUtils.integerToStringWithSign(maxZ))); + sidebar.add(I.t("{gray}Z: {white}{0} {1}", QSGUtils.integerToStringWithSign(minZ), QSGUtils.integerToStringWithSign(maxZ))); } } } @@ -162,7 +162,7 @@ public void prepareInjectionIntoSidebar() @Override public void injectIntoSidebar(Player player, SidebarInjector injector) { - if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; injector.injectLines(SidebarInjector.SidebarPriority.MIDDLE_BOTTOM, true, sidebar); } @@ -251,7 +251,7 @@ public double getDistanceToBorder(Location location, double diameter) */ public Set<Player> getPlayersOutside(int diameter) { - return UR.module(GameModule.class) + return QSG.module(GameModule.class) .getAliveConnectedPlayers().stream() .filter(player -> !isInsideBorder(player.getLocation(), diameter)) .collect(Collectors.toSet()); @@ -288,7 +288,7 @@ public void setCurrentBorderDiameter(int diameter) */ public void sendCheckMessage(final CommandSender to, final int diameter) { - final BorderModule borderModule = UR.module(BorderModule.class); + final BorderModule borderModule = QSG.module(BorderModule.class); final Set<Player> playersOutside = borderModule.getPlayersOutside(diameter); if (playersOutside.size() == 0) @@ -325,7 +325,7 @@ private void scheduleBorderReduction() if (Config.SHRINKING.ENABLED.get()) { RunTask.later(() -> { - if (UR.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; final int secondsPerBlock = (int) Math.rint(Config.SHRINKING.SHRINKS_DURING.get().getSeconds() / (border.getDiameter() - Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())) * 2; @@ -333,8 +333,8 @@ private void scheduleBorderReduction() Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); - Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.t("{red}{bold}The border begins to shrink..."))); - Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get()))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.t("{red}{bold}The border begins to shrink..."))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get()))); }, Config.SHRINKING.STARTS_AFTER.get().getSeconds() * 20L); scheduleBorderReductionWarning(new TimeDelta(1, 0, 0)); @@ -348,10 +348,10 @@ private void scheduleBorderReductionWarning(final TimeDelta warnBefore) if (Config.SHRINKING.STARTS_AFTER.get().greaterThan(warnBefore.add(new TimeDelta(0, 5, 0)))) { RunTask.later(() -> { - if (UR.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; Bukkit.broadcastMessage(""); - Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Border"), I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60)))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60)))); Bukkit.broadcastMessage(""); }, Config.SHRINKING.STARTS_AFTER.get().subtract(warnBefore).getSeconds() * 20L); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java index 8f50934..ef3d1a0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java @@ -29,18 +29,18 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; -import eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders.WorldBorder; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders.WorldBorder; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java index 362a2af..ce19cea 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/MapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; -import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.CircularMapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.MapShapeDescriptor; -import eu.carrade.amaury.UHCReloaded.modules.core.border.shapes.SquaredMapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes.CircularMapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes.MapShapeDescriptor; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes.SquaredMapShape; public enum MapShape diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java index 9553ae1..7b75c08 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/WorldBorderDependency.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java @@ -30,11 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; import com.wimbli.WorldBorder.WorldBorder; -import fr.zcraft.zlib.external.ExternalPluginComponent; -import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.quartzlib.external.ExternalPluginComponent; +import fr.zcraft.quartzlib.tools.PluginLogger; public class WorldBorderDependency extends ExternalPluginComponent<WorldBorder> diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java index 88cf573..02858fc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/commands/BorderCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; @@ -50,7 +50,7 @@ public class BorderCommand extends Command @Override protected void run() throws CommandException { - final BorderModule border = UR.module(BorderModule.class); + final BorderModule border = QSG.module(BorderModule.class); // No arguments: displays current size if (args.length == 0) @@ -80,7 +80,7 @@ protected void run() throws CommandException sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); - if (!UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) + if (!QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java index 67bb055..f295368 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/events/BorderChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.events; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java index 9539cb6..954644d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/CircularMapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java index b156f88..5ad061c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/MapShapeDescriptor.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java index d842194..2a90a67 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/shapes/SquaredMapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.shapes; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java index c1e771e..d2a87c9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; import com.wimbli.WorldBorder.BorderData; import com.wimbli.WorldBorder.Config; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.scheduler.BukkitTask; @@ -68,9 +68,9 @@ public BrettflanWorldBorder(final World world) { this.world = world; - if (UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) + if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - border = UR.module(BorderModule.class).getWorldBorderDependency().getWorldBorder().getWorldBorder(world.getName()); + border = QSG.module(BorderModule.class).getWorldBorderDependency().getWorldBorder().getWorldBorder(world.getName()); if (border == null) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java index c513ed7..fe87942 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java index 7568cfe..479841d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.modules.core.border.Config; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.Config; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java index dcb969d..bf0b858 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.border.worldborders; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.Location; import org.bukkit.World; @@ -176,7 +176,7 @@ public static WorldBorder getInstance(final World world, final WorldBorderMotor // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). if (shape == MapShape.CIRCULAR) { - if (UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) + if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { return new BrettflanWorldBorder(world); } @@ -187,7 +187,7 @@ public static WorldBorder getInstance(final World world, final WorldBorderMotor } else { - if (motor == WorldBorderMotor.VANILLA || !UR.module(BorderModule.class).getWorldBorderDependency().isEnabled()) + if (motor == WorldBorderMotor.VANILLA || !QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { return new VanillaWorldBorder(world); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java index 2e11528..2ecb488 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java index 384d1ba..942ecb7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java @@ -29,34 +29,34 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.KillCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.ResurrectCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.game.commands.StartCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.*; -import eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers.GameBeginning; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ActionBar; -import fr.zcraft.zlib.tools.text.Titles; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands.KillCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands.ResurrectCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands.StartCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.TeamDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.*; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.submanagers.GameBeginning; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.Teleporter; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.ActionBar; +import fr.zcraft.quartzlib.tools.text.Titles; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; @@ -83,7 +83,7 @@ internal = true, can_be_unloaded = false ) -public class GameModule extends UHModule implements Listener +public class GameModule extends QSGModule implements Listener { /** * The current game phase (initialized to {@link GamePhase#WAIT} in the @@ -478,11 +478,11 @@ public void run() countdownIndex.set(0); } - new UHSound(1f, countdownNotes[countdownIndex.get()], "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT").broadcast(); + new QSGSound(1f, countdownNotes[countdownIndex.get()], "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT").broadcast(); } else { - new UHSound("WITHER_DEATH").broadcast(); + new QSGSound("WITHER_DEATH").broadcast(); } if (countdown.get() == 0) @@ -525,7 +525,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) Bukkit.getOnlinePlayers().stream() .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) - .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) + .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) .forEach(player -> { // We need an unique name for the team. @@ -550,7 +550,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) ZTeams.get().getTeams().stream() .flatMap(team -> team.getPlayers().stream()) .map(OfflinePlayer::getUniqueId) - .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) + .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) .forEach(alivePlayers::add); updateAliveTeams(); @@ -560,7 +560,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) int spawnsNeeded = teleportationMode == TeleportationMode.IGNORE_TEAMS ? alivePlayers.size() : aliveTeams.size(); - if (UR.module(SpawnsModule.class).getSpawnPoints().size() < spawnsNeeded) + if (QSG.module(SpawnsModule.class).getSpawnPoints().size() < spawnsNeeded) { log().broadcastAdministrative(I.t("{ce}Unable to start the game: not enough teleportation spots.")); log().broadcastAdministrative(I.t("{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to generate the missing spawns automatically.")); @@ -591,7 +591,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // Preparation of the spawn points. - final List<Location> spawnPoints = UR.module(SpawnsModule.class).getSpawnPoints(); + final List<Location> spawnPoints = QSG.module(SpawnsModule.class).getSpawnPoints(); Collections.shuffle(spawnPoints); final Queue<Location> unusedSpawnPoints = new ArrayDeque<>(spawnPoints); @@ -756,7 +756,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) }); // Just in case... - UR.get().getWorlds().forEach(world -> world.setGameRuleValue("keepInventory", Boolean.FALSE.toString())); + QSG.get().getWorlds().forEach(world -> world.setGameRuleValue("keepInventory", Boolean.FALSE.toString())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java index fdcb545..c56a7b7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/GamePhase.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java index b9264f6..03c6e13 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/KillCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -67,7 +67,7 @@ protected void run() throws CommandException return; } - if (UR.module(GameModule.class).isAlive(player)) + if (QSG.module(GameModule.class).isAlive(player)) { if (player.isOnline()) { @@ -79,7 +79,7 @@ protected void run() throws CommandException else { // We only kill the player this way if he is offline. - UR.module(GameModule.class).kill(player); + QSG.module(GameModule.class).kill(player); } success(I.t("{cs}The player {0} is now marked as dead.", player.getName())); @@ -96,7 +96,7 @@ protected List<String> complete() if (args.length == 1) { return getMatchingSubset( - UR.module(GameModule.class) + QSG.module(GameModule.class) .getAlivePlayers().stream() .map(OfflinePlayer::getName) .collect(Collectors.toList()), diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java index c7780c3..874fbec 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/ResurrectCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -66,7 +66,7 @@ protected void run() throws CommandException { error(I.t("{ce}This player was never seen on this server.")); } - else if (UR.module(GameModule.class).resurrect(player)) + else if (QSG.module(GameModule.class).resurrect(player)) { success(I.t("{0} was resurrected.", player.getName())); } @@ -79,7 +79,7 @@ else if (UR.module(GameModule.class).resurrect(player)) @Override protected List<String> complete() { - final GameModule game = UR.module(GameModule.class); + final GameModule game = QSG.module(GameModule.class); if (args.length == 1) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java index 737b4b6..ec8bf51 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/commands/StartCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.commands.WithFlags; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.commands.WithFlags; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.entity.Player; import java.util.List; @@ -52,7 +52,7 @@ public class StartCommand extends Command @Override protected void run() throws CommandException { - final GameModule game = UR.module(GameModule.class); + final GameModule game = QSG.module(GameModule.class); switch (game.getPhase()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java index 0cd0e62..2b5d889 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/game/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.game; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java index 764f700..2259f42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/AlivePlayerDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players; import org.bukkit.OfflinePlayer; import org.bukkit.event.Cancellable; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java index 69bd949..c0156bd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/PlayerResurrectedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players; import org.bukkit.OfflinePlayer; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java index 423594e..c3d5e90 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/players/TeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.players; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players; import fr.zcraft.zteams.ZTeam; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java index 632b5bd..4004a17 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/AfterTeleportationPhaseEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java index cadc083..5c4988a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java index 45ed3c7..c1fab73 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java index d8c0858..d336989 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java index eb4d106..3052a6f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.events.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java index 66ce759..d765a7e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.submanagers; - -import eu.carrade.amaury.UHCReloaded.modules.core.game.Config; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; -import eu.carrade.amaury.UHCReloaded.utils.Run; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLibComponent; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.submanagers; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.EntitiesUtils; +import eu.carrade.amaury.quartzsurvivalgames.utils.Run; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -88,7 +88,7 @@ private void onGameStarts(GamePhaseChangedEvent ev) I.t("{green}All damages are disabled"), second -> I.tn("{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", (int) second), I.t("{yellow}{bold}Over! {yellow}You are now vulnerable..."), - () -> UR.game().getAliveConnectedPlayers(), + () -> QSG.game().getAliveConnectedPlayers(), () -> { inGracePeriod = false; @@ -113,7 +113,7 @@ private void onGameStarts(GamePhaseChangedEvent ev) second -> I.tn("{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", (int) second), I.t("{yellow}{bold}Now allowed! {yellow}Beware..."), (short) 10, - () -> UR.game().getAliveConnectedPlayers(), + () -> QSG.game().getAliveConnectedPlayers(), () -> { setPVP(true); Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); @@ -233,6 +233,6 @@ private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) private void setPVP(final boolean pvp) { - UR.get().getWorlds().forEach(world -> world.setPVP(pvp)); + QSG.get().getWorlds().forEach(world -> world.setPVP(pvp)); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java index 347d1c8..49f4d5d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationMode.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; public enum TeleportationMode { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java index d0a7446..a2ccc3e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/TeleportationRunnable.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.tools.Callback; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.tools.Callback; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayDeque; @@ -76,21 +76,21 @@ public void run() { UUID player = teleportationQueue.remove(); - UHUtils.callIfDefined(onTeleportation, player); + QSGUtils.callIfDefined(onTeleportation, player); if (teleporter.teleportPlayer(player, false)) { - UHUtils.callIfDefined(onTeleportationSuccessful, player); + QSGUtils.callIfDefined(onTeleportationSuccessful, player); } else { - UHUtils.callIfDefined(onTeleportationFailed, player); + QSGUtils.callIfDefined(onTeleportationFailed, player); failed.add(player); } } catch (NoSuchElementException e) // Queue empty { - UHUtils.callIfDefined(onTeleportationProcessFinished, failed); + QSGUtils.callIfDefined(onTeleportationProcessFinished, failed); cancel(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java index 9d9d83b..37188f7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/game/teleporter/Teleporter.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; -import eu.carrade.amaury.UHCReloaded.modules.core.game.Config; -import fr.zcraft.zlib.tools.Callback; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config; +import fr.zcraft.quartzlib.tools.Callback; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java similarity index 71% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java index 1fc44d9..c81aa52 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/ModulesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java @@ -29,22 +29,22 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules; import com.google.common.collect.ImmutableMap; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModuleCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ModulesCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.commands.ConfigurationCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ModuleCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ModulesCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ConfigurationCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -61,7 +61,7 @@ icon = Material.COMMAND, can_be_unloaded = false ) -public class ModulesModule extends UHModule +public class ModulesModule extends QSGModule { @Override public List<Class<? extends Command>> getCommands() @@ -85,7 +85,7 @@ public Map<String, Class<? extends Command>> getCommandsAliases() @Override public void injectIntoSidebar(Player player, SidebarInjector injector) { - if (player.isOp() && UR.module(GameModule.class).getPhase() == GamePhase.WAIT) // TODO Permissions + if (player.isOp() && QSG.module(GameModule.class).getPhase() == GamePhase.WAIT) // TODO Permissions { injector.injectLines( true, diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java index b95a9df..da75479 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ConfigurationCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.gui.Gui; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.MainConfigGUI; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.gui.Gui; @CommandInfo (name = "config") public class ConfigurationCommand extends Command diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java index 23777a9..74df62f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModuleCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.ChatColor; import java.text.Normalizer; @@ -64,7 +64,7 @@ protected void run() throws CommandException ModuleWrapper module = null; - for (final ModuleWrapper m : UR.get().getModulesManager().getModules()) + for (final ModuleWrapper m : QSG.get().getModulesManager().getModules()) { if (getModuleKey(m).equalsIgnoreCase(args[1])) { @@ -124,7 +124,8 @@ else if (module.setEnabled(false)) protected List<String> complete() { if (args.length == 1) return getMatchingSubset(args[0], "enable", "disable"); - else if (args.length == 2) return getMatchingSubset(UR.get().getModulesManager().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); + else if (args.length == 2) return getMatchingSubset( + QSG.get().getModulesManager().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); else return null; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java index a44967f..c247638 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/commands/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.commands; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.commands.Commands; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.components.rawtext.RawTextPart; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; + +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.commands.Commands; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.components.rawtext.RawTextPart; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -67,7 +67,7 @@ protected void run() throws CommandException return module1.getName().compareTo(module2.getName()); }); - modules.addAll(UHCReloaded.get().getModulesManager().getModules()); + modules.addAll(QuartzSurvivalGames.get().getModulesManager().getModules()); success(I.tn("{0} module registered {gray}(hover for details)", "{0} modules registered {gray}(hover for details)", modules.size())); modules.forEach(module -> { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java index bd4db7a..898b03d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/MainConfigGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java @@ -31,24 +31,24 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait.Config; -import eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait.WaitModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules.ModulesListGUI; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start.StartGameGUI; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.gui.ActionGui; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.PromptGui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui; + +import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.Config; +import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.WaitModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules.ModulesListGUI; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.start.StartGameGUI; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.gui.ActionGui; +import fr.zcraft.quartzlib.components.gui.Gui; +import fr.zcraft.quartzlib.components.gui.GuiAction; +import fr.zcraft.quartzlib.components.gui.PromptGui; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.guis.TeamsSelectorGUI; import org.bukkit.*; @@ -69,15 +69,15 @@ public class MainConfigGUI extends ActionGui protected void onUpdate() { setTitle(I.tl(getPlayerLocale(), "{black}Game Configuration")); - setHeight(UR.game().currentPhaseAfter(GamePhase.WAIT) ? 3 : 5); + setHeight(QSG.game().currentPhaseAfter(GamePhase.WAIT) ? 3 : 5); - final Set<String> alivePlayers = (UR.game().currentPhaseBefore(GamePhase.IN_GAME) - ? Bukkit.getOnlinePlayers().stream().filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) - : UR.game().getAlivePlayers().stream()) + final Set<String> alivePlayers = (QSG.game().currentPhaseBefore(GamePhase.IN_GAME) + ? Bukkit.getOnlinePlayers().stream().filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) + : QSG.game().getAlivePlayers().stream()) .map(OfflinePlayer::getName) .collect(Collectors.toSet()); - final Set<String> spectators = UR.module(SpectatorsModule.class).getSpectators().stream() + final Set<String> spectators = QSG.module(SpectatorsModule.class).getSpectators().stream() .map(Bukkit::getOfflinePlayer) .map(OfflinePlayer::getName) .collect(Collectors.toSet()); @@ -92,7 +92,7 @@ protected void onUpdate() ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} player", "{0} players", alivePlayers.size()), " - ", - I.tln(getPlayerLocale(), "{0} spectator", "{0} spectators", UR.module(SpectatorsModule.class).getSpectators().size()) + I.tln(getPlayerLocale(), "{0} spectator", "{0} spectators", QSG.module(SpectatorsModule.class).getSpectators().size()) ) .loreSeparator() .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Players")) @@ -104,7 +104,8 @@ protected void onUpdate() .longLore(ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Actions on players coming soon: in the mean time, use commands."), 38) ); - action("teams", 12, new ItemStackBuilder(UR.module(WaitModule.class) != null ? Config.TEAM_SELECTOR.ITEM.get() : Material.NETHER_STAR) + action("teams", 12, new ItemStackBuilder( + QSG.module(WaitModule.class) != null ? Config.TEAM_SELECTOR.ITEM.get() : Material.NETHER_STAR) .title(ChatColor.AQUA, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teams")) .amount(Math.max(ZTeams.get().countTeams(), 1)) .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", ZTeams.get().countTeams())) @@ -120,14 +121,14 @@ protected void onUpdate() .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click to update the game title. It is displayed on the sidebar and may be used by other modules (like the reports one)."), 38) .loreSeparator() .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Current Title")) - .longLore(UHConfig.TITLE.get()) + .longLore(QSGConfig.TITLE.get()) .loreSeparator() .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to change the title")) ); - final int modules = UR.get().getModulesManager().getModules().size(); - final int modulesEnabled = (int) UR.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); - final int modulesLoaded = (int) UR.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); + final int modules = QSG.get().getModulesManager().getModules().size(); + final int modulesEnabled = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); + final int modulesLoaded = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); action("modules", 16, new ItemStackBuilder(Material.COMMAND) .title(ChatColor.LIGHT_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Modules")) @@ -145,7 +146,7 @@ protected void onUpdate() .lore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage modules and their configuration")) ); - if (!UR.game().currentPhaseAfter(GamePhase.WAIT)) + if (!QSG.game().currentPhaseAfter(GamePhase.WAIT)) { action("start", 31, new ItemStackBuilder(Material.INK_SACK) // FIXME 1.13 .data(DyeColor.LIME.getDyeData()) @@ -196,7 +197,7 @@ protected void teams() @GuiAction protected void title() { - PromptGui.prompt(getPlayer(), newTitle -> UHConfig.TITLE.set(ChatColor.translateAlternateColorCodes('&', newTitle), false), UHConfig.TITLE.get().replace(ChatColor.COLOR_CHAR, '&'), this); + PromptGui.prompt(getPlayer(), newTitle -> QSGConfig.TITLE.set(ChatColor.translateAlternateColorCodes('&', newTitle), false), QSGConfig.TITLE.get().replace(ChatColor.COLOR_CHAR, '&'), this); } @GuiAction diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java index b7a80d1..aac7dfa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.mojang.MojangHead; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import fr.zcraft.quartzlib.components.gui.GuiAction; +import fr.zcraft.quartzlib.components.gui.GuiUtils; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.mojang.MojangHead; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java index 453d915..5a6a5d7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/FramedModuleGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java @@ -31,11 +31,11 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import fr.zcraft.zlib.components.gui.ActionGui; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import fr.zcraft.quartzlib.components.gui.ActionGui; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.zteams.colors.ColorsUtils; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java index 3baf304..c0fa7cc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/modules/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.modules; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.gui.ExplorerGui; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.mojang.MojangHead; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.gui.ExplorerGui; +import fr.zcraft.quartzlib.components.gui.Gui; +import fr.zcraft.quartzlib.components.gui.GuiAction; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.mojang.MojangHead; import fr.zcraft.zteams.colors.ColorsUtils; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -76,7 +76,7 @@ protected void onUpdate() setMode(Mode.READONLY); setKeepHorizontalScrollingSpace(true); - final ModuleWrapper[] modules = UR.get().getModulesManager().getModules().stream() + final ModuleWrapper[] modules = QSG.get().getModulesManager().getModules().stream() .filter(module -> filterCategory == null || module.getCategory() == filterCategory) .filter(module -> { switch (filterState) @@ -117,11 +117,12 @@ protected void onUpdate() if (filterCategory == null) { - setTitle(I.t("{black}All modules {darkgray}({0})", UR.get().getModulesManager().getModules().size())); + setTitle(I.t("{black}All modules {darkgray}({0})", QSG.get().getModulesManager().getModules().size())); } else { - setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, UR.get().getModulesManager().getModules().size())); + setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, QSG + .get().getModulesManager().getModules().size())); } @@ -237,11 +238,11 @@ protected ItemStack getPickedUpItem(final ModuleWrapper module) { if (module.isEnabled()) { - UR.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {green}enabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); + QSG.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {green}enabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); } else { - UR.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {red}disabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); + QSG.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {red}disabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); } } @@ -260,14 +261,15 @@ protected void onRightClick(final ModuleWrapper module) @GuiAction protected void switch_category(final InventoryClickEvent ev) { - filterCategory = UHUtils.getNextElement(filterCategory, ev.getClick() == ClickType.RIGHT ? -1 : 1, true, ModuleCategory.class); + filterCategory = QSGUtils + .getNextElement(filterCategory, ev.getClick() == ClickType.RIGHT ? -1 : 1, true, ModuleCategory.class); update(); } @GuiAction protected void switch_status(final InventoryClickEvent ev) { - filterState = UHUtils.getNextElement(filterState, ev.getClick() == ClickType.RIGHT ? -1 : 1); + filterState = QSGUtils.getNextElement(filterState, ev.getClick() == ClickType.RIGHT ? -1 : 1); update(); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java index 7b86aa8..183cddb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/modules/gui/start/StartGameGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java @@ -31,19 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.start; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.start; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.TeleportationMode; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.gui.ActionGui; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.gui.GuiAction; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.mojang.MojangHead; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.MainConfigGUI; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.gui.ActionGui; +import fr.zcraft.quartzlib.components.gui.Gui; +import fr.zcraft.quartzlib.components.gui.GuiAction; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.mojang.MojangHead; import fr.zcraft.zteams.ZTeams; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -97,7 +97,7 @@ protected void onUpdate() @GuiAction protected void teleportation_mode() { - mode = UHUtils.getNextElement(mode, 1); + mode = QSGUtils.getNextElement(mode, 1); update(); } @@ -117,10 +117,10 @@ protected void slow() private void start(final boolean slow) { - UR.game().setTeleportationMode(mode); - UR.game().setSlowMode(slow); + QSG.game().setTeleportationMode(mode); + QSG.game().setSlowMode(slow); - UR.game().setPhase(GamePhase.STARTING); + QSG.game().setPhase(GamePhase.STARTING); } @GuiAction diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java index 373ebdd..81aa65c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.core.ModuleWrapper; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.components.scoreboard.Sidebar; -import fr.zcraft.zlib.components.scoreboard.SidebarMode; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.components.scoreboard.Sidebar; +import fr.zcraft.quartzlib.components.scoreboard.SidebarMode; import org.bukkit.entity.Player; import java.util.List; @@ -54,10 +54,10 @@ public GameSidebar() @Override public void preRender() { - UHCReloaded.get().getModulesManager().getModules().stream() + QuartzSurvivalGames.get().getModulesManager().getModules().stream() .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) - .forEach(UHModule::prepareInjectionIntoSidebar); + .forEach(QSGModule::prepareInjectionIntoSidebar); } @Override @@ -65,7 +65,7 @@ public List<String> getContent(Player player) { final SidebarInjector injector = new SidebarInjector(); - UHCReloaded.get().getModulesManager().getModules().stream() + QuartzSurvivalGames.get().getModulesManager().getModules().stream() .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) .forEach(module -> module.injectIntoSidebar(player, injector)); @@ -76,6 +76,6 @@ public List<String> getContent(Player player) @Override public String getTitle(Player player) { - return UHConfig.TITLE.get(); + return QSGConfig.TITLE.get(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java index e22d761..820381f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarInjector.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; import java.util.Arrays; import java.util.Collection; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java index b79a205..add1706 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.sidebar; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -49,7 +49,7 @@ internal = true, can_be_unloaded = false ) -public class SidebarModule extends UHModule +public class SidebarModule extends QSGModule { private GameSidebar sidebar; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java index 75918a6..4ea9d22 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import org.bukkit.Location; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java index 56daea5..e6ea8e1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/Generator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java @@ -30,15 +30,15 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.CircularSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.GridSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.RandomSpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.SpawnPointsGenerator; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.CircularSpawnPointsGenerator; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.GridSpawnPointsGenerator; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.RandomSpawnPointsGenerator; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.SpawnPointsGenerator; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java index 7ec8e95..7a4245f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java @@ -29,22 +29,22 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.commands.SpawnsCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators.SpawnPointsGenerator; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns; + +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.BeforeTeleportationPhaseEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.commands.SpawnsCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.UnknownGeneratorException; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.SpawnPointsGenerator; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -68,7 +68,7 @@ internal = true, can_be_unloaded = false ) -public class SpawnsModule extends UHModule +public class SpawnsModule extends QSGModule { private List<Location> spawnPoints = new LinkedList<>(); @@ -91,7 +91,7 @@ public List<Class<? extends Command>> getCommands() */ public void addSpawnPoint(final Vector vec) { - addSpawnPoint(UHCReloaded.get().getWorld(World.Environment.NORMAL), vec.getX(), vec.getZ()); + addSpawnPoint(QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL), vec.getX(), vec.getZ()); } /** @@ -102,7 +102,7 @@ public void addSpawnPoint(final Vector vec) */ public void addSpawnPoint(final Double x, final Double z) { - addSpawnPoint(UHCReloaded.get().getWorld(World.Environment.NORMAL), x, z); + addSpawnPoint(QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL), x, z); } /** @@ -137,7 +137,7 @@ public void addSpawnPoint(final Location location) } else { - final Location safeSpot = UHUtils.searchSafeSpot(location); + final Location safeSpot = QSGUtils.searchSafeSpot(location); if (safeSpot == null) { throw new RuntimeException("Unable to find a safe spot to set the spawn point " + location.toString()); @@ -146,7 +146,7 @@ public void addSpawnPoint(final Location location) spawnPoint.setY(safeSpot.getY()); } - if (!UR.module(BorderModule.class).isInsideBorder(spawnPoint)) + if (!QSG.module(BorderModule.class).isInsideBorder(spawnPoint)) { throw new IllegalArgumentException("The given spawn location is outside the current border"); } @@ -295,11 +295,11 @@ public void generateSpawnPoints(final SpawnPointsGenerator generator, final Worl @EventHandler public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) { - final GameModule game = UR.module(GameModule.class); + final GameModule game = QSG.module(GameModule.class); - final World normalWorld = UR.get().getWorld(World.Environment.NORMAL); + final World normalWorld = QSG.get().getWorld(World.Environment.NORMAL); - final int regionDiameter = UR.module(BorderModule.class).getCurrentBorderDiameter(); + final int regionDiameter = QSG.module(BorderModule.class).getCurrentBorderDiameter(); final int playersWithoutTeam = (int) Bukkit.getOnlinePlayers().stream() .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) .count(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java index 043de87..21369e2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/commands/SpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.SpawnsModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.UnknownGeneratorException; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.SpawnsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.UnknownGeneratorException; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; @@ -118,7 +118,7 @@ protected void help() protected void list() { - final List<Location> spawnPoints = UR.module(SpawnsModule.class).getSpawnPoints(); + final List<Location> spawnPoints = QSG.module(SpawnsModule.class).getSpawnPoints(); if (spawnPoints.size() == 0) { @@ -186,7 +186,7 @@ protected void dump() // We want one list per world final Map<World, List<Location>> spawnsInWorlds = new HashMap<>(); - UR.module(SpawnsModule.class) + QSG.module(SpawnsModule.class) .getSpawnPoints() .forEach(spawn -> { spawnsInWorlds.putIfAbsent(spawn.getWorld(), new LinkedList<>()); @@ -233,7 +233,7 @@ else if (args.length >= 4) } else { - world = UR.get().getWorld(Environment.NORMAL); + world = QSG.get().getWorld(Environment.NORMAL); } // /uh spawns add @@ -241,7 +241,7 @@ else if (args.length >= 4) { try { - UR.module(SpawnsModule.class).addSpawnPoint(playerSender().getLocation()); + QSG.module(SpawnsModule.class).addSpawnPoint(playerSender().getLocation()); success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(playerSender().getLocation().getBlockX()), String.valueOf(playerSender().getLocation().getBlockZ()))); } catch (IllegalArgumentException e) @@ -265,7 +265,7 @@ else if (args.length == 2) { try { - UR.module(SpawnsModule.class).addSpawnPoint(world, Double.parseDouble(args[1]), Double.parseDouble(args[2])); + QSG.module(SpawnsModule.class).addSpawnPoint(world, Double.parseDouble(args[1]), Double.parseDouble(args[2])); success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[1], args[2])); } catch (NumberFormatException e) @@ -288,7 +288,7 @@ protected void remove() throws CommandException // /uh spawns remove if (args.length == 1) { - UR.module(SpawnsModule.class).removeSpawnPoint(playerSender().getLocation(), false); + QSG.module(SpawnsModule.class).removeSpawnPoint(playerSender().getLocation(), false); success(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", playerSender().getWorld().getName(), playerSender().getLocation().getBlockX(), playerSender().getLocation().getBlockZ())); } @@ -316,10 +316,10 @@ else if (args.length >= 4) } else { - world = UR.get().getWorld(Environment.NORMAL); + world = QSG.get().getWorld(Environment.NORMAL); } - UR.module(SpawnsModule.class).removeSpawnPoint( + QSG.module(SpawnsModule.class).removeSpawnPoint( new Location( world, Double.parseDouble(args[1]), 0, Double.parseDouble(args[2]) ), @@ -336,7 +336,7 @@ else if (args.length >= 4) protected void reset() { - UR.module(SpawnsModule.class).reset(); + QSG.module(SpawnsModule.class).reset(); success(I.t("{cs}All the spawn points were removed.")); } @@ -368,9 +368,9 @@ protected void generate() throws CommandException final String generationMethod = args[1]; // Default values - int size = UR.module(BorderModule.class).getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border + int size = QSG.module(BorderModule.class).getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border int distanceMinBetweenTwoPoints = 250; - World world = UR.get().getWorld(Environment.NORMAL); + World world = QSG.get().getWorld(Environment.NORMAL); double xCenter = world.getSpawnLocation().getX(); double zCenter = world.getSpawnLocation().getZ(); @@ -403,7 +403,7 @@ else if (sender instanceof BlockCommandSender) // Solo mode? if (spawnsCount == 0) { - spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - UR.module(SpectatorsModule.class).getSpectators().size(); + spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - QSG.module(SpectatorsModule.class).getSpectators().size(); info(I.t("{ci}No team found: assuming the game is a solo game.")); } else @@ -490,7 +490,7 @@ else if (sender instanceof BlockCommandSender) try { - UR.module(SpawnsModule.class) + QSG.module(SpawnsModule.class) .generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); } catch (UnknownGeneratorException e) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java index f25df32..a87b947 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions; public class CannotGenerateSpawnPointsException extends Exception diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java index 8e8dfda..bf2a109 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/exceptions/UnknownGeneratorException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions; public class UnknownGeneratorException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index 736580f..b95d222 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -49,7 +49,7 @@ public class CircularSpawnPointsGenerator implements SpawnPointsGenerator { - private final BorderModule borderModule = UR.module(BorderModule.class); + private final BorderModule borderModule = QSG.module(BorderModule.class); /** * Generates spawn points in concentric circles. @@ -137,8 +137,9 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) - || UHUtils.searchSafeSpot(point) == null) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + .isSafeSpot(surfaceAirBlock.getLocation()) + || QSGUtils.searchSafeSpot(point) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java index 7eb0b60..58b839d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -48,7 +48,7 @@ public class GridSpawnPointsGenerator implements SpawnPointsGenerator { - private final BorderModule borderModule = UR.module(BorderModule.class); + private final BorderModule borderModule = QSG.module(BorderModule.class); /** * Generates spawn points in a grid. @@ -135,7 +135,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int currentPoint = currentSquareStartPoint.clone(); // First point - if (borderModule.isInsideBorder(currentPoint, regionDiameter) && UHUtils.searchSafeSpot(currentPoint) != null) + if (borderModule.isInsideBorder(currentPoint, regionDiameter) && QSGUtils.searchSafeSpot(currentPoint) != null) { generatedPoints.add(currentPoint.clone()); countGeneratedPoints++; @@ -166,8 +166,9 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) - || UHUtils.searchSafeSpot(currentPoint) == null) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + .isSafeSpot(surfaceAirBlock.getLocation()) + || QSGUtils.searchSafeSpot(currentPoint) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index 873fa65..94d7a90 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -30,13 +30,13 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -54,7 +54,7 @@ public class RandomSpawnPointsGenerator implements SpawnPointsGenerator { private final Random random = new Random(); - private final BorderModule borderModule = UR.module(BorderModule.class); + private final BorderModule borderModule = QSG.module(BorderModule.class); /** * Generates randomly some spawn points in the map, with a minimal distance. @@ -161,8 +161,9 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !UHUtils.isSafeSpot(surfaceAirBlock.getLocation()) - || UHUtils.searchSafeSpot(randomPoint) == null) + if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + .isSafeSpot(surfaceAirBlock.getLocation()) + || QSGUtils.searchSafeSpot(randomPoint) == null) { continue; // not safe: nope } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java index 8bb1207..1a6d204 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spawns/generators/SpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spawns.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; -import eu.carrade.amaury.UHCReloaded.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java index 804a8b3..ccb75ec 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java index 4488f91..6f56544 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorPlusDependency.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators; import com.pgcraft.spectatorplus.SpectateAPI; import com.pgcraft.spectatorplus.SpectatorPlus; -import fr.zcraft.zlib.external.ExternalPluginComponent; -import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.quartzlib.external.ExternalPluginComponent; +import fr.zcraft.quartzlib.tools.PluginLogger; public class SpectatorPlusDependency extends ExternalPluginComponent<SpectatorPlus> diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java index ee76141..8a65a97 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java @@ -31,25 +31,25 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.commands.SpectatorsCommand; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers.SpectatorsManager; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.Commands; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.commands.SpectatorsCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers.SpectatorsManager; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.Commands; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -70,7 +70,7 @@ settings = Config.class, can_be_unloaded = false ) -public class SpectatorsModule extends UHModule +public class SpectatorsModule extends QSGModule { private SpectatorsManager manager; private SpectatorPlusDependency spectatorPlusDependency; @@ -134,7 +134,7 @@ public void addSpectator(final UUID playerID) { spectators.add(playerID); - if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) + if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) RunTask.nextTick(() -> manager.setSpectating(playerID, true)); } @@ -157,7 +157,7 @@ public void removeSpectator(final UUID playerID) { spectators.remove(playerID); - if (UR.module(GameModule.class).getPhase() != GamePhase.WAIT) + if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) RunTask.nextTick(() -> manager.setSpectating(playerID, false)); } @@ -213,7 +213,7 @@ public void onPlayerResurrects(final PlayerResurrectedEvent ev) @EventHandler public void onPlayerLogin(final PlayerLoginEvent ev) { - final GameModule game = UR.module(GameModule.class); + final GameModule game = QSG.module(GameModule.class); if (game.currentPhaseBefore(GamePhase.IN_GAME)) return; @@ -258,7 +258,7 @@ else if (!Config.UNKNOWN_SPECTATORS_CAN_JOIN.get() && !(game.isAlive(ev.getPlaye @EventHandler public void onPlayerJoin(final PlayerJoinEvent ev) { - if (UR.module(GameModule.class).getPhase().ordinal() >= GamePhase.IN_GAME.ordinal()) + if (QSG.module(GameModule.class).getPhase().ordinal() >= GamePhase.IN_GAME.ordinal()) { manager.setSpectating(ev.getPlayer(), isSpectator(ev.getPlayer())); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java index 06a65f4..7c2f91d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/commands/SpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -59,7 +59,7 @@ protected void run() throws CommandException // /uh spec if (args.length == 0) { - final Set<String> spectators = UR.module(SpectatorsModule.class) + final Set<String> spectators = QSG.module(SpectatorsModule.class) .getSpectators().stream() .map(uuid -> Bukkit.getOfflinePlayer(uuid).getName()) .collect(Collectors.toSet()); @@ -106,7 +106,7 @@ protected void run() throws CommandException return; } - UR.module(SpectatorsModule.class).addSpectator(player); + QSG.module(SpectatorsModule.class).addSpectator(player); finalSender.sendMessage(I.t("{cs}The player {0} is now a spectator.", player.getName())); }); } @@ -131,7 +131,7 @@ protected void run() throws CommandException } else { - UR.module(SpectatorsModule.class).removeSpectator(oldSpectator); + QSG.module(SpectatorsModule.class).removeSpectator(oldSpectator); success(I.t("{cs}The player {0} is now a player.", args[1])); } } @@ -153,7 +153,7 @@ else if (args.length == 2) case "a": return getMatchingSubset( Arrays.stream(Bukkit.getOfflinePlayers()) - .filter(player -> !UR.module(SpectatorsModule.class).isSpectator(player)) + .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) .map(OfflinePlayer::getName) .collect(Collectors.toList()), args[1] @@ -163,7 +163,7 @@ else if (args.length == 2) case "r": return getMatchingSubset( Arrays.stream(Bukkit.getOfflinePlayers()) - .filter(player -> UR.module(SpectatorsModule.class).isSpectator(player)) + .filter(player -> QSG.module(SpectatorsModule.class).isSpectator(player)) .map(OfflinePlayer::getName) .collect(Collectors.toList()), args[1] diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java index 6095dbe..3bd5995 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SPlusSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; import com.pgcraft.spectatorplus.SpectateAPI; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java index 403b012..a576a7c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java @@ -29,10 +29,10 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorPlusDependency; -import fr.zcraft.zlib.core.ZLib; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorPlusDependency; +import fr.zcraft.quartzlib.core.ZLib; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java index 4df455c..ce3f560 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/spectators/managers/VanillaSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.spectators.managers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; import org.bukkit.Bukkit; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java index fa94af2..10ff16f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java @@ -29,17 +29,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.teams; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import fr.zcraft.zteams.guis.TeamsGUIItemType; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java index 29b2275..8cd9dab 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java @@ -29,25 +29,25 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.teams; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams; import com.google.common.collect.ImmutableMap; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarCacheListener; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar.SidebarPlayerCache; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar.SidebarCacheListener; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar.SidebarPlayerCache; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.commands.*; @@ -65,7 +65,14 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BlockStateMeta; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.UUID; @ModuleInfo ( @@ -77,14 +84,14 @@ internal = true, can_be_unloaded = false ) -public class TeamsModule extends UHModule +public class TeamsModule extends QSGModule { private final String HEART = "\u2764"; private double TEAMMATES_DISTANCE_SQUARED; private GameModule game = null; - private Map<UUID, SidebarPlayerCache> sidebarCache = new HashMap<>(); + private final Map<UUID, SidebarPlayerCache> sidebarCache = new HashMap<>(); @Override @@ -93,7 +100,7 @@ protected void onEnable() ZLib.loadComponent(ZTeams.class); ZTeams.settings() - .setScoreboard(UHCReloaded.get().getScoreboard()) + .setScoreboard(QuartzSurvivalGames.get().getScoreboard()) .setTeamsOptions( Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), Config.ALLOW_FRIENDLY_FIRE.get(), @@ -151,7 +158,7 @@ public Map<String, Class<? extends Command>> getCommandsAliases() @Override public void injectIntoSidebar(final Player player, final SidebarInjector injector) { - if (game == null) game = UR.module(GameModule.class); + if (game == null) game = QSG.module(GameModule.class); if (game == null) return; // Module not ready if (!game.isTeamsGame() || !Config.SIDEBAR.ENABLED.get() || game.getPhase().ordinal() < GamePhase.IN_GAME.ordinal()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java index d48fc59..4ced7fb 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarCacheListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -50,8 +50,8 @@ public class SidebarCacheListener implements Listener { - private final static GameModule game = UR.module(GameModule.class); - private final static TeamsModule teams = UR.module(TeamsModule.class); + private final static GameModule game = QSG.module(GameModule.class); + private final static TeamsModule teams = QSG.module(TeamsModule.class); @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java index 98c1d30..f3378c2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/teams/sidebar/SidebarPlayerCache.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java @@ -29,12 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.teams.sidebar; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; @@ -166,7 +166,7 @@ public void updateTeammatesDisplayed(final double distanceThreshold) public void updateTeammatesDisplayed(final double distanceThresholdSquared, final Location reference, final ZTeam team) { - final GameModule game = UR.module(GameModule.class); + final GameModule game = QSG.module(GameModule.class); // For each non-encountered online teammate, we check if they are close team.getOnlinePlayers().stream() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java index 942b927..144f93d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimeDelta.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java @@ -29,11 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers; -import fr.zcraft.zlib.components.configuration.ConfigurationParseException; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; +import fr.zcraft.quartzlib.components.configuration.ConfigurationParseException; +import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandler; +import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandlers; import java.text.DecimalFormat; import java.text.NumberFormat; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java index b5273b8..00e3dfd 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/Timer.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java @@ -30,11 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerStartsEvent; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerStartsEvent; +import fr.zcraft.quartzlib.components.i18n.I; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java index 6c08fa5..1d718c1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java @@ -30,15 +30,15 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.commands.TimersCommand; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.commands.TimersCommand; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -56,7 +56,7 @@ internal = true, can_be_unloaded = false ) -public class TimersModule extends UHModule +public class TimersModule extends QSGModule { private Set<Timer> timers = new CopyOnWriteArraySet<>(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java index a2b10bf..1cca676 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/commands/TimersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java @@ -29,21 +29,21 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.commands.WithFlags; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.components.rawtext.RawTextPart; -import fr.zcraft.zlib.tools.text.MessageSender; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.commands.WithFlags; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.components.rawtext.RawTextPart; +import fr.zcraft.quartzlib.tools.text.MessageSender; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -54,7 +54,7 @@ @WithFlags public class TimersCommand extends Command { - private final TimersModule timersModule = UR.module(TimersModule.class); + private final TimersModule timersModule = QSG.module(TimersModule.class); @Override protected void run() throws CommandException @@ -122,7 +122,7 @@ private void add() throws CommandException { if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name.")); - final String name = UHUtils.getStringFromCommandArguments(args, 2); + final String name = QSGUtils.getStringFromCommandArguments(args, 2); if (timersModule.getTimer(name) != null) throwInvalidArgument(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", name)); @@ -353,7 +353,7 @@ private Timer getTimerParameter(int index) throws CommandException { try { - final String timerName = UHUtils.getStringFromCommandArguments(args, index); + final String timerName = QSGUtils.getStringFromCommandArguments(args, index); final Timer timer = timersModule.getTimer(timerName); if (timer == null) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java index 4fe5a45..31b9d7e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers.events; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java index f015d16..bea7770 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/core/timers/events/TimerStartsEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.core.timers.events; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java index c2c809b..433b7ff 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -55,7 +55,7 @@ category = ModuleCategory.COSMETICS, icon = Material.DIAMOND_SWORD ) -public class KillsCountModule extends UHModule +public class KillsCountModule extends QSGModule { private final Map<UUID, Set<UUID>> kills = new HashMap<>(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java index 6832960..0d4d5d7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -56,7 +56,7 @@ category = ModuleCategory.COSMETICS, icon = Material.DETECTOR_RAIL ) -public class ListHealthModule extends UHModule +public class ListHealthModule extends QSGModule { private String objectiveID = UUID.randomUUID().toString().substring(0, 16); @@ -64,7 +64,7 @@ public class ListHealthModule extends UHModule protected void onEnable() { // Initialization of the scoreboard (health in players' list) - final Objective healthObjective = UR.get().getScoreboard().registerNewObjective(objectiveID, Criterias.HEALTH); + final Objective healthObjective = QSG.get().getScoreboard().registerNewObjective(objectiveID, Criterias.HEALTH); healthObjective.setDisplayName("Health"); healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST); @@ -75,8 +75,8 @@ protected void onEnable() @Override protected void onDisable() { - UR.get().getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST); - UR.get().getScoreboard().getObjective(objectiveID).unregister(); + QSG.get().getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST); + QSG.get().getScoreboard().getObjective(objectiveID).unregister(); } /** diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java index 83bae4e..fd758a9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java similarity index 76% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java index 50c4dca..cf1b3df 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java @@ -31,27 +31,27 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector.SidebarPriority; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.events.TimerEndsEvent; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.commands.ShiftCommand; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.text.Titles; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector.SidebarPriority; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerEndsEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.commands.ShiftCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events.EpisodeChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.text.Titles; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.CommandSender; @@ -72,10 +72,10 @@ settings = Config.class, can_be_loaded_late = false ) -public class EpisodesModule extends UHModule +public class EpisodesModule extends QSGModule { - private final GameModule game = UR.game(); - private final TimersModule timers = UR.module(TimersModule.class); + private final GameModule game = QSG.game(); + private final TimersModule timers = QSG.module(TimersModule.class); private Timer episodesTimer; private int episode = 1; @@ -94,7 +94,7 @@ protected void onEnable() episodesTimer.start(); - UR.ifLoaded(PlayerListHeaderFooterModule.class, headFoot -> { + QSG.ifLoaded(PlayerListHeaderFooterModule.class, headFoot -> { headFoot.registerPlaceholder("episodeText", () -> I.t("Episode {0}", episode)); headFoot.registerPlaceholder("episodeNumber", () -> String.valueOf(episode)); }); @@ -164,7 +164,7 @@ public void onEpisodeChange(final EpisodeChangedEvent ev) // Update headers & footers - UR.ifLoaded(PlayerListHeaderFooterModule.class, PlayerListHeaderFooterModule::update); + QSG.ifLoaded(PlayerListHeaderFooterModule.class, PlayerListHeaderFooterModule::update); } public int getEpisode() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java similarity index 73% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java index d8cf537..788380e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/commands/ShiftCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.EpisodesModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.EpisodesModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; @CommandInfo (name = "shift", usageParameters = "[next episode number]", aliases = {"shift-episode"}) @@ -49,18 +49,18 @@ public class ShiftCommand extends Command @Override protected void run() throws CommandException { - if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { error(I.t("{ce}You can't shift the current episode because the game is not started.")); } try { - UR.module(EpisodesModule.class).shift(sender, Integer.parseInt(args[0])); + QSG.module(EpisodesModule.class).shift(sender, Integer.parseInt(args[0])); } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { - UR.module(EpisodesModule.class).shift(sender); + QSG.module(EpisodesModule.class).shift(sender); } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java index 0d192b4..246efb1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/episodes/events/EpisodeChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events; import org.bukkit.command.CommandSender; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java index abd90ca..d22968c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.hardcoreHearts; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java index 9cf9a69..1ea67aa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.hardcoreHearts; import com.comphenix.protocol.ProtocolLibrary; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.core.ZLib; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.core.ZLib; import org.bukkit.Material; @@ -49,7 +49,7 @@ icon = Material.RED_ROSE, // FIXME 1.13 settings = Config.class ) -public class HardcoreHeartsModule extends UHModule +public class HardcoreHeartsModule extends QSGModule { @Override protected void onEnable() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java index 5015384..8c9de07 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/hardcoreHearts/PacketsListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.hardcoreHearts; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.hardcoreHearts; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; @@ -40,9 +40,8 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.EnumWrappers; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; @@ -58,7 +57,7 @@ public class PacketsListener extends PacketAdapter implements Listener public PacketsListener() { // This listener needs to listen on login packets only. - super(UR.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); + super(QSG.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); // The packet to send to automatically respawn the player. respawnPacket = pm.createPacket(PacketType.Play.Client.CLIENT_COMMAND); @@ -94,7 +93,7 @@ public void onPlayerDeath(final PlayerDeathEvent ev) } catch (final IllegalAccessException | InvocationTargetException e) { - UR.log(HardcoreHeartsModule.class).error("Unable to respawn player {0}", e, ev.getEntity().getName()); + QSG.log(HardcoreHeartsModule.class).error("Unable to respawn player {0}", e, ev.getEntity().getName()); } }, Config.AUTO_RESPAWN.DELAY.get() * 20L); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java index e30f2c9..746438b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationMap; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationMap; import java.io.File; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java index f955a95..2f0f3ad 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.commands.WithFlags; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.commands.PaginatedTextView; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.commands.WithFlags; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.commands.PaginatedTextView; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -53,7 +53,7 @@ public class ListPlaceholdersCommand extends Command @Override protected void run() throws CommandException { - final Map<String, Supplier<String>> placeholders = UR.module(PlayerListHeaderFooterModule.class).getPlaceholderSuppliers(); + final Map<String, Supplier<String>> placeholders = QSG.module(PlayerListHeaderFooterModule.class).getPlaceholderSuppliers(); final int page = args.length > 0 ? getIntegerParameter(0) : 1; new PlaceholdersList() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java similarity index 76% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java index 1b8aeba..46f1fb8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -29,23 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.cosmetics.playerListHeaderFooter; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ListHeaderFooter; +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; + +import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.ListHeaderFooter; import fr.zcraft.zteams.events.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -70,18 +70,18 @@ settings = Config.class, can_be_loaded_late = false ) -public class PlayerListHeaderFooterModule extends UHModule +public class PlayerListHeaderFooterModule extends QSGModule { private final Map<String, Supplier<String>> placeholderSuppliers = new HashMap<>(); @Override protected void onEnable() { - registerPlaceholder("title", UHConfig.TITLE::get); - registerPlaceholder("playersText", () -> I.tn("{0} player", "{0} players", UR.game().countAlivePlayers())); - registerPlaceholder("playersCount", () -> String.valueOf(UR.game().countAlivePlayers())); - registerPlaceholder("teamsText", () -> I.tn("{0} team", "{0} teams", UR.game().countAliveTeams())); - registerPlaceholder("teamsCount", () -> String.valueOf(UR.game().countAliveTeams())); + registerPlaceholder("title", QSGConfig.TITLE::get); + registerPlaceholder("playersText", () -> I.tn("{0} player", "{0} players", QSG.game().countAlivePlayers())); + registerPlaceholder("playersCount", () -> String.valueOf(QSG.game().countAlivePlayers())); + registerPlaceholder("teamsText", () -> I.tn("{0} team", "{0} teams", QSG.game().countAliveTeams())); + registerPlaceholder("teamsCount", () -> String.valueOf(QSG.game().countAliveTeams())); RunTask.nextTick(this::update); } @@ -132,8 +132,8 @@ public void update() { if (!isEnabled()) return; // Other modules may keep a reference if the module is disabled. - final String headerPattern = Config.HEADERS.get(UR.game().getPhase()); - final String footerPattern = Config.FOOTERS.get(UR.game().getPhase()); + final String headerPattern = Config.HEADERS.get(QSG.game().getPhase()); + final String footerPattern = Config.FOOTERS.get(QSG.game().getPhase()); if ((headerPattern != null && !headerPattern.isEmpty()) || (footerPattern != null && !footerPattern.isEmpty())) { @@ -142,11 +142,11 @@ public void update() final Stream<? extends Player> receivers; - if (UR.game().currentPhaseAfter(GamePhase.STARTING)) + if (QSG.game().currentPhaseAfter(GamePhase.STARTING)) { receivers = Stream.concat( - UR.game().getAliveConnectedPlayers().stream(), - UR.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) + QSG.game().getAliveConnectedPlayers().stream(), + QSG.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) ); } else diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java index 011f113..6969879 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/EndAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end; +package eu.carrade.amaury.quartzsurvivalgames.modules.end; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.Titles; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.Titles; import fr.zcraft.zteams.ZTeam; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -54,22 +54,22 @@ category = ModuleCategory.END, icon = Material.ITEM_FRAME ) -public class EndAnnouncementModule extends UHModule +public class EndAnnouncementModule extends QSGModule { @Override protected void onEnable() { RunTask.later(() -> { - if (UR.game().getPhase() != GamePhase.END) return; + if (QSG.game().getPhase() != GamePhase.END) return; - final ZTeam winnerTeam = UR.game().getWinner(); + final ZTeam winnerTeam = QSG.game().getWinner(); if (winnerTeam == null) return; // No winner Bukkit.broadcastMessage(""); - if (UR.game().isTeamsGame()) + if (QSG.game().isTeamsGame()) { final StringBuilder winners = new StringBuilder(); int j = 0; @@ -106,7 +106,7 @@ protected void onEnable() final String title; final String subtitle; - if (UR.game().isTeamsGame()) + if (QSG.game().isTeamsGame()) { /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java similarity index 76% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java index f4543cc..d73549a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/FireworksModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end; +package eu.carrade.amaury.quartzsurvivalgames.modules.end; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.apache.commons.lang.math.RandomUtils; import org.bukkit.Location; import org.bukkit.Material; @@ -55,7 +55,7 @@ category = ModuleCategory.END, icon = Material.FIREWORK ) -public class FireworksModule extends UHModule +public class FireworksModule extends QSGModule { private final int area = 6; // Fireworks launched on a 6×6 area around the winners private final TimeDelta duration = new TimeDelta(10); @@ -65,7 +65,7 @@ protected void onEnable() { RunTask.later(() -> { - if (UR.game().getPhase() != GamePhase.END) return; + if (QSG.game().getPhase() != GamePhase.END) return; final long start = System.currentTimeMillis(); @@ -73,9 +73,9 @@ protected void onEnable() @Override public void run() { - if (UR.game().getWinner() == null) return; + if (QSG.game().getWinner() == null) return; - UR.game().getWinner().getOnlinePlayers().forEach(winner -> + QSG.game().getWinner().getOnlinePlayers().forEach(winner -> { final Location fireworkLocation = winner.getLocation(); @@ -90,8 +90,8 @@ public void run() RandomUtils.nextDouble() * area - (area >> 1) ); - UHUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); - UHUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); + QSGUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); + QSGUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); }); if ((System.currentTimeMillis() - start) / 1000 > duration.getSeconds()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java index 92b3082..51018c4 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.deathAnnouncement; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.deathAnnouncement; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { @@ -54,5 +54,5 @@ public Config(File file) public static final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); public static final ConfigurationItem<Boolean> PLAY_SOUND = item("play-sound", true); - public static final ConfigurationItem<UHSound> SOUND = item("sound", new UHSound("ENTITY_WITHER_SPAWN")); + public static final ConfigurationItem<QSGSound> SOUND = item("sound", new QSGSound("ENTITY_WITHER_SPAWN")); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java index 0681181..649f5aa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/deathAnnouncement/DeathAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java @@ -31,20 +31,20 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.deathAnnouncement; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.TeamDeathEvent; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.components.rawtext.RawTextPart; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.RawMessage; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.deathAnnouncement; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.TeamDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.components.rawtext.RawTextPart; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.RawMessage; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; @@ -62,9 +62,9 @@ icon = Material.BLAZE_ROD, settings = Config.class ) -public class DeathAnnouncementModule extends UHModule +public class DeathAnnouncementModule extends QSGModule { - private UHSound deathSound; + private QSGSound deathSound; @Override protected void onEnable() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java index 9ee0d38..debe2fa 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.kick; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.kick; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.i18n.I; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java index de6a763..f6fa413 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/kick/KickModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.kick; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.kick; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -50,7 +50,7 @@ icon = Material.BARRIER, settings = Config.class ) -public class KickModule extends UHModule +public class KickModule extends QSGModule { @EventHandler public void onPlayerDeath(final AlivePlayerDeathEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java index 46e4e41..4029b15 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.xpToKillers; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.xpToKillers; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java index c6b89d3..267a417 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/end/xpToKillers/XpToKillersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.end.xpToKillers; +package eu.carrade.amaury.quartzsurvivalgames.modules.end.xpToKillers; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; import fr.zcraft.zteams.ZTeams; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -54,7 +54,7 @@ icon = Material.EXP_BOTTLE, settings = Config.class ) -public class XpToKillersModule extends UHModule +public class XpToKillersModule extends QSGModule { @EventHandler public void onPlayerDeath(final AlivePlayerDeathEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java index 82ae596..3d6bd5c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.dynmap; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.dynmap; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java index 79dc8b3..67471c2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/dynmap/DynmapModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java @@ -31,19 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.dynmap; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.dynmap; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; @@ -73,7 +73,7 @@ /* * TODO: add the world border to the map. */ -public class DynmapModule extends UHModule +public class DynmapModule extends QSGModule { private final DynmapAPI dynmapAPI = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"); private final MarkerAPI markerAPI = dynmapAPI.getMarkerAPI(); @@ -199,7 +199,7 @@ public void showSpawnLocation(final OfflinePlayer player, final Location spawnPo if (team == null) return; final String markerLabel; - if (UR.module(GameModule.class).isTeamsGame() && team.size() > 1) + if (QSG.module(GameModule.class).isTeamsGame() && team.size() > 1) { /// Dynmap marker label of a spawn point of a team. markerLabel = I.t("Spawn point of the team {0}", team.getName()); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java index bcb4443..f09d5ce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.hawk; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationList; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import org.bukkit.Material; import org.bukkit.Statistic; @@ -44,8 +44,8 @@ import java.util.Arrays; import java.util.List; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java index 4daab51..f0469b3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/hawk/HawkModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java @@ -31,31 +31,31 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.hawk; - -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.PlayerResurrectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads.GoldenHeadsModule; -import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.events.FutureEventHandler; -import fr.zcraft.zlib.components.events.WrappedEvent; -import fr.zcraft.zlib.components.gui.GuiUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.RawMessage; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk; + +import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads.GoldenHeadsModule; +import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.events.FutureEventHandler; +import fr.zcraft.quartzlib.components.events.WrappedEvent; +import fr.zcraft.quartzlib.components.gui.GuiUtils; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.RawMessage; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.events.*; @@ -98,7 +98,7 @@ settings = Config.class, can_be_unloaded = false ) -public class HawkModule extends UHModule +public class HawkModule extends QSGModule { private GameModule game; @@ -135,9 +135,9 @@ public class HawkModule extends UHModule @Override protected void onEnable() { - game = UR.module(GameModule.class); + game = QSG.module(GameModule.class); - ReportsManager.init(UR.get()); + ReportsManager.init(QSG.get()); if (!Config.REPORTS_API_BASE_URL.get().isEmpty()) { @@ -157,7 +157,7 @@ protected void onEnable() .autoCollectPreviousStatistics(true) .registerPlayers(game.getAlivePlayers()) - .title(UHConfig.TITLE.get()) + .title(QSGConfig.TITLE.get()) .settings() .displayDate(Config.DATE.get()) @@ -251,7 +251,7 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { waitingAfterEnd = false; - report.autoTrack(false).title(UHConfig.TITLE.get()); + report.autoTrack(false).title(QSGConfig.TITLE.get()); report.save( saved -> @@ -540,7 +540,7 @@ public void onWorldChange(final PlayerChangedWorldEvent ev) { if (!game.isAlive(ev.getPlayer())) return; - if (!firstNether && ev.getPlayer().getWorld().getName().equals(UR.get().getWorld(World.Environment.NETHER).getName())) + if (!firstNether && ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.NETHER).getName())) { report.record(ReportEvent.withIcon( ReportEvent.EventType.RED, @@ -551,7 +551,7 @@ public void onWorldChange(final PlayerChangedWorldEvent ev) firstNether = true; } - else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(UR.get().getWorld(World.Environment.THE_END).getName())) + else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.THE_END).getName())) { report.record(ReportEvent.withIcon( I.t("{0} enters first The End", ev.getPlayer().getName()), @@ -568,7 +568,7 @@ public void onItemConsumed(final PlayerItemConsumeEvent ev) if (!game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) return; - final SkullType headType = UR.loaded(GoldenHeadsModule.class) ? UR.module(GoldenHeadsModule.class).readHeadType(ev.getItem()) : null; + final SkullType headType = QSG.loaded(GoldenHeadsModule.class) ? QSG.module(GoldenHeadsModule.class).readHeadType(ev.getItem()) : null; if (headType == SkullType.PLAYER && !firstGoldenHead) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java index 991804f..e8da4a9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.motd; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.motd; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java index 4242a49..55f2121 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/external/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.external.motd; +package eu.carrade.amaury.quartzsurvivalgames.modules.external.motd; -import eu.carrade.amaury.UHCReloaded.UHConfig; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -54,9 +54,9 @@ icon = Material.SIGN, settings = Config.class ) -public class MotdModule extends UHModule +public class MotdModule extends QSGModule { - private final GameModule game = UR.module(GameModule.class); + private final GameModule game = QSG.module(GameModule.class); private String getMOTD() { @@ -65,7 +65,7 @@ private String getMOTD() if (Config.DISPLAY_MATCH_NAME.get()) { matchName = ChatColor.translateAlternateColorCodes('&', Config.MATCH_NAME_PREFIX.get()) - + UHConfig.TITLE.get() + + QSGConfig.TITLE.get() + ChatColor.RESET + "\n"; } else diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java index b9d2422..04a7ba3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoEnderPearlDamagesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerTeleportEvent; @@ -50,7 +50,7 @@ category = ModuleCategory.GAMEPLAY, icon = Material.ENDER_PEARL ) -public class NoEnderPearlDamagesModule extends UHModule +public class NoEnderPearlDamagesModule extends QSGModule { @EventHandler(ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java index 987e5a8..814976b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/NoGhastTearsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.Material; import org.bukkit.entity.Ghast; import org.bukkit.event.EventHandler; @@ -57,7 +57,7 @@ category = ModuleCategory.GAMEPLAY, icon = Material.GHAST_TEAR ) -public class NoGhastTearsModule extends UHModule +public class NoGhastTearsModule extends QSGModule { /** * Used to replace ghast tears with gold (if needed). @@ -90,7 +90,7 @@ public void onEntityDeath(EntityDeathEvent ev) @EventHandler (ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent ev) { - if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR && UR.module(GameModule.class).isAlive(ev.getPlayer())) + if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR && QSG.module(GameModule.class).isAlive(ev.getPlayer())) { ev.setCancelled(true); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java index 74a9906..2ddad42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/OnerousGlisteringMelon.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; -import fr.zcraft.zlib.tools.items.CraftingRecipes; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.utils.RecipesUtils; +import fr.zcraft.quartzlib.tools.items.CraftingRecipes; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.inventory.PrepareItemCraftEvent; @@ -53,7 +53,7 @@ category = ModuleCategory.GAMEPLAY, icon = Material.SPECKLED_MELON // FIXME 1.13 ) -public class OnerousGlisteringMelon extends UHModule +public class OnerousGlisteringMelon extends QSGModule { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( new ItemStack(Material.SPECKLED_MELON), diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java similarity index 80% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java index 12adb18..c0cef49 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java @@ -31,22 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.i18n.I18n; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.MessageSender; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.i18n.I18n; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.MessageSender; import fr.zcraft.zteams.ZTeams; import org.apache.commons.lang.math.RandomUtils; import org.bukkit.ChatColor; @@ -71,7 +71,7 @@ icon = Material.COMPASS, settings = Config.class ) -public class CompassModule extends UHModule +public class CompassModule extends QSGModule { private CompassRecipes recipes = null; @@ -120,7 +120,7 @@ public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev) */ private boolean activateCompass(final Player compassUser) { - if (!UR.game().isAlive(compassUser) || compassUser.getItemInHand().getType() != Material.COMPASS) return false; + if (!QSG.game().isAlive(compassUser) || compassUser.getItemInHand().getType() != Material.COMPASS) return false; if (compassLocked.contains(compassUser.getUniqueId())) return false; compassLocked.add(compassUser.getUniqueId()); @@ -145,7 +145,7 @@ private boolean activateCompass(final Player compassUser) .then(".").color(ChatColor.RED) .build() ); - new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + new QSGSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); return false; } @@ -180,7 +180,7 @@ private boolean activateCompass(final Player compassUser) Player nearest = null; Double distance = Double.MAX_VALUE; - for (final Player otherPlayer : UR.module(GameModule.class).getAliveConnectedPlayers()) + for (final Player otherPlayer : QSG.module(GameModule.class).getAliveConnectedPlayers()) { try { @@ -202,9 +202,10 @@ private boolean activateCompass(final Player compassUser) if (nearest == null) { /// Error message if a player tries to use his pointing compass without a player nearby. - MessageSender.sendActionBarMessage(compassUser, UHUtils.prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); + MessageSender.sendActionBarMessage(compassUser, QSGUtils + .prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); - new UHSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); + new QSGSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); return false; } @@ -222,7 +223,7 @@ private boolean activateCompass(final Player compassUser) if (behavior == CompassBehavior.GIVE_BOTH) { compassUser.setCompassTarget(nearest.getLocation()); - compassUser.sendMessage(UHUtils.prefixedMessage( + compassUser.sendMessage(QSGUtils.prefixedMessage( I.tl(locale, "Compass"), ChatColor.YELLOW + I.tln( locale, @@ -243,10 +244,10 @@ else if (behavior == CompassBehavior.GIVE_DIRECTION) else { - compassUser.sendMessage(UHUtils.prefixedMessage(I.tl(locale, "Compass"), I.tln(locale, "{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); + compassUser.sendMessage(QSGUtils.prefixedMessage(I.tl(locale, "Compass"), I.tln(locale, "{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); } - new UHSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); + new QSGSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); return true; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java index cc2a418..8314dd6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; -import eu.carrade.amaury.UHCReloaded.utils.RecipesUtils; -import fr.zcraft.zlib.core.ZLibComponent; -import fr.zcraft.zlib.tools.items.CraftingRecipes; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.utils.RecipesUtils; +import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.tools.items.CraftingRecipes; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Event; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java index c45d267..5aebcc3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/compass/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.compass; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import org.bukkit.Material; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java index 1f67eb8..9c8d1d5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.daylightCycle; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.daylightCycle; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java index fc3cda3..27964f5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.daylightCycle; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.daylightCycle; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -57,7 +57,7 @@ icon = Material.WATCH, settings = Config.class ) -public class DaylightCycleModule extends UHModule +public class DaylightCycleModule extends QSGModule { // Here are the Magic Values™. private final static long TICKS_IN_ONE_DAYLIGHT_CYCLE = 24000L; @@ -69,7 +69,7 @@ public class DaylightCycleModule extends UHModule @Override protected void onEnable() { - UR.get().getWorlds().forEach(world -> { + QSG.get().getWorlds().forEach(world -> { world.setFullTime(Config.WAITING_PHASE_HOUR.get()); world.setGameRuleValue("doDaylightCycle", Boolean.FALSE.toString()); }); @@ -78,9 +78,9 @@ protected void onEnable() @Override public void onLateEnable() { - if (UR.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) + if (QSG.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) { - initDayLightCycle(UR.get().getWorld(World.Environment.NORMAL).getFullTime()); + initDayLightCycle(QSG.get().getWorld(World.Environment.NORMAL).getFullTime()); } } @@ -105,7 +105,7 @@ public void onGameStart(final GamePhaseChangedEvent ev) private void initDayLightCycle(final long initialTime) { - final World world = UR.get().getWorld(World.Environment.NORMAL); + final World world = QSG.get().getWorld(World.Environment.NORMAL); world.setFullTime(Config.INITIAL_GAME_HOUR.get()); world.setGameRuleValue("doDaylightCycle", Config.ENABLE_DAYLIGHT_CYCLE.get().toString()); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java index 2f269e6..8d395c7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java index 6bf1bb3..bd210c0 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -31,21 +31,21 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.goldenHeads; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import fr.zcraft.zlib.components.attributes.Attribute; -import fr.zcraft.zlib.components.attributes.Attributes; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.items.ItemUtils; -import fr.zcraft.zlib.tools.reflection.NMSException; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import fr.zcraft.quartzlib.components.attributes.Attribute; +import fr.zcraft.quartzlib.components.attributes.Attributes; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.items.ItemUtils; +import fr.zcraft.quartzlib.tools.reflection.NMSException; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -74,7 +74,7 @@ icon = Material.GOLDEN_APPLE, // TODO 1.13: enchanted golden apple or player head settings = Config.class ) -public class GoldenHeadsModule extends UHModule +public class GoldenHeadsModule extends QSGModule { private final static UUID HEADS_UUID = UUID.fromString("1a050e3b-6274-434e-b8c0-a720048142e7"); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java index 0b80a7e..2d19655 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.hardcore; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.hardcore; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import org.bukkit.Difficulty; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java index 0ec2776..9a44962 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/hardcore/HardcoreModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.hardcore; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.hardcore; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.Difficulty; import org.bukkit.Material; @@ -53,7 +53,7 @@ icon = Material.GOLDEN_APPLE, settings = Config.class ) -public class HardcoreModule extends UHModule +public class HardcoreModule extends QSGModule { private Map<String, Difficulty> oldDifficulties = new HashMap<>(); private Map<String, String> oldNaturalRegenerations = new HashMap<>(); @@ -61,7 +61,7 @@ public class HardcoreModule extends UHModule @Override protected void onEnable() { - UR.get().getWorlds().forEach(world -> + QSG.get().getWorlds().forEach(world -> { oldDifficulties.put(world.getName(), world.getDifficulty()); oldNaturalRegenerations.put(world.getName(), world.getGameRuleValue("naturalRegeneration")); @@ -74,7 +74,7 @@ protected void onEnable() @Override protected void onDisable() { - UR.get().getWorlds().forEach(world -> { + QSG.get().getWorlds().forEach(world -> { world.setDifficulty(oldDifficulties.getOrDefault(world.getName(), Difficulty.NORMAL)); world.setGameRuleValue("naturalRegeneration", oldNaturalRegenerations.getOrDefault(world.getName(), "true")); }); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java index 4b57386..d1d2608 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.killerRabbit; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.killerRabbit; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java index fb65c45..e962be9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/killerRabbit/KillerRabbitModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.killerRabbit; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.killerRabbit; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Rabbit; @@ -55,7 +55,7 @@ icon = Material.RABBIT_FOOT, settings = Config.class ) -public class KillerRabbitModule extends UHModule +public class KillerRabbitModule extends QSGModule { private final Random random = new Random(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java index 762c71d..d8eef3d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.noWitches; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.noWitches; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java index 925304b..682bfe9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/noWitches/NoWitchesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.noWitches; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.noWitches; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; @@ -51,7 +51,7 @@ icon = Material.POTION, settings = Config.class ) -public class NoWitchesModule extends UHModule +public class NoWitchesModule extends QSGModule { @EventHandler public void onCreatureSpawn(CreatureSpawnEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java index fd61edb..8cf9ad2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/CancelBrewTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; -import fr.zcraft.zlib.tools.items.ItemUtils; +import fr.zcraft.quartzlib.tools.items.ItemUtils; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java index 85500ff..ec11023 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java index 563ccd5..d87ec66 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/potions/PotionsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.potions; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.inventory.InventoryClickEvent; @@ -54,7 +54,7 @@ icon = Material.BREWING_STAND_ITEM, settings = Config.class ) -public class PotionsModule extends UHModule +public class PotionsModule extends QSGModule { @EventHandler public void onInventoryDrag(InventoryDragEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java index 8fdec29..38e855f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.weather; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.weather; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import org.bukkit.WeatherType; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java index d7338fa..dba4820 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/gameplay/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.gameplay.weather; +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.weather; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.Material; import org.bukkit.WeatherType; import org.bukkit.World; @@ -57,20 +57,20 @@ category = ModuleCategory.GAMEPLAY, icon = Material.DOUBLE_PLANT // Sunflower - FIXME 1.13 ) -public class WeatherModule extends UHModule +public class WeatherModule extends QSGModule { private Set<World> firstWeatherUpdateOccurred = new HashSet<>(); @Override protected void onEnable() { - UR.get().getWorlds().forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); + QSG.get().getWorlds().forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); } @Override public void onLateEnable() { - UR.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); + QSG.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); } @EventHandler @@ -85,7 +85,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) @EventHandler public void onWeatherChange(final WeatherChangeEvent ev) { - switch (UR.module(GameModule.class).getPhase()) + switch (QSG.module(GameModule.class).getPhase()) { case WAIT: case STARTING: diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java index e0f9ef0..f1f7ebc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/AdvancementsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java @@ -31,19 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other; +package eu.carrade.amaury.quartzsurvivalgames.modules.other; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.events.FutureEventHandler; -import fr.zcraft.zlib.components.events.WrappedEvent; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.events.FutureEventHandler; +import fr.zcraft.quartzlib.components.events.WrappedEvent; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.CommandException; @@ -64,12 +64,12 @@ category = ModuleCategory.OTHER, icon = Material.HAY_BLOCK ) -public class AdvancementsModule extends UHModule +public class AdvancementsModule extends QSGModule { @FutureEventHandler (event = "player.PlayerAchievementAwardedEvent", ignoreCancelled = true) public void onAchievementAwarded(final WrappedEvent ev) { - if (UR.game().getPhase() == GamePhase.WAIT) + if (QSG.game().getPhase() == GamePhase.WAIT) { ev.setCancelled(true); } @@ -87,7 +87,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) { final Object[] achievements = Class.forName("org.bukkit.Achievement").getEnumConstants(); - UR.game().getAliveConnectedPlayers().forEach(player -> { + QSG.game().getAliveConnectedPlayers().forEach(player -> { try { for (final Object achievement : achievements) @@ -105,12 +105,12 @@ public void onGameStarts(final GamePhaseChangedEvent ev) // Advancements final Map<String, String> oldGameRule = new HashMap<>(); - UR.get().getWorlds().forEach(world -> { + QSG.get().getWorlds().forEach(world -> { oldGameRule.put(world.getName(), world.getGameRuleValue("sendCommandFeedback")); world.setGameRuleValue("sendCommandFeedback", "false"); }); - UR.game().getAliveConnectedPlayers().forEach(player -> { + QSG.game().getAliveConnectedPlayers().forEach(player -> { try { // ¯\_(ツ)_/¯ @@ -119,7 +119,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) catch (final CommandException ignored) {} }); - UR.get().getWorlds().forEach(world -> world.setGameRuleValue("sendCommandFeedback", oldGameRule.get(world.getName()))); + QSG.get().getWorlds().forEach(world -> world.setGameRuleValue("sendCommandFeedback", oldGameRule.get(world.getName()))); oldGameRule.clear(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java similarity index 80% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java index 649f5d4..2c5ae71 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/PomfModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other; +package eu.carrade.amaury.quartzsurvivalgames.modules.other; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.Config; -import eu.carrade.amaury.UHCReloaded.modules.cosmetics.episodes.events.EpisodeChangedEvent; -import fr.zcraft.zlib.tools.runners.RunTask; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.Config; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events.EpisodeChangedEvent; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -51,7 +51,7 @@ category = ModuleCategory.OTHER, icon = Material.SLIME_BLOCK ) -public class PomfModule extends UHModule +public class PomfModule extends QSGModule { @EventHandler public void onEpisodeEnds(final EpisodeChangedEvent ev) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java index 4cf7231..074286f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/StatisticsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other; +package eu.carrade.amaury.quartzsurvivalgames.modules.other; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.Material; import org.bukkit.Statistic; import org.bukkit.entity.EntityType; @@ -56,12 +56,12 @@ category = ModuleCategory.OTHER, icon = Material.WORKBENCH ) -public class StatisticsModule extends UHModule +public class StatisticsModule extends QSGModule { @EventHandler public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) { - if (UR.game().getPhase() == GamePhase.WAIT) + if (QSG.game().getPhase() == GamePhase.WAIT) { ev.setCancelled(true); } @@ -72,7 +72,7 @@ public void onGameStart(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { - UR.game().getAliveConnectedPlayers().forEach(player -> { + QSG.game().getAliveConnectedPlayers().forEach(player -> { for (final Statistic statistic : Statistic.values()) { switch (statistic.getType()) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java index 17793b9..cc9f169 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.about; +package eu.carrade.amaury.quartzsurvivalgames.modules.other.about; -import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.i18n.I18n; +import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.i18n.I18n; @CommandInfo (name = "about") @@ -47,7 +47,7 @@ public class AboutCommand extends Command @Override protected void run() { - final AboutModule about = UR.module(AboutModule.class); + final AboutModule about = QSG.module(AboutModule.class); CommandUtils.displaySeparator(sender); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java index eb3618a..7d48b36 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/other/about/AboutModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.other.about; - -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.other.about; + +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -61,9 +61,9 @@ category = ModuleCategory.OTHER, icon = Material.BOOK ) -public class AboutModule extends UHModule +public class AboutModule extends QSGModule { - private String shortName = "UHC Reloaded"; + private String shortName = "Quartz Survival Games"; private String version = null; private Stability stability = null; private String gitVersion = null; @@ -86,7 +86,7 @@ public List<Class<? extends Command>> getCommands() @Override public void injectIntoSidebar(Player player, SidebarInjector injector) { - if (UR.module(GameModule.class).getPhase() == GamePhase.WAIT) + if (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT) { injector.injectLines( SidebarInjector.SidebarPriority.VERY_BOTTOM, @@ -129,7 +129,7 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) public String getPluginName() { - return UR.get().getDescription().getDescription(); + return QSG.get().getDescription().getDescription(); } public String getShortPluginName() @@ -154,7 +154,7 @@ public String getGitVersion() public List<String> getAuthors() { - return UR.get().getDescription().getAuthors(); + return QSG.get().getDescription().getAuthors(); } public String getFormattedAuthors() @@ -166,7 +166,7 @@ private void computeGitVersion() { try { - final Class<? extends UHCReloaded> clazz = UR.get().getClass(); + final Class<? extends QuartzSurvivalGames> clazz = QSG.get().getClass(); final String className = clazz.getSimpleName() + ".class"; final String classPath = clazz.getResource(className).toString(); @@ -214,7 +214,7 @@ private void computeFormattedAuthors() private void computeVersion() { - final String[] versionParts = UR.get().getDescription().getVersion().split("-", 2); + final String[] versionParts = QSG.get().getDescription().getVersion().split("-", 2); version = versionParts[0]; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java index b178da9..fbd192c 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AllianceRequest.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; - -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.external.hawk.HawkModule; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHSound; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.RawMessage; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk.HawkModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands.RequestAnswerCommand; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.RawMessage; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; @@ -76,8 +76,8 @@ public AllianceRequest(final UUID requesterID, final UUID requestedTo) Validate.notNull(requesterID, "The requester must not be null"); Validate.notNull(requestedTo, "The requested must not be null"); - game = UR.module(GameModule.class); - alliances = UR.module(AlliancesModule.class); + game = QSG.module(GameModule.class); + alliances = QSG.module(AlliancesModule.class); this.requesterID = requesterID; this.requestedID = requestedTo; @@ -186,10 +186,10 @@ public void sendApprovalRequests() { checkError(); - final UHSound[] jingle = new UHSound[] { - new UHSound(1f, 0.8f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.4f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.1f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT") + final QSGSound[] jingle = new QSGSound[] { + new QSGSound(1f, 0.8f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.4f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.1f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT") }; approvalsIDs.keySet().stream() @@ -365,7 +365,7 @@ private void applyApprovedRequest() || !checkGameEnd() || (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1)) { - UR.log(AlliancesModule.class).warning("The alliance request from {0} to {1} was about to be approved but is now invalid.", getName(requesterID), getName(requestedID)); + QSG.log(AlliancesModule.class).warning("The alliance request from {0} to {1} was about to be approved but is now invalid.", getName(requesterID), getName(requestedID)); Stream.of(requesterID, requestedID) .map(Bukkit::getPlayer).filter(Objects::nonNull) @@ -397,12 +397,12 @@ private void applyApprovedRequest() // We notify the players - final UHSound[] jingle = new UHSound[] { - new UHSound(1f, 1.10f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.22f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.33f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.44f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), - new UHSound(1f, 1.80f, "ENTITY_PLAYER_LEVELUP", "LEVEL_UP", "LEVELUP") + final QSGSound[] jingle = new QSGSound[] { + new QSGSound(1f, 1.10f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.22f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.33f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.44f, "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT"), + new QSGSound(1f, 1.80f, "ENTITY_PLAYER_LEVELUP", "LEVEL_UP", "LEVELUP") }; allianceTeam.getOnlinePlayers().forEach(player -> { @@ -431,7 +431,7 @@ private void applyApprovedRequest() // A small log message - UR.log(AlliancesModule.class).info( + QSG.log(AlliancesModule.class).info( "{0} succeeded! A new alliance was created between these players: {1}.", this, String.join(", ", allianceTeam.getPlayers().stream() @@ -443,7 +443,7 @@ private void applyApprovedRequest() // Also in the timeline - UR.ifLoaded(HawkModule.class, hawk -> { + QSG.ifLoaded(HawkModule.class, hawk -> { if (allianceTeam.size() == 2) { final Iterator<OfflinePlayer> players = allianceTeam.getPlayers().iterator(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java index b1c5c60..f55f9ed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java @@ -31,22 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; import com.google.common.collect.ImmutableMap; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.BeforeTeleportationPhaseEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.modules.external.hawk.HawkModule; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.AllianceRequestCommand; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands.RequestAnswerCommand; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.BeforeTeleportationPhaseEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk.HawkModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands.AllianceRequestCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands.RequestAnswerCommand; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.colors.TeamColor; @@ -84,7 +84,7 @@ settings = Config.class, can_be_loaded_late = false ) -public class AlliancesModule extends UHModule +public class AlliancesModule extends QSGModule { private GameModule game = null; @@ -94,23 +94,23 @@ public class AlliancesModule extends UHModule @Override protected void onEnable() { - game = UR.module(GameModule.class); + game = QSG.module(GameModule.class); // We update some settings - eu.carrade.amaury.UHCReloaded.modules.core.game.Config.SIDEBAR.TEAMS.set(false); - eu.carrade.amaury.UHCReloaded.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); + eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config.SIDEBAR.TEAMS.set(false); + eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); ZTeams.settings() .setTeamsOptions( - eu.carrade.amaury.UHCReloaded.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), + eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), false, false, true // Important! As we use the same team names for lots of teams, as titles. ) .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_ALLIANCE.get()); - UR.ifLoaded(HawkModule.class, hawk -> hawk.getReport().settings().enableSummary(true, true, false)); + QSG.ifLoaded(HawkModule.class, hawk -> hawk.getReport().settings().enableSummary(true, true, false)); // ...And permissions @@ -238,7 +238,7 @@ public int allianceSize(final ZTeam team) @EventHandler (priority = EventPriority.LOWEST) private void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) { - final SpectatorsModule spectators = UR.module(SpectatorsModule.class); + final SpectatorsModule spectators = QSG.module(SpectatorsModule.class); new HashSet<>(ZTeams.get().getTeams()).forEach(ZTeam::deleteTeam); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java index 7ae9c99..2d9700a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java index 4f7a03e..ea3cb04 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/TeamsPermissionsChecker.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; import fr.zcraft.zteams.ZTeamsPermission; import fr.zcraft.zteams.permissions.PermissionsChecker; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java index d793922..15a5159 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/AllianceRequestCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AllianceRequest; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.Config; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AllianceRequest; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.Config; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeams; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -56,7 +56,7 @@ public class AllianceRequestCommand extends Command @Override protected void run() throws CommandException { - if (UR.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { error(I.t("The game is not started.")); } @@ -65,7 +65,7 @@ else if (args.length == 0) throwInvalidArgument(I.t("You must provide a player name.")); } - final AlliancesModule alliances = UR.module(AlliancesModule.class); + final AlliancesModule alliances = QSG.module(AlliancesModule.class); final Player requested = getPlayerParameter(0); @@ -80,7 +80,7 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge final AllianceRequest request = new AllianceRequest(playerSender().getUniqueId(), requested.getUniqueId()); - UR.log().info("New request: {0} - {1}", request, request.getError()); + QSG.log().info("New request: {0} - {1}", request, request.getError()); // The rule to send error messages is: no answer should not be distinguishable from // errors linked to existing alliances, because the alliances are secret. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java similarity index 72% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java index fce82f4..a330f42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/scenarii/alliances/commands/RequestAnswerCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AllianceRequest; -import eu.carrade.amaury.UHCReloaded.modules.scenarii.alliances.AlliancesModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AllianceRequest; +import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AlliancesModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.entity.Player; import java.util.UUID; @@ -52,7 +52,7 @@ protected void run() throws CommandException { if (args.length < 2) { - UR.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + QSG.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); throwInvalidArgument(I.t("Invalid command usage. But, you shouldn't use this command directly. What are you doing?")); } @@ -62,18 +62,18 @@ protected void run() throws CommandException final UUID requestID = UUID.fromString(args[0]); final boolean answer = getBooleanParameter(1); - final AllianceRequest request = UR.module(AlliancesModule.class).getRequestByID(requestID); + final AllianceRequest request = QSG.module(AlliancesModule.class).getRequestByID(requestID); if (request != null) { try { - UR.log(AlliancesModule.class).info("{0}: reply from {1}: {2}", request, player.getName(), answer); + QSG.log(AlliancesModule.class).info("{0}: reply from {1}: {2}", request, player.getName(), answer); request.registerApproval(player.getUniqueId(), answer); } catch (IllegalArgumentException e) { - UR.log(AlliancesModule.class).warning("{0}: {1} tried to reply {2} but was not in the approvers list.", request, player.getName(), answer); + QSG.log(AlliancesModule.class).warning("{0}: {1} tried to reply {2} but was not in the approvers list.", request, player.getName(), answer); error(I.t("You weren't asked for your opinion regarding this request.")); } } @@ -81,7 +81,7 @@ protected void run() throws CommandException } catch (IllegalArgumentException e) { - UR.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + QSG.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); throwInvalidArgument("Malformed UUID."); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java index 13ad7be..5d49190 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.starting.cages; +package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.colors.ColorsUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java index 8005284..735f25d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.starting.cages; +package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerAboutToBeTeleportedToSpawnPointEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerAboutToBeTeleportedToSpawnPointEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; import fr.zcraft.zteams.ZTeams; import org.bukkit.Location; import org.bukkit.Material; @@ -61,7 +61,7 @@ settings = Config.class, can_be_loaded_late = false ) -public class CagesModule extends UHModule +public class CagesModule extends QSGModule { private Map<Location, Cage> cages = new HashMap<>(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java index 0a71ed3..9c554ed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/starting/cages/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.starting.cages; +package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import org.bukkit.Material; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java index 0f9940a..209134f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.check; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.check; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; @CommandInfo(name = "border-check", usageParameters = "<radius>", aliases = {"bordercheck", "bcheck", "bc"}) public class CheckCommand extends Command @@ -53,7 +53,7 @@ protected void run() throws CommandException try { - UR.module(BorderModule.class).sendCheckMessage(sender, Integer.valueOf(args[0])); + QSG.module(BorderModule.class).sendCheckMessage(sender, Integer.valueOf(args[0])); } catch (NumberFormatException e) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java index d765361..2dd79f7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/check/CheckModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.check; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.check; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Material; import java.util.Collections; @@ -50,7 +50,7 @@ icon = Material.FENCE, when = ModuleLoadTime.ON_GAME_START ) -public class CheckModule extends UHModule +public class CheckModule extends QSGModule { @Override public List<Class<? extends Command>> getCommands() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java index 6751fcb..7cee576 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.food; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands.FeedAllCommand; -import eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands.FeedCommand; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands.FeedAllCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands.FeedCommand; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Material; import java.util.Arrays; @@ -53,7 +53,7 @@ category = ModuleCategory.UTILITIES, icon = Material.MUSHROOM_SOUP ) -public class FoodModule extends UHModule +public class FoodModule extends QSGModule { @Override public List<Class<? extends Command>> getCommands() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java index 75391a6..a82628a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedAllCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java similarity index 92% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java index 6e7ade4..19b7cef 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/food/commands/FeedCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.food.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.entity.Player; import java.util.List; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java similarity index 78% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java index 6f89bd8..d083bed 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; - -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.freezer; + +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -79,7 +79,7 @@ public void run() throws CommandException // /uh freeze on: freezes the sender if (args.length == 1) { - UR.module(FreezerModule.class).setPlayerFreezeState(playerSender(), on); + QSG.module(FreezerModule.class).setPlayerFreezeState(playerSender(), on); if (on) { @@ -102,16 +102,18 @@ else if (args.length == 2) } else { - UR.module(FreezerModule.class).setPlayerFreezeState(player, on); + QSG.module(FreezerModule.class).setPlayerFreezeState(player, on); if (on) { - player.sendMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where frozen by {0}.", sender.getName()))); + player.sendMessage( + QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where frozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now frozen.", player.getName())); } else { - player.sendMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where unfrozen by {0}.", sender.getName()))); + player.sendMessage( + QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where unfrozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now unfrozen.", player.getName())); } } @@ -122,16 +124,16 @@ else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none { final boolean on = subCommand.equalsIgnoreCase("all"); - UR.module(FreezerModule.class).setGlobalFreezeState(on); + QSG.module(FreezerModule.class).setGlobalFreezeState(on); Bukkit.broadcastMessage(""); if (on) { - Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The entire game is now frozen."))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The entire game is now frozen."))); } else { - Bukkit.broadcastMessage(UHUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The game is now unfrozen."))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The game is now unfrozen."))); } Bukkit.broadcastMessage(""); } @@ -150,7 +152,7 @@ else if (args.length == 2) if (args[0].equalsIgnoreCase("off")) { return getMatchingSubset( - UR.module(FreezerModule.class).getFrozenPlayers().stream() + QSG.module(FreezerModule.class).getFrozenPlayers().stream() .map(OfflinePlayer::getName) .collect(Collectors.toSet()), args[1]); @@ -159,8 +161,8 @@ else if (args.length == 2) else if (args[0].equalsIgnoreCase("on")) { return getMatchingSubset( - UR.game().getAlivePlayers().stream() - .filter(player -> !UR.module(FreezerModule.class).isPlayerFrozen(player)) + QSG.game().getAlivePlayers().stream() + .filter(player -> !QSG.module(FreezerModule.class).isPlayerFrozen(player)) .map(OfflinePlayer::getName) .collect(Collectors.toSet()), args[1] diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java similarity index 80% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java index 05fc93a..75489dc 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.freezer; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -51,7 +51,7 @@ public class FreezerListener implements Listener @EventHandler public void onBlockBreakEvent(final BlockBreakEvent ev) { - if (UR.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) + if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } @@ -63,7 +63,7 @@ public void onBlockBreakEvent(final BlockBreakEvent ev) @EventHandler public void onBlockPlaceEvent(final BlockPlaceEvent ev) { - if (UR.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) + if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } @@ -75,7 +75,7 @@ public void onBlockPlaceEvent(final BlockPlaceEvent ev) @EventHandler public void onPlayerMove(PlayerMoveEvent ev) { - UR.module(FreezerModule.class).freezePlayerIfNeeded(ev.getPlayer(), ev.getFrom(), ev.getTo()); + QSG.module(FreezerModule.class).freezePlayerIfNeeded(ev.getPlayer(), ev.getFrom(), ev.getTo()); } /** @@ -84,8 +84,8 @@ public void onPlayerMove(PlayerMoveEvent ev) @EventHandler public void onEntityShoot(EntityShootBowEvent ev) { - if ((ev.getEntity() instanceof Player && UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) - || UR.module(FreezerModule.class).getGlobalFreezeState()) + if ((ev.getEntity() instanceof Player && QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) + || QSG.module(FreezerModule.class).getGlobalFreezeState()) { ev.setCancelled(true); @@ -105,7 +105,7 @@ public void onEntityShoot(EntityShootBowEvent ev) @EventHandler public void onItemDespawn(ItemDespawnEvent ev) { - if (UR.module(FreezerModule.class).getGlobalFreezeState()) + if (QSG.module(FreezerModule.class).getGlobalFreezeState()) { ev.setCancelled(true); } @@ -117,9 +117,9 @@ public void onItemDespawn(ItemDespawnEvent ev) @EventHandler public void onEntitySpawn(CreatureSpawnEvent ev) { - if (UR.module(FreezerModule.class).getGlobalFreezeState() && ev.getEntity() instanceof Creature) + if (QSG.module(FreezerModule.class).getGlobalFreezeState() && ev.getEntity() instanceof Creature) { - UR.module(FreezerModule.class).freezeCreature((Creature) ev.getEntity(), true); + QSG.module(FreezerModule.class).freezeCreature((Creature) ev.getEntity(), true); } } @@ -131,7 +131,7 @@ public void onEntityDamage(final EntityDamageEvent ev) { if (ev.getEntity() instanceof Player) { - if (UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) + if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { ev.setCancelled(true); } @@ -144,7 +144,7 @@ public void onEntityDamage(final EntityDamageEvent ev) @EventHandler public void onFoodUpdate(FoodLevelChangeEvent ev) { - if (UR.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) + if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { if (ev.getFoodLevel() < ((Player) ev.getEntity()).getFoodLevel()) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java index 83ccb38..a562894 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/freezer/FreezerModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java @@ -29,18 +29,18 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.freezer; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.freezer; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -63,7 +63,7 @@ category = ModuleCategory.UTILITIES, icon = Material.PACKED_ICE ) -public class FreezerModule extends UHModule +public class FreezerModule extends QSGModule { private boolean isListenerRegistered = false; private FreezerListener freezerListener; @@ -149,34 +149,34 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) if (frozen) { - UR.game().getAlivePlayers().forEach(player -> setPlayerFreezeState(player, true)); + QSG.game().getAlivePlayers().forEach(player -> setPlayerFreezeState(player, true)); // Freezes the mobs by applying a Slowness effect. There isn't any EntityMoveEvent, so... - UR.get().getWorlds().stream() + QSG.get().getWorlds().stream() .flatMap(world -> world.getLivingEntities().stream()) .filter(entity -> entity instanceof Creature) .forEach(entity -> freezeCreature((Creature) entity, true)); // Freezes the timers. - UR.module(TimersModule.class).pauseAllRunning(true); + QSG.module(TimersModule.class).pauseAllRunning(true); } else { // All the online players are listed, not the internal list of frozen players, // to avoid a ConcurrentModificationException if the iterated list is being emptied. - UR.game().getAlivePlayers().stream() + QSG.game().getAlivePlayers().stream() .filter(this::isPlayerFrozen) .forEach(player -> this.setPlayerFreezeState(player, false)); // Removes the slowness effect - UR.get().getWorlds().stream() + QSG.get().getWorlds().stream() .flatMap(world -> world.getLivingEntities().stream()) .filter(entity -> entity instanceof Creature) .forEach(entity -> freezeCreature((Creature) entity, false)); // Unfreezes the timers. - UR.module(TimersModule.class).pauseAllRunning(false); + QSG.module(TimersModule.class).pauseAllRunning(false); } updateListenerRegistration(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java index 22ec402..df53647 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/HealthModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.health; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands.HealAllCommand; -import eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands.HealCommand; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands.HealAllCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands.HealCommand; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Material; import java.util.Arrays; @@ -53,7 +53,7 @@ category = ModuleCategory.UTILITIES, icon = Material.GOLDEN_APPLE ) -public class HealthModule extends UHModule +public class HealthModule extends QSGModule { @Override public List<Class<? extends Command>> getCommands() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java index 12a5c97..302a9a3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealAllCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -97,7 +97,7 @@ else if (health > player.getMaxHealth()) } player.setHealth(health); - UR.module(TeamsModule.class).getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); + QSG.module(TeamsModule.class).getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); } if (!add) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java index 21a7abd..c200f1a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/health/commands/HealCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.health.commands; - -import eu.carrade.amaury.UHCReloaded.modules.core.teams.TeamsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands; + +import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.entity.Player; import java.util.List; @@ -101,7 +101,7 @@ else if (health > 20D) target.setHealth(health); // TODO Could we get rid of this hard reference? - UR.module(TeamsModule.class).getSidebarPlayerCache(target.getUniqueId()).updateHealth(health); + QSG.module(TeamsModule.class).getSidebarPlayerCache(target.getUniqueId()).updateHealth(health); success(I.t("The health of {0} was set to {1}.", target.getName(), health)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java similarity index 91% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java index 4cc85da..ec54fb2 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/LoadPlayersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.playersLoader; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.playersLoader; -import eu.carrade.amaury.UHCReloaded.utils.OfflinePlayersLoader; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java similarity index 86% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java index 88937f9..4ba303a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/playersLoader/PlayersLoaderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.playersLoader; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.playersLoader; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Material; import java.util.Collections; @@ -49,7 +49,7 @@ category = ModuleCategory.UTILITIES, icon = Material.SKULL_ITEM // FIXME 1.13 ) -public class PlayersLoaderModule extends UHModule +public class PlayersLoaderModule extends QSGModule { @Override public List<Class<? extends Command>> getCommands() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java similarity index 81% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java index 52352c7..abda80a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationList; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java index 078a2a2..3b25e17 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java @@ -29,13 +29,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -47,7 +47,7 @@ public class RulesCommand extends Command { public void run() throws CommandException { - if (!UR.module(RulesModule.class).hasRules()) + if (!QSG.module(RulesModule.class).hasRules()) { error(I.t("{ce}No rules are set in the config file.")); } @@ -60,7 +60,7 @@ public void run() throws CommandException if (player.isPresent()) { - UR.module(RulesModule.class).displayRulesTo(player.get()); + QSG.module(RulesModule.class).displayRulesTo(player.get()); if (!sender.equals(player.get())) sender.sendMessage(I.t("{cs}Rules sent to {0}.", player.get().getName())); @@ -72,7 +72,7 @@ public void run() throws CommandException } else { - UR.module(RulesModule.class).broadcastRules(); + QSG.module(RulesModule.class).broadcastRules(); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java index f3f3c9c..edb449a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/rules/RulesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java @@ -29,19 +29,19 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.rules; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.CommandUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -62,7 +62,7 @@ icon = Material.BOOKSHELF, settings = Config.class ) -public class RulesModule extends UHModule +public class RulesModule extends QSGModule { private final List<String> rules = new ArrayList<>(); @@ -144,7 +144,7 @@ public void broadcastRules() @EventHandler public void onPlayerJoin(final PlayerJoinEvent ev) { - if (UR.game().getPhase() == GamePhase.WAIT && hasRules() && Config.DISPLAY.ON_JOIN.get()) + if (QSG.game().getPhase() == GamePhase.WAIT && hasRules() && Config.DISPLAY.ON_JOIN.get()) { RunTask.later(() -> { if (ev.getPlayer().isOnline()) displayRulesTo(ev.getPlayer()); }, 100L); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java index 6ac043e..16f305d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.runtimeCommandsExecutor; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import java.io.File; import java.util.Map; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java similarity index 93% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java index cd26b10..9641a9d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java @@ -29,18 +29,18 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationList; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.runtimeCommandsExecutor; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.scheduler.BukkitTask; @@ -65,7 +65,7 @@ icon = Material.COMMAND, settings = Config.class ) -public class RuntimeCommandsExecutor extends UHModule +public class RuntimeCommandsExecutor extends QSGModule { /** * Stores the commands to be executed later. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java index 880603f..a2de0b6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java @@ -30,10 +30,10 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.runtimeCommandsExecutor; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.runtimeCommandsExecutor; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import fr.zcraft.zlib.tools.PluginLogger; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import fr.zcraft.quartzlib.tools.PluginLogger; import org.bukkit.command.CommandException; import java.util.HashSet; @@ -44,12 +44,12 @@ */ public class ScheduledCommandsExecutorTask implements Runnable { - private final UHCReloaded p; + private final QuartzSurvivalGames p; private final HashSet<String> commands; public ScheduledCommandsExecutorTask(HashSet<String> commands) { - this.p = UHCReloaded.get(); + this.p = QuartzSurvivalGames.get(); this.commands = commands; } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java similarity index 77% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java index 9b25dc3..de89cd6 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.players.AlivePlayerDeathEvent; -import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPDeathCommand; -import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPSpawnCommand; -import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPSpectatorsCommand; -import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands.TPTeamCommand; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPDeathCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPSpawnCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPSpectatorsCommand; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPTeamCommand; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -56,7 +56,7 @@ category = ModuleCategory.UTILITIES, icon = Material.COMMAND_MINECART ) -public class TeleportationModule extends UHModule +public class TeleportationModule extends QSGModule { private final Map<UUID, Location> deathLocations = new HashMap<>(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java index 7c5a9c0..e4df846 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPDeathCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; -import eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.TeleportationModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.TeleportationModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -56,19 +56,19 @@ protected void run() throws CommandException final Player player = args.length > 0 ? getPlayerParameter(0) : playerSender(); final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); - if (!UR.module(TeleportationModule.class).hasDeathLocation(player)) + if (!QSG.module(TeleportationModule.class).hasDeathLocation(player)) { error(I.t("{ce}No death location available for the player {0}.", player.getName())); } - final Location deathLocation = UR.module(TeleportationModule.class).getDeathLocation(player); + final Location deathLocation = QSG.module(TeleportationModule.class).getDeathLocation(player); if (force) { - UHUtils.safeTP(player, deathLocation, true); + QSGUtils.safeTP(player, deathLocation, true); success(I.t("{cs}The player {0} was teleported back.", player.getName())); } - else if (UHUtils.safeTP(player, deathLocation)) + else if (QSGUtils.safeTP(player, deathLocation)) { success(I.t("{cs}The player {0} was teleported back.", player.getName())); } @@ -84,7 +84,7 @@ protected List<String> complete() { if (args.length == 1) { - final TeleportationModule tm = UR.module(TeleportationModule.class); + final TeleportationModule tm = QSG.module(TeleportationModule.class); return getMatchingPlayerNames( Bukkit.getOnlinePlayers().stream().filter(tm::hasDeathLocation).collect(Collectors.toList()), diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java similarity index 83% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java index b300b94..3c2066a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.teleporter.Teleporter; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.Teleporter; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -54,7 +54,7 @@ public class TPSpawnCommand extends Command @Override protected void run() throws CommandException { - final Teleporter teleporter = UR.module(GameModule.class).getTeleporter(); + final Teleporter teleporter = QSG.module(GameModule.class).getTeleporter(); if (teleporter == null) { @@ -77,7 +77,7 @@ protected void run() throws CommandException teleporter.teleportPlayer(player.getUniqueId(), true); success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); } - else if (UHUtils.safeTP(player, spawnLocation)) + else if (QSGUtils.safeTP(player, spawnLocation)) { success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); } @@ -91,7 +91,7 @@ else if (UHUtils.safeTP(player, spawnLocation)) @Override protected List<String> complete() { - final Teleporter teleporter = UR.module(GameModule.class).getTeleporter(); + final Teleporter teleporter = QSG.module(GameModule.class).getTeleporter(); if (teleporter == null) return null; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java index 6c271f6..5b11a0a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPSpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java @@ -31,13 +31,13 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; -import eu.carrade.amaury.UHCReloaded.modules.core.spectators.SpectatorsModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -53,7 +53,7 @@ public class TPSpectatorsCommand extends WorldBasedCommand @Override protected void run() throws CommandException { - final SpectatorsModule spectators = UR.module(SpectatorsModule.class); + final SpectatorsModule spectators = QSG.module(SpectatorsModule.class); // /uh tp-spectators <x> <y> <z> if (args.length == 3) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java similarity index 94% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java index 79c842a..45875e5 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/TPTeamCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java @@ -31,11 +31,11 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.texts.TextUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java similarity index 89% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java index 3d72ad7..0a65dce 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/teleportation/commands/WorldBasedCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java @@ -31,10 +31,10 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.teleportation.commands; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; import org.bukkit.entity.Player; @@ -53,7 +53,7 @@ else if (sender instanceof BlockCommandSender) } else { - return UR.get().getWorld(World.Environment.NORMAL); + return QSG.get().getWorld(World.Environment.NORMAL); } } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java index f6dc8ff..8c796e9 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import org.bukkit.Material; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java index 22f1c1e..69c5458 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.World; import org.bukkit.command.BlockCommandSender; import org.bukkit.entity.Player; @@ -64,13 +64,13 @@ else if (sender instanceof BlockCommandSender) } else { - world = UHCReloaded.get().getWorld(World.Environment.NORMAL); + world = QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL); info(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName())); } try { - UR.module(WallsModule.class).generateWalls(world); + QSG.module(WallsModule.class).generateWalls(world); } catch (CannotGenerateWallsException e) { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java similarity index 79% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java index cc214f6..ffaf2ac 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java @@ -31,18 +31,18 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.CannotGenerateWallsException; -import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions.UnknownWallGenerator; -import eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators.WallGenerator; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions.CannotGenerateWallsException; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions.UnknownWallGenerator; +import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators.WallGenerator; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; import org.bukkit.Material; import org.bukkit.World; @@ -58,14 +58,14 @@ icon = Material.BARRIER, settings = Config.class ) -public class WallsModule extends UHModule +public class WallsModule extends QSGModule { private BorderModule borderModule; @Override protected void onEnable() { - borderModule = UR.module(BorderModule.class); + borderModule = QSG.module(BorderModule.class); } @Override diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java index fdb448c..dfc0cd1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions; public class CannotGenerateWallsException extends Exception { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java index 71c635a..e917799 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.exceptions; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions; public class UnknownWallGenerator extends CannotGenerateWallsException { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java index 9e0b2a4..6c743d8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java index 4f0f2bf..b91d7b3 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java index 029b0e5..4ffafa1 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java @@ -30,9 +30,9 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; import org.apache.commons.lang3.Validate; import org.bukkit.Material; import org.bukkit.World; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java index ff82840..0455203 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/walls/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java @@ -30,7 +30,7 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.walls.generators; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; /** * Used to determine in witch wall we are, to get the "inner" block. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java index 6149ff1..7283d95 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java @@ -29,20 +29,20 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; -import eu.carrade.amaury.UHCReloaded.modules.core.border.BorderModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.MapShape; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.i18n.I; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class BorderWarningTask extends BukkitRunnable { - private final BorderModule borderModule = UR.module(BorderModule.class); - private final WarningModule warningModule = UR.module(WarningModule.class); + private final BorderModule borderModule = QSG.module(BorderModule.class); + private final WarningModule warningModule = QSG.module(WarningModule.class); @Override public void run() diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java similarity index 84% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java index 446dfe1..8047325 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java index f0f5942..ffc873f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java @@ -31,14 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.commands.CommandException; -import fr.zcraft.zlib.components.commands.CommandInfo; -import fr.zcraft.zlib.components.i18n.I; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.commands.CommandException; +import fr.zcraft.quartzlib.components.commands.CommandInfo; +import fr.zcraft.quartzlib.components.i18n.I; import java.util.List; @@ -52,7 +52,7 @@ public class WarningCommand extends Command @Override protected void run() throws CommandException { - final WarningModule warnings = UR.module(WarningModule.class); + final WarningModule warnings = QSG.module(WarningModule.class); // /uh border warning if (args.length == 0) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java similarity index 85% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java index 34b2cd7..0051116 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/utilities/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java @@ -31,20 +31,20 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.utilities.warning; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.border.events.BorderChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.Timer; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimersModule; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import fr.zcraft.zlib.components.commands.Command; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.tools.runners.RunTask; +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.events.BorderChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.components.commands.Command; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; @@ -61,7 +61,7 @@ icon = Material.FENCE_GATE, settings = Config.class ) -public class WarningModule extends UHModule +public class WarningModule extends QSGModule { private Integer warningSize = 0; @@ -144,7 +144,7 @@ public void setWarningSize(final int diameter, final TimeDelta timeLeft, final C warningTimer = new Timer(this.warningTimerName); warningTimer.setDuration((int) timeLeft.getSeconds()); - UR.module(TimersModule.class).registerTimer(warningTimer); + QSG.module(TimersModule.class).registerTimer(warningTimer); warningTimer.start(); } @@ -192,7 +192,7 @@ public void cancelWarning() if (warningTimer != null) { warningTimer.stop(); - UR.module(TimersModule.class).unregisterTimer(warningTimer); + QSG.module(TimersModule.class).unregisterTimer(warningTimer); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java similarity index 88% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java index cca7d5c..0a14d74 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait; +package eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationItem; -import fr.zcraft.zlib.components.configuration.ConfigurationSection; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; import org.bukkit.Material; import java.io.File; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.section; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java index d721b86..430f11b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/waitingPhase/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java @@ -31,28 +31,28 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.waitingPhase.wait; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GamePhase; -import eu.carrade.amaury.UHCReloaded.modules.core.game.events.game.GamePhaseChangedEvent; -import eu.carrade.amaury.UHCReloaded.modules.core.modules.gui.MainConfigGUI; -import eu.carrade.amaury.UHCReloaded.shortcuts.UR; -import eu.carrade.amaury.UHCReloaded.utils.EntitiesUtils; -import eu.carrade.amaury.UHCReloaded.utils.UHUtils; -import fr.zcraft.zlib.components.attributes.Attribute; -import fr.zcraft.zlib.components.attributes.Attributes; -import fr.zcraft.zlib.components.gui.Gui; -import fr.zcraft.zlib.components.i18n.I; -import fr.zcraft.zlib.core.ZLib; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.items.ItemStackBuilder; -import fr.zcraft.zlib.tools.reflection.NMSException; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ActionBar; +package eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.MainConfigGUI; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.EntitiesUtils; +import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import fr.zcraft.quartzlib.components.attributes.Attribute; +import fr.zcraft.quartzlib.components.attributes.Attributes; +import fr.zcraft.quartzlib.components.gui.Gui; +import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.reflection.NMSException; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.ActionBar; import fr.zcraft.zteams.ZTeam; import fr.zcraft.zteams.ZTeams; import fr.zcraft.zteams.events.PlayerJoinedTeamEvent; @@ -88,7 +88,7 @@ settings = Config.class, can_be_loaded_late = false ) -public class WaitModule extends UHModule +public class WaitModule extends QSGModule { private final static UUID ACTIONABLE_ITEM_UUID = UUID.fromString("3f65c4a9-e1ae-437e-b8b4-57d80a831480"); @@ -190,10 +190,11 @@ private boolean openGUI(Player player, ItemStack item) */ private void handleNewPlayer(final Player player) { - if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get() && UR.game().getPhase() != GamePhase.STARTING) + if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get() && QSG.game().getPhase() != GamePhase.STARTING) { - final Location worldSpawn = UR.get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); - if (!UHUtils.safeTP(player, worldSpawn)) + final Location worldSpawn = QSG + .get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); + if (!QSGUtils.safeTP(player, worldSpawn)) { player.teleport(worldSpawn.add(0, 1, 0)); } @@ -410,7 +411,7 @@ public void onEntityDamage(final EntityDamageEvent ev) if (ev.getEntity() instanceof Player) { if (!isGameStarted() - || (UR.module(GameModule.class).getPhase() == GamePhase.WAIT && !Config.ENABLE_PVP.get())) + || (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT && !Config.ENABLE_PVP.get())) { ev.setCancelled(true); } @@ -535,7 +536,7 @@ private boolean isBuilder(final Permissible player) */ private boolean isGameStarted() { - final GamePhase phase = UR.module(GameModule.class).getPhase(); + final GamePhase phase = QSG.module(GameModule.class).getPhase(); return phase != GamePhase.WAIT && phase != GamePhase.STARTING; } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java similarity index 87% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java index 3d751db..3b8a041 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures; +package eu.carrade.amaury.quartzsurvivalgames.modules.worldgen.creatures; -import fr.zcraft.zlib.components.configuration.ConfigurationInstance; -import fr.zcraft.zlib.components.configuration.ConfigurationList; +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import java.io.File; import java.util.Map; -import static fr.zcraft.zlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; public class Config extends ConfigurationInstance { diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java index a23e09c..d794a0d 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/modules/worldgen/creatures/CreaturesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java @@ -31,17 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.modules.worldgen.creatures; - -import eu.carrade.amaury.UHCReloaded.core.ModuleCategory; -import eu.carrade.amaury.UHCReloaded.core.ModuleInfo; -import eu.carrade.amaury.UHCReloaded.core.ModuleLoadTime; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import fr.zcraft.zlib.components.configuration.ConfigurationParseException; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; -import fr.zcraft.zlib.exceptions.IncompatibleMinecraftVersionException; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; +package eu.carrade.amaury.quartzsurvivalgames.modules.worldgen.creatures; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import fr.zcraft.quartzlib.components.configuration.ConfigurationParseException; +import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandlers; +import fr.zcraft.quartzlib.exceptions.IncompatibleMinecraftVersionException; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.entity.EntityType; @@ -63,7 +63,7 @@ icon = Material.MOB_SPAWNER, settings = Config.class ) -public class CreaturesModule extends UHModule +public class CreaturesModule extends QSGModule { /** * {@code true} if successfully hooked into NMS. diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java similarity index 82% rename from src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java index eb6e412..2d18c72 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/shortcuts/UR.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java @@ -31,16 +31,16 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.shortcuts; +package eu.carrade.amaury.quartzsurvivalgames.shortcuts; import com.google.common.reflect.ClassPath; -import eu.carrade.amaury.UHCReloaded.UHCReloaded; -import eu.carrade.amaury.UHCReloaded.core.ModuleLogger; -import eu.carrade.amaury.UHCReloaded.core.ModulesManager; -import eu.carrade.amaury.UHCReloaded.core.UHModule; -import eu.carrade.amaury.UHCReloaded.modules.core.game.GameModule; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.reflection.Reflection; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLogger; +import eu.carrade.amaury.quartzsurvivalgames.core.ModulesManager; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.apache.commons.lang.ArrayUtils; import java.util.HashMap; @@ -53,17 +53,17 @@ /** * Useful shortcuts. */ -public final class UR +public final class QSG { - private static final Map<Class<?>, Class<? extends UHModule>> classesModules = new HashMap<>(); - private static final Map<String, Class<? extends UHModule>> packagesModules = new HashMap<>(); + private static final Map<Class<?>, Class<? extends QSGModule>> classesModules = new HashMap<>(); + private static final Map<String, Class<? extends QSGModule>> packagesModules = new HashMap<>(); /** * Returns the plugin's instance. */ - public static UHCReloaded get() + public static QuartzSurvivalGames get() { - return UHCReloaded.get(); + return QuartzSurvivalGames.get(); } /** @@ -75,7 +75,7 @@ public static UHCReloaded get() * * @return The module's instance. */ - public static <M extends UHModule> M module(final Class<M> moduleClass) + public static <M extends QSGModule> M module(final Class<M> moduleClass) { return ModulesManager.getModule(moduleClass); } @@ -91,12 +91,12 @@ public static <M extends UHModule> M module(final Class<M> moduleClass) * @throws IllegalArgumentException if no module can be found for the caller * class. */ - public static UHModule module() + public static QSGModule module() { final Class<?> caller = Reflection.getCallerClass(); if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in module()"); - final Class<? extends UHModule> moduleClass = getModuleFromClass(caller); + final Class<? extends QSGModule> moduleClass = getModuleFromClass(caller); if (moduleClass != null) return module(moduleClass); @@ -121,7 +121,7 @@ public static GameModule game() * * @return {@code true} if the given module is loaded. */ - public static <M extends UHModule> boolean loaded(Class<M> moduleClass) + public static <M extends QSGModule> boolean loaded(Class<M> moduleClass) { return get().getModulesManager().isLoaded(moduleClass); } @@ -134,7 +134,7 @@ public static <M extends UHModule> boolean loaded(Class<M> moduleClass) * @param consumer The module's instance consumer. * @param <M> The module's type. */ - public static <M extends UHModule> void ifLoaded(final Class<M> moduleClass, Consumer<M> consumer) + public static <M extends QSGModule> void ifLoaded(final Class<M> moduleClass, Consumer<M> consumer) { final M module = module(moduleClass); if (module != null) consumer.accept(module); @@ -147,7 +147,7 @@ public static <M extends UHModule> void ifLoaded(final Class<M> moduleClass, Con * @param moduleClass The module's class. * @return The module's logger. */ - public static ModuleLogger log(final Class<? extends UHModule> moduleClass) + public static ModuleLogger log(final Class<? extends QSGModule> moduleClass) { try { @@ -176,7 +176,7 @@ public static ModuleLogger log() final Class<?> caller = Reflection.getCallerClass(); if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in log()"); - final Class<? extends UHModule> moduleClass = getModuleFromClass(caller); + final Class<? extends QSGModule> moduleClass = getModuleFromClass(caller); if (moduleClass != null) return log(moduleClass); @@ -186,7 +186,7 @@ public static ModuleLogger log() /** * Tries to retrieve the module of a given class. * - * It will lookup for a class extending {@link UHModule} in the class's + * It will lookup for a class extending {@link QSGModule} in the class's * package, then in the “parent” package, etc., until the “root” package is * reached. {@code null} will be returned if no package can be found. * @@ -195,7 +195,7 @@ public static ModuleLogger log() * @param clazz The class to search the module of. * @return The module class, or {@code null} if not found. */ - private static Class<? extends UHModule> getModuleFromClass(final Class<?> clazz) + private static Class<? extends QSGModule> getModuleFromClass(final Class<?> clazz) { if (classesModules.containsKey(clazz)) return classesModules.get(clazz); @@ -217,11 +217,11 @@ private static Class<? extends UHModule> getModuleFromClass(final Class<?> clazz { final Class<?> packajClazz = packajClazzInfo.load(); - if (UHModule.class.isAssignableFrom(packajClazz)) + if (QSGModule.class.isAssignableFrom(packajClazz)) { // We found the One™. @SuppressWarnings("unchecked") - final Class<? extends UHModule> moduleClazz = (Class<? extends UHModule>) packajClazz; + final Class<? extends QSGModule> moduleClazz = (Class<? extends QSGModule>) packajClazz; // We cache as hard as we can as these operations can be heavy. analyzedPackages.forEach(analyzed -> packagesModules.put(analyzed, moduleClazz)); @@ -258,5 +258,5 @@ private static Class<? extends UHModule> getModuleFromClass(final Class<?> clazz } } - private class UnknownModule extends UHModule {} + private static class UnknownModule extends QSGModule {} } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java similarity index 96% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java index 62bb464..3f74e5e 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/CommandUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -75,7 +75,7 @@ public static List<String> getAutocompleteSuggestions(String typed, List<String> else { // Not the primary use, but, hey! It works. - suggestion = UHUtils.getStringFromCommandArguments(rawSuggestion.split(" "), numberOfWordsToIgnore); + suggestion = QSGUtils.getStringFromCommandArguments(rawSuggestion.split(" "), numberOfWordsToIgnore); } if (rawSuggestion.toLowerCase().startsWith(typed.toLowerCase())) diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java index 066ce7e..b2fe59f 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/EntitiesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java @@ -31,7 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import org.bukkit.entity.*; import org.bukkit.event.entity.CreatureSpawnEvent; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java index bb1671c..9d842d8 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/ModulesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersComparator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersComparator.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java index 56d240c..e5c2723 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersComparator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java similarity index 95% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java index 54d85dc..400e00b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersLoader.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java @@ -29,16 +29,16 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; -import fr.zcraft.zlib.components.worker.Worker; -import fr.zcraft.zlib.components.worker.WorkerAttributes; -import fr.zcraft.zlib.components.worker.WorkerCallback; -import fr.zcraft.zlib.components.worker.WorkerRunnable; -import fr.zcraft.zlib.tools.Callback; -import fr.zcraft.zlib.tools.PluginLogger; -import fr.zcraft.zlib.tools.mojang.UUIDFetcher; -import fr.zcraft.zlib.tools.reflection.Reflection; +import fr.zcraft.quartzlib.components.worker.Worker; +import fr.zcraft.quartzlib.components.worker.WorkerAttributes; +import fr.zcraft.quartzlib.components.worker.WorkerCallback; +import fr.zcraft.quartzlib.components.worker.WorkerRunnable; +import fr.zcraft.quartzlib.tools.Callback; +import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.mojang.UUIDFetcher; +import fr.zcraft.quartzlib.tools.reflection.Reflection; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java similarity index 90% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java index 841c7cf..1f2083a 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHSound.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java @@ -30,11 +30,11 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; -import fr.zcraft.zlib.components.configuration.ConfigurationParseException; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandler; -import fr.zcraft.zlib.components.configuration.ConfigurationValueHandlers; +import fr.zcraft.quartzlib.components.configuration.ConfigurationParseException; +import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandler; +import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandlers; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -53,7 +53,7 @@ * * @author Amaury Carrade */ -public class UHSound +public class QSGSound { private Sound sound = null; private Float volume = 1f; @@ -64,13 +64,13 @@ public class UHSound * * @param sound The sound. */ - public UHSound(final Sound sound) + public QSGSound(final Sound sound) { Validate.notNull(sound, "The sound cannot be null."); this.sound = sound; } - public UHSound(final Sound sound, final Float volume, final Float pitch) + public QSGSound(final Sound sound, final Float volume, final Float pitch) { Validate.notNull(sound, "The sound cannot be null."); @@ -87,7 +87,7 @@ public UHSound(final Sound sound, final Float volume, final Float pitch) * * @param sound The sound name to be looked up. */ - public UHSound(final String sound) + public QSGSound(final String sound) { final Sound bukkitSound = string2Sound(sound); @@ -106,7 +106,7 @@ public UHSound(final String sound) * @param volume The sound volume. * @param pitch The sound pitch. */ - public UHSound(final String sound, final Float volume, final Float pitch) + public QSGSound(final String sound, final Float volume, final Float pitch) { final Sound bukkitSound = string2Sound(sound); @@ -125,7 +125,7 @@ public UHSound(final String sound, final Float volume, final Float pitch) * * @param sound A list of sounds to be looked up. The first one found will be used. */ - public UHSound(final String... sound) + public QSGSound(final String... sound) { Sound bukkitSound = null; @@ -150,7 +150,7 @@ public UHSound(final String... sound) * @param pitch The sound pitch. * @param sound A list of sounds to be looked up. The first one found will be used. */ - public UHSound(final Float volume, final Float pitch, final String... sound) + public QSGSound(final Float volume, final Float pitch, final String... sound) { Sound bukkitSound = null; @@ -180,7 +180,7 @@ public UHSound(final Float volume, final Float pitch, final String... sound) * * @param config The configuration section. */ - public UHSound(ConfigurationSection config) + public QSGSound(ConfigurationSection config) { if (config == null) { @@ -281,9 +281,9 @@ public int hashCode() public boolean equals(Object obj) { if (this == obj) return true; - if (!(obj instanceof UHSound)) return false; + if (!(obj instanceof QSGSound)) return false; - final UHSound other = (UHSound) obj; + final QSGSound other = (QSGSound) obj; if (pitch == null) { if (other.pitch != null) @@ -342,7 +342,7 @@ public static Sound handleSoundValue(final Object object) } @ConfigurationValueHandler - public static UHSound handleUHSoundValue(final Map<String, Object> section) throws ConfigurationParseException + public static QSGSound handleUHSoundValue(final Map<String, Object> section) throws ConfigurationParseException { if (!section.containsKey("name")) throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); @@ -366,15 +366,15 @@ else if (names instanceof Collection) soundNames[i++] = name.toString(); } - return new UHSound(volume, pitch, soundNames); + return new QSGSound(volume, pitch, soundNames); } else { - return new UHSound(names.toString(), volume, pitch); + return new QSGSound(names.toString(), volume, pitch); } } static { - ConfigurationValueHandlers.registerHandlers(UHSound.class); + ConfigurationValueHandlers.registerHandlers(QSGSound.class); } } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java index bbb9305..4d70f43 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/UHUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java @@ -30,12 +30,12 @@ * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; -import fr.zcraft.zlib.components.rawtext.RawText; -import fr.zcraft.zlib.components.rawtext.RawTextPart; -import fr.zcraft.zlib.tools.Callback; -import fr.zcraft.zlib.tools.PluginLogger; +import fr.zcraft.quartzlib.components.rawtext.RawText; +import fr.zcraft.quartzlib.components.rawtext.RawTextPart; +import fr.zcraft.quartzlib.tools.Callback; +import fr.zcraft.quartzlib.tools.PluginLogger; import org.apache.commons.lang.Validate; import org.bukkit.*; import org.bukkit.FireworkEffect.Builder; @@ -49,7 +49,7 @@ import java.util.stream.IntStream; -public class UHUtils +public class QSGUtils { private final static Random random = new Random(); diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java similarity index 99% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java index bbb8e80..1ddcc42 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/RecipesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java similarity index 97% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java index 17e98ef..0d1f2ad 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/Run.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java @@ -31,12 +31,12 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; -import eu.carrade.amaury.UHCReloaded.modules.core.timers.TimeDelta; -import fr.zcraft.zlib.tools.runners.RunTask; -import fr.zcraft.zlib.tools.text.ActionBar; -import fr.zcraft.zlib.tools.text.MessageSender; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import fr.zcraft.quartzlib.tools.runners.RunTask; +import fr.zcraft.quartzlib.tools.text.ActionBar; +import fr.zcraft.quartzlib.tools.text.MessageSender; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/TextUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java similarity index 98% rename from src/main/java/eu/carrade/amaury/UHCReloaded/utils/TextUtils.java rename to src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java index 6298d81..6edb92b 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/utils/TextUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java @@ -29,7 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded.utils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import com.google.common.collect.Sets; import org.apache.commons.lang.WordUtils; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c5bd683..8795a24 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,13 +1,13 @@ -name: UHPlugin -description: UltraHardcore Reloaded -main: eu.carrade.amaury.UHCReloaded.UHCReloaded +name: QuartzSurvivalGames +description: Survival games plugin, able to handle most Minecraft survival games (like UHC) through combined modules +main: eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames load: STARTUP version: 2.0-beta author: "Amaury Carrade" -authors: [azenet, "João Roda"] +authors: ["azenet", "João Roda"] awareness: - - !@UTF8 + - "!@UTF8" softdepend: - WorldBorder @@ -211,11 +211,10 @@ permissions: uh.player.renameTeam: - default: Allows a player to rename his own team. + description: Allows a player to rename his own team. default: op uh.team.gui: description: Allows a player to use the teams GUI (/uh team gui) default: true - diff --git a/src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java b/src/test/java/eu/carrade/amaury/quartzsurvivalgames/SidebarInjectorTest.java similarity index 98% rename from src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java rename to src/test/java/eu/carrade/amaury/quartzsurvivalgames/SidebarInjectorTest.java index 69b5ed8..9ac55bb 100644 --- a/src/test/java/eu/carrade/amaury/UHCReloaded/SidebarInjectorTest.java +++ b/src/test/java/eu/carrade/amaury/quartzsurvivalgames/SidebarInjectorTest.java @@ -29,9 +29,9 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.UHCReloaded; +package eu.carrade.amaury.quartzsurvivalgames; -import eu.carrade.amaury.UHCReloaded.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; import org.junit.Assert; import org.junit.ComparisonFailure; import org.junit.Test; From ebc1cb8c27b0cd2c8bdc17e4f12eef284ef3774c Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 25 Nov 2020 18:39:24 +0100 Subject: [PATCH 75/91] Migrate to both 1.15+ and QuartzLib --- pom.xml | 10 +- .../QuartzSurvivalGames.java | 8 +- .../core/ModuleCategory.java | 73 ++- .../core/ModuleLoadTime.java | 16 +- .../core/ModuleLogger.java | 8 +- .../core/ModuleWrapper.java | 50 +- .../core/ModulesManager.java | 205 ++++---- .../quartzsurvivalgames/core/QSGModule.java | 4 +- .../modules/core/border/BorderModule.java | 178 ++++--- .../modules/core/border/Config.java | 34 +- .../modules/core/border/MapShape.java | 12 +- .../core/border/commands/BorderCommand.java | 137 +++-- .../border/events/BorderChangedEvent.java | 22 +- .../core/border/shapes/CircularMapShape.java | 18 +- .../border/shapes/MapShapeDescriptor.java | 8 +- .../core/border/shapes/SquaredMapShape.java | 55 +-- .../worldborders/BrettflanWorldBorder.java | 107 ++-- .../border/worldborders/FakeWorldBorder.java | 69 +-- .../worldborders/VanillaWorldBorder.java | 68 +-- .../core/border/worldborders/WorldBorder.java | 90 ++-- .../modules/core/game/Config.java | 44 +- .../modules/core/game/GameModule.java | 467 ++++++++---------- .../modules/core/game/GamePhase.java | 4 +- .../core/game/commands/KillCommand.java | 43 +- .../core/game/commands/ResurrectCommand.java | 45 +- .../core/game/commands/StartCommand.java | 41 +- .../events/game/GamePhaseChangedEvent.java | 28 +- .../events/players/AlivePlayerDeathEvent.java | 41 +- .../players/PlayerResurrectedEvent.java | 26 +- .../game/events/players/TeamDeathEvent.java | 30 +- .../start/AfterTeleportationPhaseEvent.java | 12 +- .../start/BeforeTeleportationPhaseEvent.java | 12 +- ...rAboutToBeTeleportedToSpawnPointEvent.java | 27 +- .../start/PlayerSpawnPointSelectedEvent.java | 28 +- .../PlayerTeleportedToSpawnPointEvent.java | 27 +- .../core/game/submanagers/GameBeginning.java | 168 ++++--- .../game/teleporter/TeleportationMode.java | 4 +- .../teleporter/TeleportationRunnable.java | 25 +- .../core/game/teleporter/Teleporter.java | 72 ++- .../modules/core/modules/ModulesModule.java | 2 +- .../core/modules/gui/MainConfigGUI.java | 24 +- .../gui/modules/ConfirmModuleDisableGUI.java | 12 +- .../modules/gui/modules/FramedModuleGUI.java | 6 +- .../modules/gui/modules/ModulesListGUI.java | 8 +- .../core/modules/gui/start/StartGameGUI.java | 4 +- .../modules/core/sidebar/SidebarModule.java | 2 +- .../modules/core/spawns/SpawnsModule.java | 8 +- .../core/spawns/commands/SpawnsCommand.java | 8 +- .../CircularSpawnPointsGenerator.java | 2 +- .../generators/GridSpawnPointsGenerator.java | 2 +- .../RandomSpawnPointsGenerator.java | 2 +- .../core/spectators/SpectatorsModule.java | 2 +- .../managers/SpectatorsManager.java | 4 +- .../modules/core/teams/Config.java | 88 ++-- .../modules/core/teams/TeamsModule.java | 249 +++++----- .../teams/sidebar/SidebarCacheListener.java | 43 +- .../teams/sidebar/SidebarPlayerCache.java | 120 +++-- .../modules/core/timers/TimersModule.java | 2 +- .../cosmetics/episodes/EpisodesModule.java | 2 +- .../hardcoreHearts/HardcoreHeartsModule.java | 6 +- .../PlayerListHeaderFooterModule.java | 2 +- .../modules/end/EndAnnouncementModule.java | 56 +-- .../modules/end/FireworksModule.java | 25 +- .../modules/end/deathAnnouncement/Config.java | 18 +- .../DeathAnnouncementModule.java | 67 ++- .../modules/end/kick/Config.java | 17 +- .../modules/end/kick/KickModule.java | 15 +- .../modules/end/xpToKillers/Config.java | 17 +- .../end/xpToKillers/XpToKillersModule.java | 29 +- .../modules/external/dynmap/DynmapModule.java | 12 +- .../modules/external/hawk/Config.java | 25 +- .../modules/external/hawk/HawkModule.java | 12 +- .../modules/external/motd/MotdModule.java | 6 +- .../gameplay/OnerousGlisteringMelon.java | 6 +- .../gameplay/compass/CompassModule.java | 10 +- .../gameplay/compass/CompassRecipes.java | 8 +- .../daylightCycle/DaylightCycleModule.java | 2 +- .../goldenHeads/GoldenHeadsModule.java | 37 +- .../gameplay/potions/CancelBrewTask.java | 2 +- .../gameplay/potions/PotionsModule.java | 2 +- .../gameplay/weather/WeatherModule.java | 2 +- .../modules/other/StatisticsModule.java | 2 +- .../scenarii/alliances/AllianceRequest.java | 20 +- .../scenarii/alliances/AlliancesModule.java | 18 +- .../alliances/TeamsPermissionsChecker.java | 6 +- .../commands/AllianceRequestCommand.java | 4 +- .../modules/starting/cages/Cage.java | 107 ++-- .../modules/starting/cages/CagesModule.java | 4 +- .../modules/utilities/check/CheckModule.java | 2 +- .../modules/utilities/food/FoodModule.java | 2 +- .../utilities/freezer/FreezerModule.java | 8 +- .../playersLoader/PlayersLoaderModule.java | 2 +- .../RuntimeCommandsExecutor.java | 2 +- .../teleportation/TeleportationModule.java | 2 +- .../teleportation/commands/TPTeamCommand.java | 10 +- .../walls/generators/WallGenerator.java | 35 +- .../utilities/warning/WarningModule.java | 2 +- .../modules/waitingPhase/wait/Config.java | 11 +- .../modules/waitingPhase/wait/WaitModule.java | 22 +- .../worldgen/creatures/CreaturesModule.java | 2 +- .../utils/CommandUtils.java | 50 +- .../utils/EntitiesUtils.java | 20 +- .../utils/ModulesUtils.java | 51 +- .../utils/OfflinePlayersComparator.java | 17 +- .../utils/OfflinePlayersLoader.java | 146 +++--- .../quartzsurvivalgames/utils/QSGSound.java | 315 ++++++------ .../quartzsurvivalgames/utils/QSGUtils.java | 246 +++++---- .../utils/RecipesUtils.java | 101 ++-- .../amaury/quartzsurvivalgames/utils/Run.java | 126 +++-- .../quartzsurvivalgames/utils/TextUtils.java | 66 +-- 110 files changed, 2121 insertions(+), 2560 deletions(-) diff --git a/pom.xml b/pom.xml index 6506b29..5b5d4db 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ <artifactSet> <includes> <include>fr.zcraft:zlib</include> - <include>fr.zcraft:zteams</include> + <include>fr.zcraft:QuartzTeams</include> <include>me.cassayre.florian:Hawk</include> </includes> </artifactSet> @@ -110,7 +110,7 @@ </relocation> <relocation> <pattern>fr.zcraft.quartzteams</pattern> - <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzteams</shadedPattern> + <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartQuartzTeams</shadedPattern> </relocation> <relocation> <pattern>me.cassayre.florian.hawk</pattern> @@ -157,8 +157,8 @@ <url>https://maven.zcraft.fr/QuartzLib</url> </repository> <repository> - <id>zdevelpers-quartzteams</id> - <url>https://maven.zcraft.fr/QuartzTeams</url> + <id>zdevelpers-quartQuartzTeams</id> + <url>https://maven.zcraft.fr/QuartQuartzTeams</url> </repository> </repositories> <dependencies> @@ -171,7 +171,7 @@ <dependency> <groupId>fr.zcraft</groupId> <artifactId>quartzlib</artifactId> - <version>0.0.1-SNAPSHOT</version> + <version>0.0.1</version> </dependency> <dependency> <groupId>fr.zcraft</groupId> diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java index a57bb80..4e71c29 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java @@ -48,8 +48,8 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.i18n.I18n; import fr.zcraft.quartzlib.components.scoreboard.SidebarScoreboard; -import fr.zcraft.quartzlib.core.ZLib; -import fr.zcraft.quartzlib.core.ZPlugin; +import fr.zcraft.quartzlib.core.QuartzLib; +import fr.zcraft.quartzlib.core.QuartzPlugin; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Bukkit; @@ -66,7 +66,7 @@ import java.util.function.BiConsumer; -public class QuartzSurvivalGames extends ZPlugin implements Listener +public class QuartzSurvivalGames extends QuartzPlugin implements Listener { private static QuartzSurvivalGames instance; @@ -104,7 +104,7 @@ public void onEnable() /* *** Core events *** */ - ZLib.registerEvents(this); + QuartzLib.registerEvents(this); /* *** Core modules *** */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java index a2d7186..8e4d63c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java @@ -31,103 +31,101 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.core; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import java.util.function.Supplier; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import java.util.function.Supplier; - -public enum ModuleCategory -{ - CORE ( +public enum ModuleCategory { + CORE( I.t("Core Modules"), I.t("These modules are the core of UHCReloaded, required by other modules."), Material.BEDROCK, ChatColor.DARK_RED ), - WORLD_GENERATION ( + WORLD_GENERATION( I.t("World Generation"), I.t("These modules alter the world generation. To use them, the server must be started without world."), - Material.REDSTONE_COMPARATOR, + Material.COMPARATOR, ChatColor.DARK_GREEN ), - WAITING_PHASE ( + WAITING_PHASE( I.t("Waiting Phase"), I.t("These modules manage the waiting phase, when the game is not yet started."), - Material.WATCH, + Material.CLOCK, ChatColor.YELLOW ), - STARTING ( + STARTING( I.t("Game Beginning"), I.t("These modules enhance the starting phase of the game."), Material.FEATHER, ChatColor.GOLD ), - END ( + END( I.t("Game End"), I.t("These modules alter the game end (either player deaths or whole game end)."), - Material.SKULL_ITEM, + Material.SKELETON_SKULL, ChatColor.RED ), - GAMEPLAY ( + GAMEPLAY( I.t("Gameplay"), I.t("These modules alter the world or gameplay during the game, e.g. adding or nerfing creatures, effects... This category does not contains scenarii, which are in a dedicated one."), Material.SADDLE, ChatColor.DARK_AQUA ), - SCENARII ( + SCENARII( I.t("Scenarii"), I.t("These modules adds scenarii to the game, i.e. global set of changes that changes the gameplay in a deeper way, and possibly the whole game experience."), - Material.BEACON, + Material.KNOWLEDGE_BOOK, ChatColor.AQUA ), - UTILITIES ( + UTILITIES( I.t("Utilities"), I.t("These modules provides tools and utilities to manage the game and offer useful commands."), - Material.COMMAND, + Material.REPEATING_COMMAND_BLOCK, ChatColor.DARK_PURPLE ), - COSMETICS ( + COSMETICS( I.t("Cosmetics"), I.t("These modules adds cosmetics things to the game, like effects or visual enhancements that can be useful but does not change the gameplay."), - new ItemStackBuilder(Material.RED_ROSE).data((short) 1), // FIXME 1.13 + Material.ROSE_BUSH, ChatColor.LIGHT_PURPLE ), - EXTERNAL ( + EXTERNAL( I.t("External"), I.t("These modules adds features alongside the game, like web maps, external summaries..."), Material.ENDER_CHEST, ChatColor.DARK_GREEN ), - OTHER ( + OTHER( I.t("Others"), I.t("All uncategorized modules goes there."), () -> { - final ItemStack icon = new ItemStackBuilder(Material.SKULL_ITEM).data((short) 3).item(); + // TODO use updated ISB in QuartzLib 0.1 + final ItemStack icon = new ItemStackBuilder(Material.PLAYER_HEAD).item(); final SkullMeta meta = (SkullMeta) icon.getItemMeta(); meta.setOwner("MHF_Question"); icon.setItemMeta(meta); return icon; }, ChatColor.WHITE - ) - - ; + ); private final String displayName; @@ -135,8 +133,7 @@ public enum ModuleCategory private final ItemStack icon; private final ChatColor color; - ModuleCategory(final String displayName, final String description, final ItemStack icon, ChatColor color) - { + ModuleCategory(final String displayName, final String description, final ItemStack icon, ChatColor color) { this.displayName = displayName; this.description = description; @@ -144,38 +141,32 @@ public enum ModuleCategory this.color = color; } - ModuleCategory(final String displayName, final String description, final ItemStackBuilder icon, ChatColor color) - { + ModuleCategory(final String displayName, final String description, final ItemStackBuilder icon, ChatColor color) { this(displayName, description, icon.item(), color); } - ModuleCategory(final String displayName, final String description, final Supplier<ItemStack> icon, ChatColor color) - { + ModuleCategory(final String displayName, final String description, final Supplier<ItemStack> icon, + ChatColor color) { this(displayName, description, icon.get(), color); } - ModuleCategory(final String displayName, final String description, final Material icon, ChatColor color) - { + ModuleCategory(final String displayName, final String description, final Material icon, ChatColor color) { this(displayName, description, new ItemStack(icon), color); } - public String getDisplayName() - { + public String getDisplayName() { return displayName; } - public String getDescription() - { + public String getDescription() { return description; } - public ItemStack getIcon() - { + public ItemStack getIcon() { return icon.clone(); } - public ChatColor getColor() - { + public ChatColor getColor() { return color; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java index a4d852a..bb6a0da 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLoadTime.java @@ -31,15 +31,15 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.core; import fr.zcraft.quartzlib.components.i18n.I; -public enum ModuleLoadTime -{ +public enum ModuleLoadTime { /** * Loads the module at startup, before the worlds are loaded. - * + * <p> * Please note that most core modules (and localization) are not loaded at this point. Use that * for modules altering the world generation. */ @@ -66,21 +66,17 @@ public enum ModuleLoadTime /** * Loads the module when the game ends. */ - ON_GAME_END(I.t("When the game ends")) - - ; + ON_GAME_END(I.t("When the game ends")); private final String description; - ModuleLoadTime(String description) - { + ModuleLoadTime(String description) { this.description = description; } - public String getDescription() - { + public String getDescription() { return description; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java index f2c0c79..c38ae84 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java @@ -36,7 +36,7 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.components.rawtext.RawText; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.text.RawMessage; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -50,13 +50,13 @@ public class ModuleLogger extends Logger { private final String loggerName; public ModuleLogger(Class<? extends QSGModule> module) { - super(ZLib.getPlugin().getClass().getCanonicalName(), null); + super(QuartzLib.getPlugin().getClass().getCanonicalName(), null); - setParent(ZLib.getPlugin().getLogger()); + setParent(QuartzLib.getPlugin().getLogger()); setLevel(Level.ALL); moduleName = ModuleWrapper.computeModuleName(module); - loggerName = "[" + ZLib.getPlugin().getName() + "] [" + moduleName + "] "; + loggerName = "[" + QuartzLib.getPlugin().getName() + "] [" + moduleName + "] "; } @Override diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java index cf95a16..d7ea5df 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java @@ -41,10 +41,17 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.reflection.Reflection; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.util.stream.Stream; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; @@ -53,10 +60,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.util.stream.Stream; - public class ModuleWrapper { private final String name; @@ -68,20 +71,15 @@ public class ModuleWrapper { private final ModuleCategory category; private final Material icon; - - private boolean enabled; - private final Class<? extends QSGModule> moduleClass; - private final Class<? extends ConfigurationInstance> moduleConfiguration; private final String settingsFileName; private final String settingsDefaultFileName; - private String[] dependencies; - private final boolean internal; private final boolean canBeUnloaded; private final boolean canBeLoadedLate; - + private boolean enabled; + private final String[] dependencies; private QSGModule instance = null; public ModuleWrapper(final Class<? extends QSGModule> moduleClass) { @@ -130,6 +128,17 @@ public ModuleWrapper(final Class<? extends QSGModule> moduleClass, boolean enabl loadConfiguration(); } + static String computeModuleName(Class<? extends QSGModule> moduleClass) { + final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); + + if (info == null || info.name().isEmpty()) { + return StringUtils.capitalize( + String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); + } else { + return info.name(); + } + } + /** * Enables this module. * @@ -160,7 +169,7 @@ public boolean load(boolean late) { } } - instance = ZLib.loadComponent(moduleClass); + instance = QuartzLib.loadComponent(moduleClass); Bukkit.getPluginManager().callEvent(new ModuleLoadedEvent(this, late)); @@ -180,7 +189,7 @@ public void unload() { } instance.setEnabled(false); - ZLib.unregisterEvents(instance); + QuartzLib.unregisterEvents(instance); Bukkit.getPluginManager().callEvent(new ModuleUnloadedEvent(this)); @@ -363,7 +372,7 @@ private String getDefaultSettingsFileName() { private File getConfigurationFile() { final String settingsFileName = this.settingsFileName != null ? this.settingsFileName + ".yml" : getDefaultSettingsFileName() + ".yml"; - return new File(ZLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); + return new File(QuartzLib.getPlugin().getDataFolder(), "modules" + File.separator + settingsFileName); } /** @@ -489,15 +498,4 @@ public boolean isLoaded() { public QSGModule get() { return instance; } - - static String computeModuleName(Class<? extends QSGModule> moduleClass) { - final ModuleInfo info = moduleClass.getAnnotation(ModuleInfo.class); - - if (info == null || info.name().isEmpty()) { - return StringUtils.capitalize( - String.join(" ", StringUtils.splitByCharacterTypeCamelCase(moduleClass.getSimpleName()))); - } else { - return info.name(); - } - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java index 7778989..f2d40f7 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.core; import com.google.common.reflect.ClassPath; @@ -45,10 +46,22 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.ModulesUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.Commands; -import fr.zcraft.quartzlib.core.ZLib; -import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.core.QuartzLib; +import fr.zcraft.quartzlib.core.QuartzComponent; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.command.CommandMap; import org.bukkit.command.PluginCommand; @@ -56,14 +69,7 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.stream.Collectors; - -public class ModulesManager extends ZLibComponent implements Listener -{ +public class ModulesManager extends QuartzComponent implements Listener { /** * The package were all built-in modules are stored. */ @@ -87,52 +93,64 @@ public class ModulesManager extends ZLibComponent implements Listener /** * All the registered modules. */ - private Map<Class<? extends QSGModule>, ModuleWrapper> modules = new HashMap<>(); + private final Map<Class<? extends QSGModule>, ModuleWrapper> modules = new HashMap<>(); /** * These loads times were loaded using {@link #loadModules(ModuleLoadTime)} and are stored to not * be loaded again (e.g. in case of cancelled start, modules with {@link ModuleLoadTime#ON_GAME_STARTING} * will not be loaded twice). */ - private Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); + private final Set<ModuleLoadTime> loadedPriorities = new HashSet<>(); + /** + * Gets a module's instance. This may return null if the module is not currently + * enabled. + * + * @param moduleClass The module's class. + * @param <M> The module's type. + * @return The module's instance. + */ + public static <M extends QSGModule> M getModule(final Class<M> moduleClass) { + final ModuleWrapper module = QSG.get().getModulesManager().modules.get(moduleClass); + + if (module == null || !module.isLoaded()) { + return null; + } else { + return (M) module.get(); + } + } /** * Lookup and loads all built-in modules. They will be enabled by default, except if in * the {@link #DISABLED_BY_DEFAULT disabled-by-default list}. */ - public void registerBuiltInModules() - { + public void registerBuiltInModules() { final long t = System.currentTimeMillis(); int i = 0; - try - { - for (final ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(MODULES_PACKAGE)) - { + try { + for (final ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()) + .getTopLevelClassesRecursive(MODULES_PACKAGE)) { final Class<?> potentialModuleClass = classInfo.load(); - if (QSGModule.class.isAssignableFrom(potentialModuleClass)) - { - registerModule((Class<? extends QSGModule>) potentialModuleClass, !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); + if (QSGModule.class.isAssignableFrom(potentialModuleClass)) { + registerModule((Class<? extends QSGModule>) potentialModuleClass, + !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); i++; } } } - catch (final IOException e) - { + catch (final IOException e) { PluginLogger.error("Unable to load built-in modules.", e); } PluginLogger.info("Registered {0} built-in modules in {1}ms", i, System.currentTimeMillis() - t); } - /** * @return A view on all registered modules. */ - public Collection<ModuleWrapper> getModules() - { + public Collection<ModuleWrapper> getModules() { return modules.values(); } @@ -142,30 +160,27 @@ public Collection<ModuleWrapper> getModules() * @param modules the module's class, that must accept a zero-arguments constructor. */ @SafeVarargs - public final void registerModules(final Class<? extends QSGModule>... modules) - { + public final void registerModules(final Class<? extends QSGModule>... modules) { Arrays.stream(modules).forEach(module -> registerModule(module, true)); } /** * Registers an UHCReloaded module. It is not loaded by this method. * - * @param module the module's class, that must accept a zero-arguments constructor. + * @param module the module's class, that must accept a zero-arguments constructor. * @param initiallyEnabled {@code true} if this module, according to the configuration file, should be enabled at startup. */ - public void registerModule(final Class<? extends QSGModule> module, final boolean initiallyEnabled) - { - if (!modules.containsKey(module)) - { + public void registerModule(final Class<? extends QSGModule> module, final boolean initiallyEnabled) { + if (!modules.containsKey(module)) { this.modules.put(module, new ModuleWrapper(module, initiallyEnabled)); } } /** * Registers an UHCReloaded module. It is not loaded by this method. - * + * <p> * It tries to load the following classes (in this order, taking the first existing): - * + * <p> * - eu.carrade.amaury.UHCReloaded.modules.[name] * - eu.carrade.amaury.UHCReloaded.modules.[name]Module * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] @@ -179,16 +194,15 @@ public void registerModule(final Class<? extends QSGModule> module, final boolea * * @param module the module's class name; the class must accept a zero-arguments constructor. */ - public void registerModule(final String module) - { + public void registerModule(final String module) { registerModule(module, true); } /** * Registers an UHCReloaded module. It is not loaded by this method. - * + * <p> * It tries to load the following classes (in this order, taking the first existing): - * + * <p> * - eu.carrade.amaury.UHCReloaded.modules.[name] * - eu.carrade.amaury.UHCReloaded.modules.[name]Module * - eu.carrade.amaury.UHCReloaded.modules.[capitalizedName] @@ -200,12 +214,11 @@ public void registerModule(final String module) * - eu.carrade.amaury.UHCReloaded.modules.[firstLowercasedName].Module * - [name] * - * @param module the module's class name; the class must accept a zero-arguments constructor. + * @param module the module's class name; the class must accept a zero-arguments constructor. * @param initiallyEnabled {@code true} if this module, according to the configuration file, * should be enabled at startup. */ - public void registerModule(final String module, boolean initiallyEnabled) - { + public void registerModule(final String module, boolean initiallyEnabled) { final Class<? extends QSGModule> moduleClass = ModulesUtils.getClassFromName( module.replace('-', '.'), MODULES_PACKAGE, @@ -213,26 +226,24 @@ public void registerModule(final String module, boolean initiallyEnabled) QSGModule.class ); - if (moduleClass != null) - { + if (moduleClass != null) { registerModule(moduleClass, initiallyEnabled); - } - else - { - PluginLogger.error("Error registering a module: unable to find a module named {0} in the class path. Maybe you spelled it wrong?", module); + } else { + PluginLogger + .error("Error registering a module: unable to find a module named {0} in the class path. Maybe you spelled it wrong?", + module); } } - - /** * Loads registered modules. Internal modules will always be loaded first. * * @param loadTime Loads the modules registered to be loaded at that given time. */ - public void loadModules(final ModuleLoadTime loadTime) - { - if (loadedPriorities.contains(loadTime)) return; + public void loadModules(final ModuleLoadTime loadTime) { + if (loadedPriorities.contains(loadTime)) { + return; + } // Loads all internal modules first modules.values().stream() @@ -263,8 +274,7 @@ public void loadModules(final ModuleLoadTime loadTime) * @param loadTime The load time. * @return {@code true} if loaded. */ - public boolean isLoaded(final ModuleLoadTime loadTime) - { + public boolean isLoaded(final ModuleLoadTime loadTime) { return loadedPriorities.contains(loadTime); } @@ -274,34 +284,14 @@ public boolean isLoaded(final ModuleLoadTime loadTime) * @param module The module's class. * @return {@code true} if loaded. */ - public boolean isLoaded(final Class<? extends QSGModule> module) - { + public boolean isLoaded(final Class<? extends QSGModule> module) { final ModuleWrapper wrapper = modules.get(module); return wrapper != null && wrapper.isLoaded(); } - /** - * Gets a module's instance. This may return null if the module is not currently - * enabled. - * - * @param moduleClass The module's class. - * @param <M> The module's type. - * - * @return The module's instance. - */ - public static <M extends QSGModule> M getModule(final Class<M> moduleClass) - { - final ModuleWrapper module = QSG.get().getModulesManager().modules.get(moduleClass); - - if (module == null || !module.isLoaded()) return null; - else return (M) module.get(); - } - - - @SuppressWarnings ("unchecked") - private void collectCommandsFromModules() - { + @SuppressWarnings("unchecked") + private void collectCommandsFromModules() { Commands.register("uh", modules.values().stream() .filter(ModuleWrapper::isLoaded) .map(module -> module.get().getCommands()) @@ -322,37 +312,37 @@ private void collectCommandsFromModules() final Map<org.bukkit.command.Command, Class<? extends Command>> pluginCommands = new HashMap<>(); final Set<String> registered = new HashSet<>(); - try - { - final Constructor<PluginCommand> pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); + try { + final Constructor<PluginCommand> pluginCommandConstructor = + PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); pluginCommandConstructor.setAccessible(true); - for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) - { - try - { - pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), ZLib.getPlugin()), commandAlias.getValue()); + for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) { + try { + pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), QuartzLib.getPlugin()), + commandAlias.getValue()); registered.add(commandAlias.getKey()); } - catch (InstantiationException | InvocationTargetException | IllegalAccessException e) - { - PluginLogger.error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", e, commandAlias); + catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { + PluginLogger + .error("Unable to register plugin command for {0}, is this version supported by UHCReloaded?", + e, commandAlias); } } - try - { + try { final CommandMap commandMap = (CommandMap) Reflection.getFieldValue(Bukkit.getServer(), "commandMap"); String mutPrefix = QSG.get().getDescription().getPrefix(); - if (mutPrefix == null) mutPrefix = QSG.get().getDescription().getName().toLowerCase(); + if (mutPrefix == null) { + mutPrefix = QSG.get().getDescription().getName().toLowerCase(); + } final String prefix = mutPrefix; pluginCommands.forEach((pluginCommand, commandClass) -> { - if (commandMap.register(prefix, pluginCommand)) - { + if (commandMap.register(prefix, pluginCommand)) { PluginLogger.info( "Hot-registered new command /{0} for class “{1}”.", pluginCommand.getName(), @@ -361,14 +351,15 @@ private void collectCommandsFromModules() } }); } - catch (NoSuchFieldException | IllegalAccessException e) - { - PluginLogger.error("Unable to retrieve Bukkit's command map, is this version supported by UHCReloaded?", e); + catch (NoSuchFieldException | IllegalAccessException e) { + PluginLogger + .error("Unable to retrieve Bukkit's command map, is this version supported by UHCReloaded?", e); } } - catch (NoSuchMethodException | SecurityException e) - { - PluginLogger.error("Unable to register plugin commands: unable to retrieve PluginCommand's constructor. Is this version supported by UHCReloaded?", e); + catch (NoSuchMethodException | SecurityException e) { + PluginLogger + .error("Unable to register plugin commands: unable to retrieve PluginCommand's constructor. Is this version supported by UHCReloaded?", + e); } // Now that all commands are registered into Bukkit, we can register them into zLib. @@ -376,29 +367,27 @@ private void collectCommandsFromModules() commandAliases.forEach((name, klass) -> { // Bukkit registration failed? - if (!registered.contains(name)) return; + if (!registered.contains(name)) { + return; + } Commands.registerShortcut("uh", klass, name); }); } - @EventHandler - public void onModuleLoaded(final ModuleLoadedEvent ev) - { + public void onModuleLoaded(final ModuleLoadedEvent ev) { PluginLogger.info("Module {0} loaded.", ev.getModule().getName()); - if (ev.isLoadedLate()) - { + if (ev.isLoadedLate()) { // If loaded late, we may have to re-register the module's commands. collectCommandsFromModules(); } } @EventHandler - public void onModuleUnloaded(final ModuleUnloadedEvent ev) - { + public void onModuleUnloaded(final ModuleUnloadedEvent ev) { PluginLogger.info("Module {0} unloaded.", ev.getModule().getName()); // We remove commands if needed when a module is unloaded, diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java index 2764840..fc653c9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/QSGModule.java @@ -35,14 +35,14 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.scoreboard.Sidebar; -import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.core.QuartzComponent; import java.util.List; import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.event.Listener; -public abstract class QSGModule extends ZLibComponent implements Listener { +public abstract class QSGModule extends QuartzComponent implements Listener { protected ModuleLogger logger; public QSGModule() { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java index e597eca..70d5404 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; @@ -47,7 +48,7 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.Titles; import org.bukkit.*; @@ -62,17 +63,16 @@ import java.util.stream.Collectors; -@ModuleInfo ( +@ModuleInfo( name = "Border", description = "Manages the border size and reduction.", category = ModuleCategory.CORE, - icon = Material.FENCE, + icon = Material.BIRCH_FENCE, settings = Config.class, can_be_unloaded = false, internal = true ) -public class BorderModule extends QSGModule -{ +public class BorderModule extends QSGModule { private MapShape mapShape = null; private WorldBorder border = null; @@ -84,9 +84,8 @@ public class BorderModule extends QSGModule private final List<String> sidebar = new ArrayList<>(); @Override - public void onEnable() - { - worldBorderDependency = ZLib.loadComponent(WorldBorderDependency.class); + public void onEnable() { + worldBorderDependency = QuartzLib.loadComponent(WorldBorderDependency.class); mapShape = Config.SHAPE.get(); @@ -104,36 +103,36 @@ public void onEnable() } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(BorderCommand.class); } @Override - public void prepareInjectionIntoSidebar() - { - if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) return; + public void prepareInjectionIntoSidebar() { + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { + return; + } sidebar.clear(); - if (Config.SIDEBAR.DISPLAYED.get()) - { + if (Config.SIDEBAR.DISPLAYED.get()) { /// Title of the border section in the sidebar sidebar.add(I.t("{blue}{bold}Border")); int diameter = (int) Math.ceil(border.getDiameter()); - if (Config.SIDEBAR.DISPLAY_DIAMETER.get() || border.getShape() == MapShape.CIRCULAR) - { + if (Config.SIDEBAR.DISPLAY_DIAMETER.get() || border.getShape() == MapShape.CIRCULAR) { if (border.getShape() == MapShape.SQUARED) - /// Border diameter for a squared map in the sidebar + /// Border diameter for a squared map in the sidebar + { sidebar.add(I.tn("{white}{0} block wide", "{white}{0} blocks wide", diameter, diameter)); - else - /// Border diameter for a circular map in the sidebar - sidebar.add(I.tn("{gray}Diameter: {white}{0} block", "{gray}Diameter: {white}{0} blocks", diameter, diameter)); - } - else - { + } else + /// Border diameter for a circular map in the sidebar + { + sidebar.add(I.tn("{gray}Diameter: {white}{0} block", "{gray}Diameter: {white}{0} blocks", diameter, + diameter)); + } + } else { Location center = border.getCenter(); int radius = (int) Math.ceil(diameter / 2d); @@ -143,26 +142,27 @@ public void prepareInjectionIntoSidebar() int maxZ = center.getBlockZ() + radius; // Same min & max, we can display both at once - if (minX == minZ && maxX == maxZ) - { + if (minX == minZ && maxX == maxZ) { /// Min & max coordinates in the sidebar, to locate the border. Ex: "-500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{white}{0} {1}", QSGUtils.integerToStringWithSign(minX), QSGUtils.integerToStringWithSign(maxZ))); - } - else - { + sidebar.add(I.t("{white}{0} {1}", QSGUtils.integerToStringWithSign(minX), + QSGUtils.integerToStringWithSign(maxZ))); + } else { /// Min & max X coordinates in the sidebar, to locate the border. Ex: "X: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}X: {white}{0} {1}", QSGUtils.integerToStringWithSign(minX), QSGUtils.integerToStringWithSign(maxX))); + sidebar.add(I.t("{gray}X: {white}{0} {1}", QSGUtils.integerToStringWithSign(minX), + QSGUtils.integerToStringWithSign(maxX))); /// Min & max Z coordinates in the sidebar, to locate the border. Ex: "Z: -500 +500". {0} = minimal coord, {1} = maximal coord. - sidebar.add(I.t("{gray}Z: {white}{0} {1}", QSGUtils.integerToStringWithSign(minZ), QSGUtils.integerToStringWithSign(maxZ))); + sidebar.add(I.t("{gray}Z: {white}{0} {1}", QSGUtils.integerToStringWithSign(minZ), + QSGUtils.integerToStringWithSign(maxZ))); } } } } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { - if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) return; + public void injectIntoSidebar(Player player, SidebarInjector injector) { + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME) || sidebar.isEmpty()) { + return; + } injector.injectLines(SidebarInjector.SidebarPriority.MIDDLE_BOTTOM, true, sidebar); } @@ -171,8 +171,7 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) * * @param shape The shape. */ - public void setMapShape(MapShape shape) - { + public void setMapShape(MapShape shape) { this.mapShape = shape; border.setShape(shape); } @@ -182,21 +181,18 @@ public void setMapShape(MapShape shape) * * @return The shape. */ - public MapShape getMapShape() - { + public MapShape getMapShape() { return mapShape; } /** * @return The WorldBorder proxy to set the border in-game. */ - public WorldBorder getBorderProxy() - { + public WorldBorder getBorderProxy() { return border; } - public WorldBorderDependency getWorldBorderDependency() - { + public WorldBorderDependency getWorldBorderDependency() { return worldBorderDependency; } @@ -206,13 +202,12 @@ public WorldBorderDependency getWorldBorderDependency() * * @param location The location to check. * @param diameter The diameter of the checked border. - * * @return {@code true} if inside. */ - public boolean isInsideBorder(Location location, double diameter) - { + public boolean isInsideBorder(Location location, double diameter) { // The nether/end are not limited. - return !location.getWorld().getEnvironment().equals(World.Environment.NORMAL) || mapShape.getShape().isInsideBorder(location, diameter, location.getWorld().getSpawnLocation()); + return !location.getWorld().getEnvironment().equals(World.Environment.NORMAL) || + mapShape.getShape().isInsideBorder(location, diameter, location.getWorld().getSpawnLocation()); } /** @@ -222,8 +217,7 @@ public boolean isInsideBorder(Location location, double diameter) * @param location The location to check. * @return {@code true} if inside. */ - public boolean isInsideBorder(Location location) - { + public boolean isInsideBorder(Location location) { return this.isInsideBorder(location, getCurrentBorderDiameter()); } @@ -233,11 +227,9 @@ public boolean isInsideBorder(Location location) * * @param location The location to check. * @param diameter The diameter of the checked border. - * * @return The distance, or 0 if the player is either inside the border or not in the world. */ - public double getDistanceToBorder(Location location, double diameter) - { + public double getDistanceToBorder(Location location, double diameter) { return mapShape.getShape().getDistanceToBorder(location, diameter, location.getWorld().getSpawnLocation()); } @@ -249,8 +241,7 @@ public double getDistanceToBorder(Location location, double diameter) * @param diameter The diameter of the checked border. * @return A list of players out of the given diameter. */ - public Set<Player> getPlayersOutside(int diameter) - { + public Set<Player> getPlayersOutside(int diameter) { return QSG.module(GameModule.class) .getAliveConnectedPlayers().stream() .filter(player -> !isInsideBorder(player.getLocation(), diameter)) @@ -260,22 +251,20 @@ public Set<Player> getPlayersOutside(int diameter) /** * @return the current border diameter. */ - public int getCurrentBorderDiameter() - { + public int getCurrentBorderDiameter() { return (int) border.getDiameter(); } /** * Changes the current border diameter. * This also reconfigures the used world border. - * + * <p> * If WorldBorder is installed, all players out of this new border will be teleported inside the new one. * Else, nothing will happens. * * @param diameter the new diameter. */ - public void setCurrentBorderDiameter(int diameter) - { + public void setCurrentBorderDiameter(int diameter) { border.setDiameter(diameter); Bukkit.getPluginManager().callEvent(new BorderChangedEvent(diameter)); } @@ -283,34 +272,25 @@ public void setCurrentBorderDiameter(int diameter) /** * Sends a list of the players outside the given border to the specified sender. * - * @param to The player/console to send the check. + * @param to The player/console to send the check. * @param diameter The diameter of the border to be checked. */ - public void sendCheckMessage(final CommandSender to, final int diameter) - { + public void sendCheckMessage(final CommandSender to, final int diameter) { final BorderModule borderModule = QSG.module(BorderModule.class); final Set<Player> playersOutside = borderModule.getPlayersOutside(diameter); - if (playersOutside.size() == 0) - { + if (playersOutside.size() == 0) { to.sendMessage(I.t("{cs}All players are inside the given border.")); - } - else - { - to.sendMessage(I.t("{ci}There are {0} players outside the given border.", String.valueOf(playersOutside.size()))); - for (Player player : borderModule.getPlayersOutside(diameter)) - { + } else { + to.sendMessage( + I.t("{ci}There are {0} players outside the given border.", String.valueOf(playersOutside.size()))); + for (Player player : borderModule.getPlayersOutside(diameter)) { double distance = borderModule.getDistanceToBorder(player.getLocation(), diameter); - if (distance > 150) - { + if (distance > 150) { to.sendMessage(I.t("{lightpurple} - {red}{0}{ci} (far away from the border)", player.getName())); - } - else if (distance > 25) - { + } else if (distance > 25) { to.sendMessage(I.t("{lightpurple} - {yellow}{0}{ci} (close to the border)", player.getName())); - } - else - { + } else { to.sendMessage(I.t("{lightpurple} - {green}{0}{ci} (very close to the border)", player.getName())); } } @@ -320,21 +300,25 @@ else if (distance > 25) /** * Schedules the automatic border reduction, if enabled in the configuration. */ - private void scheduleBorderReduction() - { - if (Config.SHRINKING.ENABLED.get()) - { + private void scheduleBorderReduction() { + if (Config.SHRINKING.ENABLED.get()) { RunTask.later(() -> { - if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) { + return; + } - final int secondsPerBlock = (int) Math.rint(Config.SHRINKING.SHRINKS_DURING.get().getSeconds() / (border.getDiameter() - Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())) * 2; + final int secondsPerBlock = (int) Math.rint(Config.SHRINKING.SHRINKS_DURING.get().getSeconds() / + (border.getDiameter() - Config.SHRINKING.DIAMETER_AFTER_SHRINK.get())) * 2; border.setDiameter(Config.SHRINKING.DIAMETER_AFTER_SHRINK.get(), Config.SHRINKING.SHRINKS_DURING.get()); Titles.broadcastTitle(5, 30, 8, I.t("{red}Warning!"), I.t("{white}The border begins to shrink...")); - Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.t("{red}{bold}The border begins to shrink..."))); - Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get()))); + Bukkit.broadcastMessage( + QSGUtils.prefixedMessage(I.t("Border"), I.t("{red}{bold}The border begins to shrink..."))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), + I.t("{gray}It will shrink by one block every {0} second(s) until {1} blocks in diameter.", + secondsPerBlock, Config.SHRINKING.DIAMETER_AFTER_SHRINK.get()))); }, Config.SHRINKING.STARTS_AFTER.get().getSeconds() * 20L); scheduleBorderReductionWarning(new TimeDelta(1, 0, 0)); @@ -343,24 +327,28 @@ private void scheduleBorderReduction() } } - private void scheduleBorderReductionWarning(final TimeDelta warnBefore) - { - if (Config.SHRINKING.STARTS_AFTER.get().greaterThan(warnBefore.add(new TimeDelta(0, 5, 0)))) - { + private void scheduleBorderReductionWarning(final TimeDelta warnBefore) { + if (Config.SHRINKING.STARTS_AFTER.get().greaterThan(warnBefore.add(new TimeDelta(0, 5, 0)))) { RunTask.later(() -> { - if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) return; + if (QSG.module(GameModule.class).getPhase() != GamePhase.IN_GAME) { + return; + } Bukkit.broadcastMessage(""); - Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), I.tn("{red}The border will start to shrink in {0} minute...", "{red}The border will start to shrink in {0} minutes...", (int) (warnBefore.getSeconds() / 60)))); + Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Border"), + I.tn("{red}The border will start to shrink in {0} minute...", + "{red}The border will start to shrink in {0} minutes...", + (int) (warnBefore.getSeconds() / 60)))); Bukkit.broadcastMessage(""); }, Config.SHRINKING.STARTS_AFTER.get().subtract(warnBefore).getSeconds() * 20L); } } @EventHandler - public void onGameStarts(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; + public void onGameStarts(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME) { + return; + } scheduleBorderReduction(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java index ef3d1a0..af4d4d3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/Config.java @@ -29,49 +29,43 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders.WorldBorder; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Integer> SIZE = item("size", 2000); public static final ConfigurationItem<MapShape> SHAPE = item("shape", MapShape.SQUARED); - - public static final ConfigurationItem<WorldBorder.WorldBorderMotor> MOTOR = item("motor", WorldBorder.WorldBorderMotor.VANILLA); + public static final ConfigurationItem<WorldBorder.WorldBorderMotor> MOTOR = + item("motor", WorldBorder.WorldBorderMotor.VANILLA); public static final ConfigurationItem<Double> DAMAGES_BUFFER = item("damages-buffer", 5d); public static final ConfigurationItem<Double> DAMAGES_AMOUNT = item("damages-amount", 0.2); public static final ConfigurationItem<Integer> WARNING_DISTANCE = item("warning-distance", 5); - public static final ShrinkingSection SHRINKING = section("shrinking", ShrinkingSection.class); + static public final BorderSection SIDEBAR = section("sidebar", BorderSection.class); - static public class ShrinkingSection extends ConfigurationSection - { + public Config(File file) { + super(file); + } + + static public class ShrinkingSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); public final ConfigurationItem<TimeDelta> STARTS_AFTER = item("starts-after", new TimeDelta(1, 30, 0)); public final ConfigurationItem<TimeDelta> SHRINKS_DURING = item("shrinks-during", new TimeDelta(2, 0, 0)); public final ConfigurationItem<Integer> DIAMETER_AFTER_SHRINK = item("diameter-after-shrink", 200); } - static public final BorderSection SIDEBAR = section("sidebar", BorderSection.class); - - static public class BorderSection extends ConfigurationSection - { + static public class BorderSection extends ConfigurationSection { public final ConfigurationItem<Boolean> DISPLAYED = item("displayed", true); public final ConfigurationItem<Boolean> DISPLAY_DIAMETER = item("display-diameter", false); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java index ce19cea..7b58947 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/MapShape.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes.CircularMapShape; @@ -36,21 +37,19 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes.SquaredMapShape; -public enum MapShape -{ +public enum MapShape { CIRCULAR(new CircularMapShape()), SQUARED(new SquaredMapShape()), ; - private MapShapeDescriptor shape; + private final MapShapeDescriptor shape; /** * @param shape The shape descriptor to use for border-checks. */ - MapShape(MapShapeDescriptor shape) - { + MapShape(MapShapeDescriptor shape) { this.shape = shape; } @@ -59,8 +58,7 @@ public enum MapShape * * @return The shape. */ - public MapShapeDescriptor getShape() - { + public MapShapeDescriptor getShape() { return shape; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java index 02858fc..cb1bf56 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -44,133 +45,117 @@ import org.bukkit.Bukkit; -@CommandInfo (name = "border", usageParameters = "[new diameter] [duration]", aliases = "b") -public class BorderCommand extends Command -{ +@CommandInfo(name = "border", usageParameters = "[new diameter] [duration]", aliases = "b") +public class BorderCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final BorderModule border = QSG.module(BorderModule.class); // No arguments: displays current size - if (args.length == 0) - { - if (border.getMapShape() == MapShape.CIRCULAR) - { - sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", "{ci}The current diameter of the map is {0} blocks.", border.getCurrentBorderDiameter())); - } - else - { + if (args.length == 0) { + if (border.getMapShape() == MapShape.CIRCULAR) { + sender.sendMessage(I.tn("{ci}The current diameter of the map is {0} block.", + "{ci}The current diameter of the map is {0} blocks.", border.getCurrentBorderDiameter())); + } else { sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", border.getCurrentBorderDiameter())); } - } - - else - { + } else { // /uh border <radius> - if (args.length == 1) - { - try - { + if (args.length == 1) { + try { final int newDiameter = Integer.valueOf(args[0]); // Some players are outside - if (border.getPlayersOutside(newDiameter).size() != 0) - { - sender.sendMessage(I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); - sender.sendMessage(I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); - - if (!QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) - { - sender.sendMessage(I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); - } + if (border.getPlayersOutside(newDiameter).size() != 0) { + sender.sendMessage( + I.t("{ce}Some players are outside the future border, so this operation was cancelled.")); + sender.sendMessage( + I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", + args[0])); + + if (!QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { + sender.sendMessage( + I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); + } border.sendCheckMessage(sender, newDiameter); - } - else - { + } else { border.setCurrentBorderDiameter(newDiameter); - if (border.getMapShape() == MapShape.CIRCULAR) - { - Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); - } - else - { - Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); + if (border.getMapShape() == MapShape.CIRCULAR) { + Bukkit.getServer().broadcastMessage( + I.tn("{lightpurple}The diameter of the map is now {0} block.", + "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); + } else { + Bukkit.getServer().broadcastMessage( + I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); } } } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { error(I.t("{ce}“{0}” is not a number...", args[0])); } } // /uh border <radius> force - else if (args.length == 2 && args[1].equalsIgnoreCase("force")) - { - try - { + else if (args.length == 2 && args[1].equalsIgnoreCase("force")) { + try { final Integer newDiameter = Integer.valueOf(args[0]); border.setCurrentBorderDiameter(newDiameter); - if (border.getMapShape() == MapShape.CIRCULAR) - { - Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map is now {0} block.", "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); - } - else - { - Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); + if (border.getMapShape() == MapShape.CIRCULAR) { + Bukkit.getServer().broadcastMessage( + I.tn("{lightpurple}The diameter of the map is now {0} block.", + "{lightpurple}The diameter of the map is now {0} blocks.", newDiameter)); + } else { + Bukkit.getServer() + .broadcastMessage(I.t("{lightpurple}The size of the map is now {0}×{0}.", newDiameter)); } } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { error(I.t("{ce}“{0}” is not a number...", args[0])); } } // /uh border <radius> <duration> - else if (args.length == 2) - { - if (!border.getBorderProxy().supportsProgressiveResize()) - { - error(I.t("The border motor ({0}) does not supports progressive resizes.", border.getBorderProxy().getClass().getSimpleName())); + else if (args.length == 2) { + if (!border.getBorderProxy().supportsProgressiveResize()) { + error(I.t("The border motor ({0}) does not supports progressive resizes.", + border.getBorderProxy().getClass().getSimpleName())); } final Integer newDiameter; final TimeDelta delta; - try - { + try { newDiameter = Integer.valueOf(args[0]); } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { error(I.t("{ce}“{0}” is not a number...", args[0])); return; } - try - { + try { delta = new TimeDelta(args[1]); } - catch (IllegalArgumentException e) - { - error(I.t("{ce}“{0}” is not a valid time delta... Accepted formats are mm, mm:ss or hh:mm:ss.", args[1])); + catch (IllegalArgumentException e) { + error(I.t("{ce}“{0}” is not a valid time delta... Accepted formats are mm, mm:ss or hh:mm:ss.", + args[1])); return; } border.getBorderProxy().setDiameter(newDiameter, delta); - if (border.getMapShape() == MapShape.CIRCULAR) - { - Bukkit.getServer().broadcastMessage(I.tn("{lightpurple}The diameter of the map will be set to {0} block over {1}.", "{lightpurple}The diameter of the map will be set to {0} blocks over {1}.", newDiameter, newDiameter, delta)); - } - else - { - Bukkit.getServer().broadcastMessage(I.t("{lightpurple}The size of the map will be set to {0}×{0} over {1}.", newDiameter, delta)); + if (border.getMapShape() == MapShape.CIRCULAR) { + Bukkit.getServer().broadcastMessage( + I.tn("{lightpurple}The diameter of the map will be set to {0} block over {1}.", + "{lightpurple}The diameter of the map will be set to {0} blocks over {1}.", + newDiameter, newDiameter, delta)); + } else { + Bukkit.getServer().broadcastMessage( + I.t("{lightpurple}The size of the map will be set to {0}×{0} over {1}.", newDiameter, + delta)); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java index f295368..9cd6b57 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/events/BorderChangedEvent.java @@ -31,35 +31,31 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -public class BorderChangedEvent extends Event -{ +public class BorderChangedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final int newDiameter; - public BorderChangedEvent(final int newDiameter) - { + public BorderChangedEvent(final int newDiameter) { this.newDiameter = newDiameter; } - public int getNewDiameter() - { - return newDiameter; + public static HandlerList getHandlerList() { + return handlers; } - @Override - public HandlerList getHandlers() - { - return handlers; + public int getNewDiameter() { + return newDiameter; } - public static HandlerList getHandlerList() - { + @Override + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java index 954644d..37fac6a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/CircularMapShape.java @@ -29,26 +29,24 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; -public class CircularMapShape implements MapShapeDescriptor -{ +public class CircularMapShape implements MapShapeDescriptor { /** * Returns true if the given location is inside the map. * * @param location The location to check. * @param diameter The diameter of the map. * @param center The center of the map. - * * @return {@code true} if the given location is inside the map. */ @Override - public boolean isInsideBorder(final Location location, final Double diameter, final Location center) - { + public boolean isInsideBorder(final Location location, final Double diameter, final Location center) { final Location centerRef = center.clone(); centerRef.setY(location.getY()); @@ -61,21 +59,17 @@ public boolean isInsideBorder(final Location location, final Double diameter, fi * @param location The distance will be calculated between this location and the closest point of the border. * @param diameter The diameter of the border. * @param center The center of the border. - * * @return The distance between the given {@code location} and the closest point of the border.<br /> * {@code -1} if the location is inside the border. */ @Override - public double getDistanceToBorder(final Location location, final Double diameter, final Location center) - { + public double getDistanceToBorder(final Location location, final Double diameter, final Location center) { // The nether/end are not limited. - if (!location.getWorld().getEnvironment().equals(World.Environment.NORMAL)) - { + if (!location.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { return -1; } - if (isInsideBorder(location, diameter, center)) - { + if (isInsideBorder(location, diameter, center)) { return -1; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java index 5ad061c..144d2b2 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/MapShapeDescriptor.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; @@ -37,15 +38,13 @@ /** * Represents a shape of the map. */ -public interface MapShapeDescriptor -{ +public interface MapShapeDescriptor { /** * Returns true if the given location is inside the map. * * @param location The location to check. * @param diameter The diameter of the map. * @param center The center of the map. - * * @return {@code true} if the given location is inside the map. */ boolean isInsideBorder(final Location location, final Double diameter, final Location center); @@ -56,9 +55,8 @@ public interface MapShapeDescriptor * @param location The distance will be calculated between this location and the closest point of the border. * @param diameter The diameter of the border. * @param center The center of the border. - * * @return The distance between the given {@code location} and the closest point of the border.<br /> - * {@code -1} if the location is inside the border. + * {@code -1} if the location is inside the border. */ double getDistanceToBorder(final Location location, final Double diameter, final Location center); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java index 2a90a67..7763ea4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/shapes/SquaredMapShape.java @@ -29,26 +29,24 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.shapes; import org.bukkit.Location; import org.bukkit.World; -public class SquaredMapShape implements MapShapeDescriptor -{ +public class SquaredMapShape implements MapShapeDescriptor { /** * Returns true if the given location is inside the map. * * @param location The location to check. * @param diameter The diameter of the map. * @param center The center of the map. - * * @return {@code true} if the given location is inside the map. */ @Override - public boolean isInsideBorder(final Location location, final Double diameter, final Location center) - { + public boolean isInsideBorder(final Location location, final Double diameter, final Location center) { final Integer halfMapSize = (int) Math.floor(diameter / 2); final Integer x = location.getBlockX(); final Integer z = location.getBlockZ(); @@ -67,21 +65,17 @@ public boolean isInsideBorder(final Location location, final Double diameter, fi * @param location The distance will be calculated between this location and the closest point of the border. * @param diameter The diameter of the border. * @param center The center of the border. - * * @return The distance between the given {@code location} and the closest point of the border.<br /> * {@code -1} if the location is inside the border. */ @Override - public double getDistanceToBorder(final Location location, final Double diameter, final Location center) - { + public double getDistanceToBorder(final Location location, final Double diameter, final Location center) { // The nether/end are not limited. - if (!location.getWorld().getEnvironment().equals(World.Environment.NORMAL)) - { + if (!location.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { return -1; } - if (isInsideBorder(location, diameter, center)) - { + if (isInsideBorder(location, diameter, center)) { return -1; } @@ -97,37 +91,32 @@ public double getDistanceToBorder(final Location location, final Double diameter if (x > limitXSup && z < limitZSup && z > limitZInf) // East of the border { return Math.abs(x - limitXSup); - } - else if (x < limitXInf && z < limitZSup && z > limitZInf) // West of the border + } else if (x < limitXInf && z < limitZSup && z > limitZInf) // West of the border { return Math.abs(x - limitXInf); - } - else if (z > limitZSup && x < limitXSup && x > limitXInf) // South of the border + } else if (z > limitZSup && x < limitXSup && x > limitXInf) // South of the border { return Math.abs(z - limitZSup); - } - else if (z < limitZInf && x < limitXSup && x > limitXInf) // North of the border + } else if (z < limitZInf && x < limitXSup && x > limitXInf) // North of the border { return Math.abs(z - limitZInf); - } - else if (x > limitXSup && z < limitZInf) // North-East + } else if (x > limitXSup && z < limitZInf) // North-East { - return (int) location.distance(new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZInf)); - } - else if (x > limitXSup && z > limitZSup) // South-East + return (int) location + .distance(new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZInf)); + } else if (x > limitXSup && z > limitZSup) // South-East { - return (int) location.distance(new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZSup)); - } - else if (x < limitXInf && z > limitZSup) // South-West + return (int) location + .distance(new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZSup)); + } else if (x < limitXInf && z > limitZSup) // South-West { - return (int) location.distance(new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZSup)); - } - else if (x < limitXInf && z < limitZInf) // North-West - { - return (int) location.distance(new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZInf)); - } - else + return (int) location + .distance(new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZSup)); + } else if (x < limitXInf && z < limitZInf) // North-West { + return (int) location + .distance(new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZInf)); + } else { return -1; // Should never happen. } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java index d2a87c9..684b336 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; import com.wimbli.WorldBorder.BorderData; @@ -54,9 +55,8 @@ * <li>{@link #setWarningTime(int)}.</li> * </ul> */ -public class BrettflanWorldBorder extends WorldBorder -{ - private World world; +public class BrettflanWorldBorder extends WorldBorder { + private final World world; private BorderData border; private Double diameter = 0d; @@ -64,16 +64,14 @@ public class BrettflanWorldBorder extends WorldBorder private BukkitTask slowReductionTask = null; - public BrettflanWorldBorder(final World world) - { + public BrettflanWorldBorder(final World world) { this.world = world; - if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) - { - border = QSG.module(BorderModule.class).getWorldBorderDependency().getWorldBorder().getWorldBorder(world.getName()); + if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { + border = QSG.module(BorderModule.class).getWorldBorderDependency().getWorldBorder() + .getWorldBorder(world.getName()); - if (border == null) - { + if (border == null) { border = new BorderData(world.getSpawnLocation().getX(), world.getSpawnLocation().getZ(), 3000000); Config.setBorder(world.getName(), border); } @@ -81,23 +79,21 @@ public BrettflanWorldBorder(final World world) } @Override - public void init() - { + public void init() { Config.setPortalRedirection(true); } @Override - public World getWorld() - { + public World getWorld() { return world; } @Override - public double getDiameter() - { + public double getDiameter() { // If squared, the size is not changed - if (!border.getShape()) + if (!border.getShape()) { return diameter; + } Double realDiameter = (double) (border.getRadiusX() * 2); @@ -105,35 +101,32 @@ public double getDiameter() // Returns the stored diameter, except if it was changed // manually with /wb (see #setDiameterInternal(Double) for // details). - if (realDiameter - diameter >= 8) + if (realDiameter - diameter >= 8) { diameter = realDiameter; + } return diameter; } @Override - public void setDiameter(final double diameter) - { + public void setDiameter(final double diameter) { setDiameterInternal(diameter); - if (slowReductionTask != null) - { + if (slowReductionTask != null) { slowReductionTask.cancel(); slowReductionTask = null; } } @Override - public void setDiameter(final double diameter, final long time) - { + public void setDiameter(final double diameter, final long time) { // The behavior of the vanilla reduction is emulated. final double currentDiameter = getDiameter(); final long ticksPerBlockRemoved = (int) Math.rint(time / (currentDiameter - diameter)) * 20L; final long movement = (diameter >= currentDiameter) ? 1 : -1; - if (slowReductionTask != null) - { + if (slowReductionTask != null) { slowReductionTask.cancel(); slowReductionTask = null; } @@ -143,19 +136,15 @@ public void setDiameter(final double diameter, final long time) // If the final size is achieved, we set the exact requested size and we stop here. // Calling setDiameter cancels this task. - if ((movement < 0 && newDiameter <= diameter) || (movement > 0 && newDiameter >= diameter)) - { + if ((movement < 0 && newDiameter <= diameter) || (movement > 0 && newDiameter >= diameter)) { setDiameter(diameter); - } - else - { + } else { setDiameterInternal(newDiameter); } }, ticksPerBlockRemoved, ticksPerBlockRemoved); } - private void setDiameterInternal(final double diameter) - { + private void setDiameterInternal(final double diameter) { this.diameter = diameter; // If the wall is circular, the diameter used to check must be bigger to avoid false positives @@ -169,63 +158,69 @@ private void setDiameterInternal(final double diameter) } @Override - public Location getCenter() - { + public Location getCenter() { return new Location(world, border.getX(), 0, border.getZ()); } @Override - public void setCenter(final double x, final double z) - { - border.setX(x); - border.setZ(z); + public void setCenter(final Location center) { + setCenter(center.getX(), center.getZ()); } @Override - public void setCenter(final Location center) - { - setCenter(center.getX(), center.getZ()); + public void setCenter(final double x, final double z) { + border.setX(x); + border.setZ(z); } @Override - public double getDamageBuffer() { return 0; } + public double getDamageBuffer() { + return 0; + } @Override - public void setDamageBuffer(final double distance) {} + public void setDamageBuffer(final double distance) { + } @Override - public double getDamageAmount() { return 0; } + public double getDamageAmount() { + return 0; + } @Override - public void setDamageAmount(final double damageAmount) {} + public void setDamageAmount(final double damageAmount) { + } @Override - public int getWarningTime() { return 0; } + public int getWarningTime() { + return 0; + } @Override - public void setWarningTime(final int seconds) {} + public void setWarningTime(final int seconds) { + } @Override - public int getWarningDistance() { return 0; } + public int getWarningDistance() { + return 0; + } @Override - public void setWarningDistance(final int blocks) {} + public void setWarningDistance(final int blocks) { + } @Override - public MapShape getShape() - { + public MapShape getShape() { return border.getShape() ? MapShape.CIRCULAR : MapShape.SQUARED; } @Override - public void setShape(final MapShape shape) - { + public void setShape(final MapShape shape) { border.setShape(shape == MapShape.CIRCULAR); } @Override - public boolean supportsProgressiveResize() - { + public boolean supportsProgressiveResize() { return true; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java index fe87942..d7759a9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/FakeWorldBorder.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; @@ -41,100 +42,100 @@ * * <p>Used when a circular world border is requested without the WorldBorder plugin.</p> */ -public class FakeWorldBorder extends WorldBorder -{ +public class FakeWorldBorder extends WorldBorder { private final World world; private Location center; private Double diameter; private MapShape shape; - public FakeWorldBorder(final World world) - { + public FakeWorldBorder(final World world) { this.world = world; } @Override - public World getWorld() - { + public World getWorld() { return world; } @Override - public double getDiameter() - { + public double getDiameter() { return diameter; } @Override - public void setDiameter(final double diameter) - { + public void setDiameter(final double diameter) { this.diameter = diameter; } @Override - public void setDiameter(final double diameter, final long time) - { + public void setDiameter(final double diameter, final long time) { this.diameter = diameter; } @Override - public Location getCenter() - { + public Location getCenter() { return center; } @Override - public void setCenter(final double x, final double z) - { - this.center = new Location(world, x, 0, z); + public void setCenter(final Location center) { + setCenter(center.getX(), center.getZ()); } @Override - public void setCenter(final Location center) - { - setCenter(center.getX(), center.getZ()); + public void setCenter(final double x, final double z) { + this.center = new Location(world, x, 0, z); } @Override - public double getDamageBuffer() { return 0; } + public double getDamageBuffer() { + return 0; + } @Override - public void setDamageBuffer(final double distance) {} + public void setDamageBuffer(final double distance) { + } @Override - public double getDamageAmount() { return 0; } + public double getDamageAmount() { + return 0; + } @Override - public void setDamageAmount(final double damageAmount) {} + public void setDamageAmount(final double damageAmount) { + } @Override - public int getWarningTime() { return 0; } + public int getWarningTime() { + return 0; + } @Override - public void setWarningTime(final int seconds) {} + public void setWarningTime(final int seconds) { + } @Override - public int getWarningDistance() { return 0; } + public int getWarningDistance() { + return 0; + } @Override - public void setWarningDistance(final int blocks) {} + public void setWarningDistance(final int blocks) { + } @Override - public MapShape getShape() - { + public MapShape getShape() { return shape; } @Override - public void setShape(final MapShape shape) - { + public void setShape(final MapShape shape) { this.shape = shape; } @Override - public boolean supportsProgressiveResize() - { + public boolean supportsProgressiveResize() { return false; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java index 479841d..d9c0d63 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/VanillaWorldBorder.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.Config; @@ -43,127 +44,108 @@ * <p>This border is always squared, so {@link #setShape(MapShape)} does nothing and {@link * #getShape()} always returns {@link MapShape#SQUARED}.</p> */ -public class VanillaWorldBorder extends WorldBorder -{ +public class VanillaWorldBorder extends WorldBorder { private final World world; private final org.bukkit.WorldBorder border; - public VanillaWorldBorder(final World world) - { + public VanillaWorldBorder(final World world) { this.world = world; this.border = world.getWorldBorder(); } @Override - public void init() - { + public void init() { setDamageBuffer(Config.DAMAGES_BUFFER.get()); setDamageAmount(Config.DAMAGES_AMOUNT.get()); setWarningDistance(Config.WARNING_DISTANCE.get()); } @Override - public World getWorld() - { + public World getWorld() { return world; } @Override - public double getDiameter() - { + public double getDiameter() { return border.getSize(); } @Override - public void setDiameter(final double diameter) - { + public void setDiameter(final double diameter) { border.setSize(diameter); } @Override - public void setDiameter(final double diameter, final long time) - { + public void setDiameter(final double diameter, final long time) { border.setSize(diameter, time); } @Override - public Location getCenter() - { + public Location getCenter() { return border.getCenter(); } @Override - public void setCenter(final double x, final double z) - { - border.setCenter(x, z); + public void setCenter(final Location center) { + border.setCenter(center); } @Override - public void setCenter(final Location center) - { - border.setCenter(center); + public void setCenter(final double x, final double z) { + border.setCenter(x, z); } @Override - public double getDamageBuffer() - { + public double getDamageBuffer() { return border.getDamageBuffer(); } @Override - public void setDamageBuffer(final double distance) - { + public void setDamageBuffer(final double distance) { border.setDamageBuffer(distance); } @Override - public double getDamageAmount() - { + public double getDamageAmount() { return border.getDamageAmount(); } @Override - public void setDamageAmount(final double damageAmount) - { + public void setDamageAmount(final double damageAmount) { border.setDamageAmount(damageAmount); } @Override - public int getWarningTime() - { + public int getWarningTime() { return border.getWarningTime(); } @Override - public void setWarningTime(final int seconds) - { + public void setWarningTime(final int seconds) { border.setWarningTime(seconds); } @Override - public int getWarningDistance() - { + public int getWarningDistance() { return border.getWarningDistance(); } @Override - public void setWarningDistance(final int blocks) - { + public void setWarningDistance(final int blocks) { border.setWarningDistance(blocks); } @Override - public MapShape getShape() - { + public MapShape getShape() { return MapShape.SQUARED; } @Override - public void setShape(final MapShape shape) {} + public void setShape(final MapShape shape) { + } @Override - public boolean supportsProgressiveResize() - { + public boolean supportsProgressiveResize() { return true; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java index bf0b858..2c702c0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -43,14 +44,40 @@ * An abstraction layer to manipulate world borders, typically the vanilla world border or * the Brettflan one. */ -public abstract class WorldBorder -{ +public abstract class WorldBorder { /** - * Initializes the world border configuration, if needed. + * Returns a new instance of a WorldBorder proxy using the requested types. * + * @param motor The border motor; can be "vanilla" or "brettflan" (from config). + * @param shape The border shape. + * @return An instance of a WorldBorder proxy. + */ + public static WorldBorder getInstance(final World world, final WorldBorderMotor motor, final MapShape shape) { + // For circular shapes, the vanilla motor cannot be used. + // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). + if (shape == MapShape.CIRCULAR) { + if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { + return new BrettflanWorldBorder(world); + } else { + return new FakeWorldBorder(world); + } + } else { + if (motor == WorldBorderMotor.VANILLA || + !QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { + return new VanillaWorldBorder(world); + } else { + return new BrettflanWorldBorder(world); + } + } + } + + /** + * Initializes the world border configuration, if needed. + * <p> * This method does not initializes the shape, size, etc. */ - public void init() {} + public void init() { + } /** * @return The world bordered by this world border. @@ -77,8 +104,7 @@ public void init() {} * @param diameter The new diameter of the border. * @param time The seconds used to change the size from the old size to the new one. */ - public void setDiameter(final double diameter, final TimeDelta time) - { + public void setDiameter(final double diameter, final TimeDelta time) { setDiameter(diameter, time.getSeconds()); } @@ -87,6 +113,11 @@ public void setDiameter(final double diameter, final TimeDelta time) */ public abstract Location getCenter(); + /** + * @param center The new center of the border. + */ + public abstract void setCenter(final Location center); + /** * Sets the center of the border. * @@ -95,11 +126,6 @@ public void setDiameter(final double diameter, final TimeDelta time) */ public abstract void setCenter(final double x, final double z); - /** - * @param center The new center of the border. - */ - public abstract void setCenter(final Location center); - /** * @return the amount of blocks a player may safely be outside the border before taking damage. */ @@ -161,45 +187,7 @@ public void setDiameter(final double diameter, final TimeDelta time) */ public abstract boolean supportsProgressiveResize(); - - /** - * Returns a new instance of a WorldBorder proxy using the requested types. - * - * @param motor The border motor; can be "vanilla" or "brettflan" (from config). - * @param shape The border shape. - * - * @return An instance of a WorldBorder proxy. - */ - public static WorldBorder getInstance(final World world, final WorldBorderMotor motor, final MapShape shape) - { - // For circular shapes, the vanilla motor cannot be used. - // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). - if (shape == MapShape.CIRCULAR) - { - if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) - { - return new BrettflanWorldBorder(world); - } - else - { - return new FakeWorldBorder(world); - } - } - else - { - if (motor == WorldBorderMotor.VANILLA || !QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) - { - return new VanillaWorldBorder(world); - } - else - { - return new BrettflanWorldBorder(world); - } - } - } - - public enum WorldBorderMotor - { + public enum WorldBorderMotor { /** * Uses the vanilla world border (for squared borders only). */ @@ -207,7 +195,7 @@ public enum WorldBorderMotor /** * Uses the Brettflan's WorldBorder plugin (for both squared and circular). - * + * <p> * If set for squared world borders and WorldBorder is not installed, fallbacks to vanilla. */ BRETTFLAN diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java index 2ecb488..50b8e76 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/Config.java @@ -29,55 +29,47 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Integer> COUNTDOWN = item("countdown", 7); public static final ConfigurationItem<Boolean> STARTUP_TITLE = item("startup-title", true); - - public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = item("random-color-in-solo-games", true); - + public static final ConfigurationItem<Boolean> RANDOM_COLORS_IN_SOLO_GAMES = + item("random-color-in-solo-games", true); public static final ConfigurationItem<Boolean> BROADCAST_PROGRESS = item("broadcast-progress", true); - public static final SlowSection SLOW = section("slow", SlowSection.class); + public static final BeginningSection BEGINNING = section("beginning", BeginningSection.class); + public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); - public static final class SlowSection extends ConfigurationSection - { - public final ConfigurationItem<Long> DELAY_BETWEEN_TP = item("delay-between-teleportations", 3L); + public Config(File file) { + super(file); } - public static final BeginningSection BEGINNING = section("beginning", BeginningSection.class); + public static final class SlowSection extends ConfigurationSection { + public final ConfigurationItem<Long> DELAY_BETWEEN_TP = item("delay-between-teleportations", 3L); + } - public static final class BeginningSection extends ConfigurationSection - { + public static final class BeginningSection extends ConfigurationSection { public final ConfigurationItem<TimeDelta> GRACE_PERIOD = item("grace-period", new TimeDelta(0, 0, 30)); public final ConfigurationItem<Boolean> BROADCAST_GRACE_END = item("broadcast-grace-end", true); public final ConfigurationItem<TimeDelta> PEACE_PERIOD = item("peace-period", new TimeDelta(0, 1, 0)); - public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = item("surface-mobs-free-period", new TimeDelta(0, 20, 0)); + public final ConfigurationItem<TimeDelta> SURFACE_MOBS_FREE_PERIOD = + item("surface-mobs-free-period", new TimeDelta(0, 20, 0)); } - public static final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); - - public static final class SidebarSection extends ConfigurationSection - { + public static final class SidebarSection extends ConfigurationSection { public final ConfigurationItem<Boolean> PLAYERS = item("players", true); public final ConfigurationItem<Boolean> TEAMS = item("teams", true); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java index 942ecb7..37b24c4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,7 +42,11 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.TeamDeathEvent; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.*; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.AfterTeleportationPhaseEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.BeforeTeleportationPhaseEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerAboutToBeTeleportedToSpawnPointEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.submanagers.GameBeginning; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.Teleporter; @@ -53,14 +58,32 @@ import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.rawtext.RawText; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.ActionBar; import fr.zcraft.quartzlib.tools.text.Titles; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.colors.TeamColor; -import org.bukkit.*; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.colors.TeamColor; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Queue; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -69,12 +92,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.scheduler.BukkitRunnable; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -@ModuleInfo ( +@ModuleInfo( name = "Game", description = "Manages the game execution and phases.", category = ModuleCategory.CORE, @@ -83,29 +102,25 @@ internal = true, can_be_unloaded = false ) -public class GameModule extends QSGModule implements Listener -{ - /** - * The current game phase (initialized to {@link GamePhase#WAIT} in the - * {@link #onEnable()} method). - */ - private GamePhase phase = null; - +public class GameModule extends QSGModule implements Listener { /** * A list containing the currently alive players. */ private final Set<UUID> alivePlayers = new HashSet<>(); - /** * A list containing the currently (cached) alive teams. * Refreshed using the {@link #updateAliveTeams()} method. */ - private final Set<ZTeam> aliveTeams = new HashSet<>(); - + private final Set<QuartzTeam> aliveTeams = new HashSet<>(); + /** + * The current game phase (initialized to {@link GamePhase#WAIT} in the + * {@link #onEnable()} method). + */ + private GamePhase phase = null; /** * When the game ends, stores the last standing team. */ - private ZTeam winner = null; + private QuartzTeam winner = null; /** * {@code true} if there is teams in this game. @@ -146,17 +161,15 @@ public class GameModule extends QSGModule implements Listener @Override - protected void onEnable() - { + protected void onEnable() { setPhase(GamePhase.WAIT); Bukkit.getOnlinePlayers().forEach(this::updatePlayerFlightOptions); - ZLib.loadComponent(GameBeginning.class); + QuartzLib.loadComponent(GameBeginning.class); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList( StartCommand.class, KillCommand.class, @@ -165,27 +178,23 @@ public List<Class<? extends Command>> getCommands() } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { + public void injectIntoSidebar(Player player, SidebarInjector injector) { final List<String> topSidebar = new ArrayList<>(); - if (Config.SIDEBAR.PLAYERS.get()) - { + if (Config.SIDEBAR.PLAYERS.get()) { topSidebar.add(I.tn( "{white}{0}{gray} player", "{white}{0}{gray} players", phase == GamePhase.WAIT ? Bukkit.getOnlinePlayers().size() : alivePlayers.size() )); } - if (Config.SIDEBAR.TEAMS.get() && teamsGame && phase != GamePhase.WAIT) - { + if (Config.SIDEBAR.TEAMS.get() && teamsGame && phase != GamePhase.WAIT) { topSidebar.add(I.tn("{white}{0}{gray} team", "{white}{0}{gray} teams", aliveTeams.size())); } injector.injectLines(SidebarInjector.SidebarPriority.TOP, true, topSidebar); - switch (phase) - { + switch (phase) { case WAIT: injector.injectLines( SidebarInjector.SidebarPriority.TOP, true, @@ -203,112 +212,95 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) } } - public boolean isTeamsGame() - { + public boolean isTeamsGame() { return teamsGame; } - public Set<UUID> getAlivePlayersUUIDs() - { + public Set<UUID> getAlivePlayersUUIDs() { return Collections.unmodifiableSet(alivePlayers); } - public Set<OfflinePlayer> getAlivePlayers() - { + public Set<OfflinePlayer> getAlivePlayers() { return alivePlayers.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toSet()); } - public int countAlivePlayers() - { + public int countAlivePlayers() { return alivePlayers.size(); } - public Set<Player> getAliveConnectedPlayers() - { - return alivePlayers.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).filter(Player::isOnline).collect(Collectors.toSet()); + public Set<Player> getAliveConnectedPlayers() { + return alivePlayers.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).filter(Player::isOnline) + .collect(Collectors.toSet()); } - public Set<ZTeam> getAliveTeams() - { + public Set<QuartzTeam> getAliveTeams() { return Collections.unmodifiableSet(aliveTeams); } - public int countAliveTeams() - { + public int countAliveTeams() { return aliveTeams.size(); } /** * @return The game's winner, if any; null else. */ - public ZTeam getWinner() - { + public QuartzTeam getWinner() { return winner; } - public boolean isAlive(final OfflinePlayer player) - { + public boolean isAlive(final OfflinePlayer player) { return alivePlayers.contains(player.getUniqueId()); } - public boolean isAlive(final UUID playerID) - { + public boolean isAlive(final UUID playerID) { return alivePlayers.contains(playerID); } - public boolean isAlive(final ZTeam team) - { + public boolean isAlive(final QuartzTeam team) { return team.getPlayersUUID().stream().anyMatch(alivePlayers::contains); } /** * Kills a player. - * + * <p> * This method calls an event. If the event is cancelled, the player is not * killed. * * @param player The player to kill. * @return {@code true} if the player was effectively killed (event not cancelled). */ - public boolean kill(final OfflinePlayer player) - { + public boolean kill(final OfflinePlayer player) { return kill(player, null); } /** * Kills a player. Internal use for natural deaths. - * + * <p> * This method calls an event. If the event is cancelled, the player is not * killed. * * @param player The player to kill. - * @param ev The underlying death event. - * + * @param ev The underlying death event. * @return {@code true} if the player was effectively killed (event not cancelled). */ - private boolean kill(final OfflinePlayer player, final PlayerDeathEvent ev) - { + private boolean kill(final OfflinePlayer player, final PlayerDeathEvent ev) { final AlivePlayerDeathEvent event = new AlivePlayerDeathEvent(player, ev); Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) - { + if (!event.isCancelled()) { alivePlayers.remove(player.getUniqueId()); updateAliveTeams(); // We check the player's team to see if there is players left inside. - if (teamsGame) - { - final ZTeam team = ZTeams.get().getTeamForPlayer(player); - if (team != null && !aliveTeams.contains(team)) - { + if (teamsGame) { + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); + if (team != null && !aliveTeams.contains(team)) { Bukkit.getPluginManager().callEvent(new TeamDeathEvent(team)); } } - if (aliveTeams.size() <= 1) - { + if (aliveTeams.size() <= 1) { setPhase(GamePhase.END); } @@ -325,19 +317,20 @@ private boolean kill(final OfflinePlayer player, final PlayerDeathEvent ev) * @param player The player to resurrect. * @return {@code true} if the player was effectively resurrected (i.e. not already alive). */ - public boolean resurrect(final OfflinePlayer player) - { - if (isAlive(player)) return false; + public boolean resurrect(final OfflinePlayer player) { + if (isAlive(player)) { + return false; + } log().info("Resurrecting player {0}", player.getName()); alivePlayers.add(player.getUniqueId()); updateAliveTeams(); - log().info("Resurrected. Alive players: {0}. Teams: {1}. Phase: {2}.", alivePlayers.size(), aliveTeams.size(), phase); + log().info("Resurrected. Alive players: {0}. Teams: {1}. Phase: {2}.", alivePlayers.size(), aliveTeams.size(), + phase); - if (aliveTeams.size() > 1 && phase == GamePhase.END) - { + if (aliveTeams.size() > 1 && phase == GamePhase.END) { setPhase(GamePhase.IN_GAME); log().info("Going back to IN_GAME phase. Phase is now {0}.", phase); } @@ -350,143 +343,131 @@ public boolean resurrect(final OfflinePlayer player) /** * @return the current phase of the game. */ - public GamePhase getPhase() - { + public GamePhase getPhase() { return phase; } - /** - * Compares the current phase with the given one. - * - * @param phase The compared phase. - * @return {@code true} if the current phase is strictly before this one. - */ - public boolean currentPhaseBefore(final GamePhase phase) - { - return this.phase.ordinal() < phase.ordinal(); - } - - /** - * Compares the current phase with the given one. - * - * @param phase The compared phase. - * @return {@code true} if the current phase is strictly after this one. - */ - public boolean currentPhaseAfter(final GamePhase phase) - { - return this.phase.ordinal() > phase.ordinal(); - } - /** * Changes the phase of the game. - * + * <p> * The phase must be a phase after the current one, with two exceptions: * the phase order can be STARTING → WAIT or END → IN_GAME. * * @param phase The new phase. */ - public void setPhase(final GamePhase phase) - { + public void setPhase(final GamePhase phase) { if (this.phase == null || (this.phase != phase && phase.ordinal() > this.phase.ordinal()) || (this.phase == GamePhase.STARTING && phase == GamePhase.WAIT) || (this.phase == GamePhase.END && phase == GamePhase.IN_GAME) - ) - { + ) { final GamePhase oldPhase = this.phase; this.phase = phase; log().info("Game phase changed to {0}.", phase); - RunTask.nextTick(() -> Bukkit.getServer().getPluginManager().callEvent(new GamePhaseChangedEvent(oldPhase, phase))); + RunTask.nextTick( + () -> Bukkit.getServer().getPluginManager().callEvent(new GamePhaseChangedEvent(oldPhase, phase))); } } - public void setSlowMode(boolean slowMode) - { - this.slowMode = slowMode; + /** + * Compares the current phase with the given one. + * + * @param phase The compared phase. + * @return {@code true} if the current phase is strictly before this one. + */ + public boolean currentPhaseBefore(final GamePhase phase) { + return this.phase.ordinal() < phase.ordinal(); + } + + /** + * Compares the current phase with the given one. + * + * @param phase The compared phase. + * @return {@code true} if the current phase is strictly after this one. + */ + public boolean currentPhaseAfter(final GamePhase phase) { + return this.phase.ordinal() > phase.ordinal(); } - public boolean isSlowMode() - { + public boolean isSlowMode() { return slowMode; } - public void setTeleportationMode(TeleportationMode teleportationMode) - { - this.teleportationMode = teleportationMode; + public void setSlowMode(boolean slowMode) { + this.slowMode = slowMode; } - public TeleportationMode getTeleportationMode() - { + public TeleportationMode getTeleportationMode() { return teleportationMode; } - public Teleporter getTeleporter() - { + public void setTeleportationMode(TeleportationMode teleportationMode) { + this.teleportationMode = teleportationMode; + } + + public Teleporter getTeleporter() { return teleporter; } /** * Sets the phase to {@link GamePhase#IN_GAME} after a countdown. */ - public void start() - { - if (startingCountdownLock) return; - if (phase != GamePhase.STARTING) throw new IllegalStateException("Cannot start the game if not in “starting” phase."); - if (teleportationProcessLock) throw new IllegalStateException("Cannot start the game: the teleportation phase is still running."); + public void start() { + if (startingCountdownLock) { + return; + } + if (phase != GamePhase.STARTING) { + throw new IllegalStateException("Cannot start the game if not in “starting” phase."); + } + if (teleportationProcessLock) { + throw new IllegalStateException("Cannot start the game: the teleportation phase is still running."); + } startingCountdownLock = true; final AtomicInteger countdown = new AtomicInteger(Config.COUNTDOWN.get() + 1); - final float[] countdownNotes = new float[] { .75f, .86f, .66f, 1, .5f, .5f, .5f }; + final float[] countdownNotes = new float[] {.75f, .86f, .66f, 1, .5f, .5f, .5f}; final AtomicInteger countdownIndex = new AtomicInteger(-1); - RunTask.timer(new BukkitRunnable() - { + RunTask.timer(new BukkitRunnable() { @Override - public void run() - { + public void run() { countdown.getAndDecrement(); - if (countdown.get() != 0 || !Config.STARTUP_TITLE.get()) - { + if (countdown.get() != 0 || !Config.STARTUP_TITLE.get()) { Titles.broadcastTitle( countdown.get() == 10 ? 8 : 0, countdown.get() == 0 ? 40 : 20, countdown.get() == 0 ? 20 : 0, - (countdown.get() > 5 ? ChatColor.GREEN : (countdown.get() > 3 ? ChatColor.YELLOW : ChatColor.RED)) + countdown.toString(), + (countdown.get() > 5 ? ChatColor.GREEN : + (countdown.get() > 3 ? ChatColor.YELLOW : ChatColor.RED)) + countdown.toString(), "" ); - } - else - { + } else { Titles.broadcastTitle( - 0, 84, 8, - /// Title of title displayed when the game starts. - I.t("{darkgreen}Let's go!"), - /// Subtitle of title displayed when the game starts. - I.t("{green}Good luck, and have fun") + 0, 84, 8, + /// Title of title displayed when the game starts. + I.t("{darkgreen}Let's go!"), + /// Subtitle of title displayed when the game starts. + I.t("{green}Good luck, and have fun") ); } - if (countdown.get() != 0) - { - if (countdownIndex.incrementAndGet() == countdownNotes.length) - { + if (countdown.get() != 0) { + if (countdownIndex.incrementAndGet() == countdownNotes.length) { countdownIndex.set(0); } - new QSGSound(1f, countdownNotes[countdownIndex.get()], "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT").broadcast(); - } - else - { + new QSGSound(1f, countdownNotes[countdownIndex.get()], "ARROW_HIT_PLAYER", "SUCCESSFUL_HIT") + .broadcast(); + } else { new QSGSound("WITHER_DEATH").broadcast(); } - if (countdown.get() == 0) - { + if (countdown.get() == 0) { setPhase(GamePhase.IN_GAME); cancel(); } @@ -500,9 +481,10 @@ public void run() @EventHandler(priority = EventPriority.LOW) - public void onGameStarting(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.STARTING) return; + public void onGameStarting(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.STARTING) { + return; + } teleportationProcessLock = true; @@ -511,7 +493,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) Bukkit.getPluginManager().callEvent(new BeforeTeleportationPhaseEvent()); // We determine if the game is or not with teams by counting the teams. - teamsGame = ZTeams.get().countTeams() > 0; + teamsGame = QuartzTeams.get().countTeams() > 0; alivePlayers.clear(); aliveTeams.clear(); @@ -520,22 +502,21 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // In case of a teams game, we create a “wrapping” team for each alone player. Else, a team for each player. // These teams created on the fly are saved in case of startup fail. - final Set<ZTeam> onTheFlyTeams = new HashSet<>(); + final Set<QuartzTeam> onTheFlyTeams = new HashSet<>(); final Random random = new Random(); Bukkit.getOnlinePlayers().stream() - .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) + .filter(player -> QuartzTeams.get().getTeamForPlayer(player) == null) .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) .forEach(player -> { // We need an unique name for the team. String teamName = player.getName(); - while (ZTeams.get().isTeamRegistered(teamName)) - { + while (QuartzTeams.get().isTeamRegistered(teamName)) { teamName = player.getName() + " " + random.nextInt(1000000); } - final ZTeam team = ZTeams.get().createTeam( + final QuartzTeam team = QuartzTeams.get().createTeam( teamName, Config.RANDOM_COLORS_IN_SOLO_GAMES.get() ? TeamColor.RANDOM : TeamColor.WHITE, player @@ -547,7 +528,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // Loading alive players from teams, now that they are constructed and complete. - ZTeams.get().getTeams().stream() + QuartzTeams.get().getTeams().stream() .flatMap(team -> team.getPlayers().stream()) .map(OfflinePlayer::getUniqueId) .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) @@ -558,12 +539,13 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // We have to check if there is enough spawn points. - int spawnsNeeded = teleportationMode == TeleportationMode.IGNORE_TEAMS ? alivePlayers.size() : aliveTeams.size(); + int spawnsNeeded = + teleportationMode == TeleportationMode.IGNORE_TEAMS ? alivePlayers.size() : aliveTeams.size(); - if (QSG.module(SpawnsModule.class).getSpawnPoints().size() < spawnsNeeded) - { + if (QSG.module(SpawnsModule.class).getSpawnPoints().size() < spawnsNeeded) { log().broadcastAdministrative(I.t("{ce}Unable to start the game: not enough teleportation spots.")); - log().broadcastAdministrative(I.t("{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to generate the missing spawns automatically.")); + log().broadcastAdministrative( + I.t("{ci}You can use {cc}/uh spawns generate <random|circular|grid>{ci} to generate the missing spawns automatically.")); /// In the sentence: "Or click here to generate the spawns randomly." log().broadcastAdministrative(new RawText(I.t("Or")) @@ -580,7 +562,7 @@ public void onGameStarting(final GamePhaseChangedEvent ev) ); // We clears the teams created on-the-fly - onTheFlyTeams.forEach(ZTeam::deleteTeam); + onTheFlyTeams.forEach(QuartzTeam::deleteTeam); // We set the phase back to WAIT. setPhase(GamePhase.WAIT); @@ -598,15 +580,13 @@ public void onGameStarting(final GamePhaseChangedEvent ev) teleporter = new Teleporter(); - ZTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> + QuartzTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> { - if (teleportationMode == TeleportationMode.NORMAL && teamsGame) - { + if (teleportationMode == TeleportationMode.NORMAL && teamsGame) { final Location teamSpawn = unusedSpawnPoints.poll(); // Should never happen - if (teamSpawn == null) - { + if (teamSpawn == null) { log().error( "A fatal error occurred while starting the game: cannot set spawn point for team {0}: not enough spawn points", team.getName() @@ -624,17 +604,14 @@ public void onGameStarting(final GamePhaseChangedEvent ev) teleporter.setSpawnForPlayer(player, event.getSpawnPoint()); }); - } - else - { + } else { team.getPlayersUUID().forEach(player -> { final Location playerSpawn = unusedSpawnPoints.poll(); final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player); // Should never happen - if (playerSpawn == null) - { + if (playerSpawn == null) { log().error( "A fatal error occurred while starting the game: cannot set spawn point for player {0}: not enough spawn points", offlinePlayer.getName() @@ -657,79 +634,77 @@ public void onGameStarting(final GamePhaseChangedEvent ev) // Effective teleportation. teleporter - .whenTeleportationOccurs(uuid -> Bukkit.getPluginManager().callEvent( - new PlayerAboutToBeTeleportedToSpawnPointEvent(Bukkit.getPlayer(uuid), teleporter.getSpawnForPlayer(uuid)))) + .whenTeleportationOccurs(uuid -> Bukkit.getPluginManager().callEvent( + new PlayerAboutToBeTeleportedToSpawnPointEvent(Bukkit.getPlayer(uuid), + teleporter.getSpawnForPlayer(uuid)))) - .whenTeleportationSuccesses(uuid -> { - final Player player = Bukkit.getPlayer(uuid); + .whenTeleportationSuccesses(uuid -> { + final Player player = Bukkit.getPlayer(uuid); - log().info("Player {0} - {1} teleported to its spawn point.", uuid, player.getName()); + log().info("Player {0} - {1} teleported to its spawn point.", uuid, player.getName()); - Bukkit.getPluginManager().callEvent( - new PlayerTeleportedToSpawnPointEvent(player, teleporter.getSpawnForPlayer(uuid))); - }) + Bukkit.getPluginManager().callEvent( + new PlayerTeleportedToSpawnPointEvent(player, teleporter.getSpawnForPlayer(uuid))); + }) - .whenTeleportationFails(uuid -> log().error("Unable to teleport player {0} - {1}", uuid, Bukkit.getOfflinePlayer(uuid).getName())) + .whenTeleportationFails(uuid -> log() + .error("Unable to teleport player {0} - {1}", uuid, Bukkit.getOfflinePlayer(uuid).getName())) - .whenTeleportationEnds(uuids -> { - teleportationProcessLock = false; - Bukkit.getPluginManager().callEvent(new AfterTeleportationPhaseEvent()); - }) + .whenTeleportationEnds(uuids -> { + teleportationProcessLock = false; + Bukkit.getPluginManager().callEvent(new AfterTeleportationPhaseEvent()); + }) - .startTeleportationProcess(slowMode); + .startTeleportationProcess(slowMode); } - @EventHandler (priority = EventPriority.LOWEST) - public void onPlayerTeleportedToSpawnPoint(final PlayerTeleportedToSpawnPointEvent ev) - { + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerTeleportedToSpawnPoint(final PlayerTeleportedToSpawnPointEvent ev) { Player player = Bukkit.getPlayer(ev.getPlayer().getUniqueId()); - if (player != null) - { + if (player != null) { player.setGameMode(GameMode.ADVENTURE); player.setAllowFlight(true); player.setFlying(true); player.setFlySpeed(0f); } - if (Config.BROADCAST_PROGRESS.get()) - { + if (Config.BROADCAST_PROGRESS.get()) { teleportationProgress++; /// Displayed in the action bar while the slow teleportation occurs. - final String message = I.t("{lightpurple}Teleporting... {gray}({0}/{1})", teleportationProgress, alivePlayers.size()); + final String message = + I.t("{lightpurple}Teleporting... {gray}({0}/{1})", teleportationProgress, alivePlayers.size()); Bukkit.getOnlinePlayers().forEach(onlinePlayer -> ActionBar.sendPermanentMessage(onlinePlayer, message)); } } - @EventHandler (priority = EventPriority.LOWEST) - public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev) - { + @EventHandler(priority = EventPriority.LOWEST) + public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev) { log().broadcastAdministrative(I.t("{cs}All teams are teleported.")); - if (slowMode) - { - log().broadcastAdministrative(new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) - .hover(new RawText(I.t("Click here to start the game"))) - .command(StartCommand.class) + if (slowMode) { + log().broadcastAdministrative( + new RawText(I.t("{gray}Use {cc}/uh start{gray} or click here to start the game.")) + .hover(new RawText(I.t("Click here to start the game"))) + .command(StartCommand.class) ); - } - else - { + } else { start(); } - if (Config.BROADCAST_PROGRESS.get()) - { + if (Config.BROADCAST_PROGRESS.get()) { /// Displayed in the action bar when the slow teleportation is finished but the game not started. - Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, I.tl(player, "{lightpurple}Teleportation complete. {gray}The game will start soon..."))); + Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, + I.tl(player, "{lightpurple}Teleportation complete. {gray}The game will start soon..."))); } } - @EventHandler (priority = EventPriority.LOWEST) - public void onGameStarts(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + @EventHandler(priority = EventPriority.LOWEST) + public void onGameStarts(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) { + return; + } Bukkit.getOnlinePlayers().forEach(ActionBar::removeMessage); @@ -765,23 +740,24 @@ public void onGameStarts(final GamePhaseChangedEvent ev) @EventHandler - public void onPlayerDeath(final PlayerDeathEvent ev) - { - if (phase != GamePhase.IN_GAME) return; - if (!isAlive(ev.getEntity())) return; + public void onPlayerDeath(final PlayerDeathEvent ev) { + if (phase != GamePhase.IN_GAME) { + return; + } + if (!isAlive(ev.getEntity())) { + return; + } kill(ev.getEntity(), ev); } @EventHandler - public void onPlayerKilled(final AlivePlayerDeathEvent ev) - { + public void onPlayerKilled(final AlivePlayerDeathEvent ev) { log().info("{0} killed", ev.getPlayer().getName()); } @EventHandler - public void onPlayerResurrected(final PlayerResurrectedEvent ev) - { + public void onPlayerResurrected(final PlayerResurrectedEvent ev) { log().info("{0} resurrected", ev.getPlayer().getName()); /// Resurrection notification. {0} = raw resurrected player name. @@ -789,14 +765,10 @@ public void onPlayerResurrected(final PlayerResurrectedEvent ev) } @EventHandler - public void onGameEndsOrEndsCancelled(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.END) - { + public void onGameEndsOrEndsCancelled(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.END) { winner = aliveTeams.stream().findAny().orElse(null); // There will be one alive team left here. - } - else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) - { + } else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) { winner = null; // Win cancelled because a team was resurrected. } } @@ -806,32 +778,27 @@ else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) /* *** OTHER PLAYERS MANAGEMENT *** */ @EventHandler - public void onPlayerJoin(final PlayerJoinEvent ev) - { + public void onPlayerJoin(final PlayerJoinEvent ev) { updatePlayerFlightOptions(ev.getPlayer()); } /** * Sets the flight options for the player according to the current game phase. + * * @param player The player. */ - private void updatePlayerFlightOptions(final Player player) - { - switch (phase) - { + private void updatePlayerFlightOptions(final Player player) { + switch (phase) { case WAIT: player.setFlySpeed(.1f); break; case STARTING: - if (alivePlayers.contains(player.getUniqueId())) - { + if (alivePlayers.contains(player.getUniqueId())) { player.setAllowFlight(true); player.setFlySpeed(0f); - } - else - { + } else { player.setFlySpeed(.1f); } @@ -843,11 +810,11 @@ private void updatePlayerFlightOptions(final Player player) } } - private void updateAliveTeams() - { + private void updateAliveTeams() { aliveTeams.clear(); - ZTeams.get().getTeams() - .forEach(t -> t.getPlayersUUID().stream().filter(alivePlayers::contains).map(pid -> t).forEach(aliveTeams::add)); + QuartzTeams.get().getTeams() + .forEach(t -> t.getPlayersUUID().stream().filter(alivePlayers::contains).map(pid -> t) + .forEach(aliveTeams::add)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java index c56a7b7..dbedf3e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GamePhase.java @@ -29,14 +29,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game; /** * Represents the current phase of the game. */ -public enum GamePhase -{ +public enum GamePhase { /** * Before the game, when the players are waiting for the game to start. */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java index 03c6e13..231d842 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/KillCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -39,21 +40,17 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; -@CommandInfo (name = "kill", usageParameters = "<player>") -public class KillCommand extends Command -{ +@CommandInfo(name = "kill", usageParameters = "<player>") +public class KillCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length < 1) - { + protected void run() throws CommandException { + if (args.length < 1) { throwInvalidArgument(I.t("You must specify the player to kill.")); } @@ -61,40 +58,31 @@ protected void run() throws CommandException .filter(pl -> pl.getName().equalsIgnoreCase(args[0])) .findAny().orElse(null); - if (player == null) - { + if (player == null) { error(I.t("{ce}This player was never seen on this server.")); return; } - if (QSG.module(GameModule.class).isAlive(player)) - { - if (player.isOnline()) - { + if (QSG.module(GameModule.class).isAlive(player)) { + if (player.isOnline()) { // If the player is online, we kill it. // It will be cached by normal alive players's death listeners, // plus the inventory will drop, effects will be complete, etc. player.getPlayer().setHealth(0d); - } - else - { + } else { // We only kill the player this way if he is offline. QSG.module(GameModule.class).kill(player); } success(I.t("{cs}The player {0} is now marked as dead.", player.getName())); - } - else - { + } else { error(I.t("{ce}{0} is not an alive player.", player.getName())); } } @Override - protected List<String> complete() - { - if (args.length == 1) - { + protected List<String> complete() { + if (args.length == 1) { return getMatchingSubset( QSG.module(GameModule.class) .getAlivePlayers().stream() @@ -102,7 +90,8 @@ protected List<String> complete() .collect(Collectors.toList()), args[0] ); + } else { + return null; } - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java index 874fbec..8c5671a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/ResurrectCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -39,56 +40,46 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; -@CommandInfo (name = "resurrect", usageParameters = "<player>", aliases = {"revive", "undead"}) -public class ResurrectCommand extends Command -{ +@CommandInfo(name = "resurrect", usageParameters = "<player>", aliases = {"revive", "undead"}) +public class ResurrectCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length != 1) - { + protected void run() throws CommandException { + if (args.length != 1) { throwInvalidArgument(I.t("You must specify the player to resurrect.")); } final OfflinePlayer player = Arrays.stream(Bukkit.getOfflinePlayers()) - .filter(pl -> pl.getName().equalsIgnoreCase(args[0])) - .findAny().orElse(null); + .filter(pl -> pl.getName().equalsIgnoreCase(args[0])) + .findAny().orElse(null); - if (player == null) - { + if (player == null) { error(I.t("{ce}This player was never seen on this server.")); - } - else if (QSG.module(GameModule.class).resurrect(player)) - { + } else if (QSG.module(GameModule.class).resurrect(player)) { success(I.t("{0} was resurrected.", player.getName())); - } - else - { + } else { error(I.t("{ce}This player is not playing or dead!")); } } @Override - protected List<String> complete() - { + protected List<String> complete() { final GameModule game = QSG.module(GameModule.class); - if (args.length == 1) - { + if (args.length == 1) { return getMatchingPlayerNames( - Bukkit.getOnlinePlayers().stream().filter(player -> !game.isAlive(player)).collect(Collectors.toList()), + Bukkit.getOnlinePlayers().stream().filter(player -> !game.isAlive(player)) + .collect(Collectors.toList()), args[0] ); + } else { + return null; } - - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java index ec8bf51..e9b26f9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/commands/StartCommand.java @@ -29,42 +29,42 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter.TeleportationMode; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.commands.WithFlags; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.entity.Player; - import java.util.List; +import org.bukkit.entity.Player; -@CommandInfo (name = "start", usageParameters = "[--slow] [--ignore-teams]") -@WithFlags ({"slow", "ignore-teams"}) -public class StartCommand extends Command -{ +@CommandInfo(name = "start", usageParameters = "[--slow] [--ignore-teams]") +@WithFlags({"slow", "ignore-teams"}) +public class StartCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final GameModule game = QSG.module(GameModule.class); - switch (game.getPhase()) - { + switch (game.getPhase()) { case WAIT: game.setSlowMode(hasFlag("slow")); - game.setTeleportationMode(hasFlag("ignore-teams") ? TeleportationMode.IGNORE_TEAMS : TeleportationMode.NORMAL); + game.setTeleportationMode( + hasFlag("ignore-teams") ? TeleportationMode.IGNORE_TEAMS : TeleportationMode.NORMAL); - if (hasFlag("slow")) - { - if (sender instanceof Player) info(""); + if (hasFlag("slow")) { + if (sender instanceof Player) { + info(""); + } info(I.t("{green}{bold}The game is now starting.")); - info(I.t("{green}Wait for the teleportation to finish; you'll then be prompted to start the game.")); + info(I.t( + "{green}Wait for the teleportation to finish; you'll then be prompted to start the game.")); } game.setPhase(GamePhase.STARTING); @@ -72,12 +72,10 @@ protected void run() throws CommandException break; case STARTING: - try - { + try { game.start(); } - catch (final IllegalStateException e) - { + catch (final IllegalStateException e) { error(I.t("The starting process is not finished yet. Please be patient.")); } @@ -89,8 +87,7 @@ protected void run() throws CommandException } @Override - protected List<String> complete() - { + protected List<String> complete() { return getMatchingSubset(args[args.length - 1], "--slow", "--ignore-teams"); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java index 2b5d889..a99f225 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/game/GamePhaseChangedEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; @@ -46,34 +47,34 @@ * a player is resurrected, check the old phase with {@link #getOldPhase()}, or simpler, * use the {@link #isRunningForward()} method.</p> */ -public class GamePhaseChangedEvent extends Event -{ +public class GamePhaseChangedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final GamePhase oldPhase; private final GamePhase newPhase; - public GamePhaseChangedEvent(final GamePhase oldPhase, final GamePhase newPhase) - { + public GamePhaseChangedEvent(final GamePhase oldPhase, final GamePhase newPhase) { this.oldPhase = oldPhase; this.newPhase = newPhase; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * The old phase. May be {@code null} if this is the first phase ever (i.e. {@link GamePhase#WAIT}). * * @return The old phase. */ - public GamePhase getOldPhase() - { + public GamePhase getOldPhase() { return oldPhase; } /** * @return The new phase. */ - public GamePhase getNewPhase() - { + public GamePhase getNewPhase() { return newPhase; } @@ -90,19 +91,12 @@ public GamePhase getNewPhase() * * @return {@code true} if the game is running forward. */ - public boolean isRunningForward() - { + public boolean isRunningForward() { return oldPhase == null || newPhase.ordinal() > oldPhase.ordinal(); } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java index 2259f42..a940fa3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/AlivePlayerDeathEvent.java @@ -41,33 +41,35 @@ /** * Fired when a player playing an UHC match is dead. - * + * <p> * When this event is called, the player is not yet removed from the alive * players (i.e. {@code UR.module(GameModule.class).isAlive(ev.getPlayer())} * will return {@code true}). - * + * <p> * If the event is cancelled, the player will die but will not be removed * from the alive players. */ -public class AlivePlayerDeathEvent extends Event implements Cancellable -{ +public class AlivePlayerDeathEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private final OfflinePlayer player; private final PlayerDeathEvent playerDeathEvent; - private boolean cancelled = false; - public AlivePlayerDeathEvent(final OfflinePlayer player, final PlayerDeathEvent playerDeathEvent) - { + public AlivePlayerDeathEvent(final OfflinePlayer player, final PlayerDeathEvent playerDeathEvent) { this.player = player; this.playerDeathEvent = playerDeathEvent; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the dead player. + * * @return The player. */ - public OfflinePlayer getPlayer() - { + public OfflinePlayer getPlayer() { return player; } @@ -77,35 +79,22 @@ public OfflinePlayer getPlayer() * * @return The {@link PlayerDeathEvent}. */ - public PlayerDeathEvent getPlayerDeathEvent() - { + public PlayerDeathEvent getPlayerDeathEvent() { return playerDeathEvent; } - @Override - public boolean isCancelled() - { + public boolean isCancelled() { return cancelled; } @Override - public void setCancelled(boolean cancelled) - { + public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java index c0156bd..c859329 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/PlayerResurrectedEvent.java @@ -40,37 +40,29 @@ /** * Called when a player is resurrected. */ -public class PlayerResurrectedEvent extends Event -{ +public class PlayerResurrectedEvent extends Event { + private static final HandlerList handlers = new HandlerList(); private final OfflinePlayer resurrectedPlayer; - public PlayerResurrectedEvent(final OfflinePlayer player) - { + public PlayerResurrectedEvent(final OfflinePlayer player) { this.resurrectedPlayer = player; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the resurrected player. * * @return The player. */ - public OfflinePlayer getPlayer() - { + public OfflinePlayer getPlayer() { return resurrectedPlayer; } - - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java index c3d5e90..b7a0c5f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/players/TeamDeathEvent.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players; -import fr.zcraft.zteams.ZTeam; +import fr.zcraft.quartzteams.QuartzTeam; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -40,37 +40,29 @@ /** * Event fired when the last member of a team die. */ -public class TeamDeathEvent extends Event -{ - private final ZTeam team; +public class TeamDeathEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private final QuartzTeam team; - public TeamDeathEvent(ZTeam team) - { + public TeamDeathEvent(QuartzTeam team) { this.team = team; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the now-dead team. * * @return The team. */ - public ZTeam getTeam() - { + public QuartzTeam getTeam() { return team; } - - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java index 4004a17..c712319 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/AfterTeleportationPhaseEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.event.Event; @@ -38,18 +39,15 @@ /** * Fired while starting the game, when the teleportation phase is finished. */ -public class AfterTeleportationPhaseEvent extends Event -{ +public class AfterTeleportationPhaseEvent extends Event { private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { + public static HandlerList getHandlerList() { return handlers; } - public static HandlerList getHandlerList() - { + @Override + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java index 5c4988a..cc33957 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/BeforeTeleportationPhaseEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.event.Event; @@ -39,18 +40,15 @@ * Fired while starting the game, when the teleportation phase is about * to start. */ -public class BeforeTeleportationPhaseEvent extends Event -{ +public class BeforeTeleportationPhaseEvent extends Event { private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { + public static HandlerList getHandlerList() { return handlers; } - public static HandlerList getHandlerList() - { + @Override + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java index c1fab73..85f8e8c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerAboutToBeTeleportedToSpawnPointEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; @@ -39,42 +40,36 @@ /** * Fired just before a player's teleportation to its spawn point. - * + * <p> * The spawn point cannot be modified here. * * @see PlayerSpawnPointSelectedEvent */ -public class PlayerAboutToBeTeleportedToSpawnPointEvent extends Event -{ +public class PlayerAboutToBeTeleportedToSpawnPointEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final Player player; private final Location spawnPoint; - public PlayerAboutToBeTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) - { + public PlayerAboutToBeTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) { this.player = player; this.spawnPoint = spawnPoint; } - public Player getPlayer() - { + public static HandlerList getHandlerList() { + return handlers; + } + + public Player getPlayer() { return player; } - public Location getSpawnPoint() - { + public Location getSpawnPoint() { return spawnPoint; } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java index d336989..730b934 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerSpawnPointSelectedEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; @@ -40,42 +41,35 @@ /** * Fired when a spawn point is selected for a given player. */ -public class PlayerSpawnPointSelectedEvent extends Event -{ +public class PlayerSpawnPointSelectedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final OfflinePlayer player; private Location spawnPoint; - public PlayerSpawnPointSelectedEvent(final OfflinePlayer player, final Location spawnPoint) - { + public PlayerSpawnPointSelectedEvent(final OfflinePlayer player, final Location spawnPoint) { this.player = player; this.spawnPoint = spawnPoint; } - public OfflinePlayer getPlayer() - { + public static HandlerList getHandlerList() { + return handlers; + } + + public OfflinePlayer getPlayer() { return player; } - public Location getSpawnPoint() - { + public Location getSpawnPoint() { return spawnPoint; } - public void setSpawnPoint(Location spawnPoint) - { + public void setSpawnPoint(Location spawnPoint) { this.spawnPoint = spawnPoint; } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java index 3052a6f..330ebad 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/events/start/PlayerTeleportedToSpawnPointEvent.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start; import org.bukkit.Location; @@ -39,42 +40,36 @@ /** * Fired when a player is teleported to its spawn point. - * + * <p> * The spawn point cannot be modified here. * * @see PlayerSpawnPointSelectedEvent */ -public class PlayerTeleportedToSpawnPointEvent extends Event -{ +public class PlayerTeleportedToSpawnPointEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final Player player; private final Location spawnPoint; - public PlayerTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) - { + public PlayerTeleportedToSpawnPointEvent(final Player player, final Location spawnPoint) { this.player = player; this.spawnPoint = spawnPoint; } - public Player getPlayer() - { + public static HandlerList getHandlerList() { + return handlers; + } + + public Player getPlayer() { return player; } - public Location getSpawnPoint() - { + public Location getSpawnPoint() { return spawnPoint; } @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java index d765a7e..bdc13dd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java @@ -31,8 +31,10 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.submanagers; +import com.google.common.collect.ImmutableSet; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; @@ -41,10 +43,12 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.EntitiesUtils; import eu.carrade.amaury.quartzsurvivalgames.utils.Run; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.core.QuartzComponent; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -53,8 +57,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityDamageEvent; -public class GameBeginning extends ZLibComponent implements Listener -{ +public class GameBeginning extends QuartzComponent implements Listener { /** * A flag used to disable damages at the beginning of the game to avoid fall damages and early ones. */ @@ -64,73 +67,84 @@ public class GameBeginning extends ZLibComponent implements Listener * A flag used to disable hostile mobs spawn on the surface a few minutes after the beginning of the game. */ private boolean inMobsFreePeriod = false; + + private static final Set<String> SURFACE_MATERIAL_ENDS = ImmutableSet.of( + "LOG", + "LEAVES", + "PLANKS", + "STAIRS", + "BANNER", + "WALL", + "FENCE" + ); @EventHandler(priority = EventPriority.LOWEST) - private void onGameStarts(GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + private void onGameStarts(GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) { + return; + } /* *** Grace period (damages disabled) *** */ TimeDelta grace = Config.BEGINNING.GRACE_PERIOD.get(); - if (grace.getSeconds() < 15) - { + if (grace.getSeconds() < 15) { grace = new TimeDelta(15); } inGracePeriod = true; Run.withCountdown( - I.t("{green}{bold}Grace period"), - I.t("{green}All damages are disabled"), - second -> I.tn("{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", (int) second), - I.t("{yellow}{bold}Over! {yellow}You are now vulnerable..."), - () -> QSG.game().getAliveConnectedPlayers(), - () -> { - inGracePeriod = false; - - if (Config.BEGINNING.BROADCAST_GRACE_END.get()) - { - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} The grace period is over, you are now vulnerable.")); - } - }, - grace + I.t("{green}{bold}Grace period"), + I.t("{green}All damages are disabled"), + second -> I.tn("{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", + "{yellow}{bold}Over in {gold}{bold}{0}{yellow}{bold} second", (int) second), + I.t("{yellow}{bold}Over! {yellow}You are now vulnerable..."), + () -> QSG.game().getAliveConnectedPlayers(), + () -> { + inGracePeriod = false; + + if (Config.BEGINNING.BROADCAST_GRACE_END.get()) { + Bukkit.broadcastMessage( + I.t("{red}{bold}Warning!{white} The grace period is over, you are now vulnerable.")); + } + }, + grace ); /* *** Peace period (PVP disabled) *** */ - if (Config.BEGINNING.PEACE_PERIOD.get().getSeconds() > 0) - { + if (Config.BEGINNING.PEACE_PERIOD.get().getSeconds() > 0) { setPVP(false); Run.withCountdown( - I.t("{red}{bold}Combats between players"), - null, - second -> I.tn("{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", "{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", (int) second), - I.t("{yellow}{bold}Now allowed! {yellow}Beware..."), - (short) 10, - () -> QSG.game().getAliveConnectedPlayers(), - () -> { - setPVP(true); - Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); - }, - Config.BEGINNING.PEACE_PERIOD.get() + I.t("{red}{bold}Combats between players"), + null, + second -> I.tn("{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", + "{yellow}{bold}Allowed in {gold}{bold}{0}{yellow}{bold} second", (int) second), + I.t("{yellow}{bold}Now allowed! {yellow}Beware..."), + (short) 10, + () -> QSG.game().getAliveConnectedPlayers(), + () -> { + setPVP(true); + Bukkit.broadcastMessage(I.t("{red}{bold}Warning!{white} PvP is now enabled.")); + }, + Config.BEGINNING.PEACE_PERIOD.get() ); + } else { + setPVP(true); } - else setPVP(true); - /* *** Mobs-free period (mobs disabled on surface) *** */ - if (Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() > 0) - { + if (Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() > 0) { inMobsFreePeriod = true; - RunTask.later(() -> inMobsFreePeriod = false, Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() * 20L); + RunTask.later(() -> inMobsFreePeriod = false, + Config.BEGINNING.SURFACE_MOBS_FREE_PERIOD.get().getSeconds() * 20L); } } @@ -139,10 +153,8 @@ private void onGameStarts(GamePhaseChangedEvent ev) * Used to disable all damages if the game is not started. */ @EventHandler - private void onEntityDamage(final EntityDamageEvent ev) - { - if (ev.getEntity() instanceof Player && inGracePeriod) - { + private void onEntityDamage(final EntityDamageEvent ev) { + if (ev.getEntity() instanceof Player && inGracePeriod) { ev.setCancelled(true); } } @@ -151,10 +163,9 @@ private void onEntityDamage(final EntityDamageEvent ev) * Used to cancel the spawn of hostile entities on the surface only, at the beginning of the game. */ @EventHandler - private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) - { - if (inMobsFreePeriod && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) && EntitiesUtils.isHostile(ev.getEntityType())) - { + private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) { + if (inMobsFreePeriod && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) && + EntitiesUtils.isHostile(ev.getEntityType())) { // We check the blocs above the entity to see if we only find surface blocks. final Location spawnLocation = ev.getLocation(); final World world = spawnLocation.getWorld(); @@ -165,30 +176,27 @@ private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) boolean surface = true; - for (int y = spawnLocation.getBlockY(); y <= highestBlockY; y++) - { - switch (world.getBlockAt(x, y, z).getType()) - { + for (int y = spawnLocation.getBlockY(); y <= highestBlockY; y++) { + final Material type = world.getBlockAt(x, y, z).getType(); + + switch (type) { // Air case AIR: + + // Trees + case BROWN_MUSHROOM_BLOCK: + case RED_MUSHROOM_BLOCK: - // Trees - case LOG: - case LOG_2: - case LEAVES: - case LEAVES_2: - case HUGE_MUSHROOM_1: - case HUGE_MUSHROOM_2: - - // Vegetation + // Vegetation case DEAD_BUSH: - case CROPS: + case CHORUS_PLANT: + case KELP_PLANT: case GRASS: - case LONG_GRASS: - case DOUBLE_PLANT: - case YELLOW_FLOWER: + case CHORUS_FLOWER: + case SUNFLOWER: + case CORNFLOWER: case VINE: - case SUGAR_CANE_BLOCK: + case SUGAR_CANE: case BROWN_MUSHROOM: case RED_MUSHROOM: @@ -199,22 +207,16 @@ private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) case SNOW_BLOCK: // Villages - case WOOD: - case WOOD_STAIRS: - case SANDSTONE_STAIRS: case BOOKSHELF: // Redstone case REDSTONE_WIRE: - case REDSTONE_COMPARATOR: - case REDSTONE_COMPARATOR_OFF: - case REDSTONE_COMPARATOR_ON: - case REDSTONE_TORCH_OFF: - case REDSTONE_TORCH_ON: + case COMPARATOR: + case REDSTONE_TORCH: // Other blocs frequently used on surface on custom maps case TORCH: - case RAILS: + case RAIL: case ACTIVATOR_RAIL: case DETECTOR_RAIL: case POWERED_RAIL: @@ -224,15 +226,23 @@ private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) surface = false; } - if (!surface) break; + if (!surface) { + final String typeName = type.name(); + surface = SURFACE_MATERIAL_ENDS.stream().anyMatch(typeName::endsWith); + } + + if (!surface) { + break; + } } - if (surface) ev.setCancelled(true); + if (surface) { + ev.setCancelled(true); + } } } - private void setPVP(final boolean pvp) - { + private void setPVP(final boolean pvp) { QSG.get().getWorlds().forEach(world -> world.setPVP(pvp)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java index 49f4d5d..2032b6f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationMode.java @@ -31,10 +31,10 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; -public enum TeleportationMode -{ +public enum TeleportationMode { /** * Teams are teleported together. */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java index a2ccc3e..0c7b2e6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/TeleportationRunnable.java @@ -29,25 +29,24 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.tools.Callback; -import org.bukkit.scheduler.BukkitRunnable; - import java.util.ArrayDeque; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Queue; import java.util.Set; import java.util.UUID; +import org.bukkit.scheduler.BukkitRunnable; /** * @see Teleporter */ -class TeleportationRunnable extends BukkitRunnable -{ +class TeleportationRunnable extends BukkitRunnable { private final Teleporter teleporter; private final Queue<UUID> teleportationQueue; @@ -58,8 +57,9 @@ class TeleportationRunnable extends BukkitRunnable private final Set<UUID> failed = new HashSet<>(); - public TeleportationRunnable(Teleporter teleporter, Set<UUID> playersToTeleport, Callback<UUID> onTeleportation, Callback<UUID> onTeleportationSuccessful, Callback<UUID> onTeleportationFailed, Callback<Set<UUID>> onTeleportationProcessFinished) - { + public TeleportationRunnable(Teleporter teleporter, Set<UUID> playersToTeleport, Callback<UUID> onTeleportation, + Callback<UUID> onTeleportationSuccessful, Callback<UUID> onTeleportationFailed, + Callback<Set<UUID>> onTeleportationProcessFinished) { this.teleporter = teleporter; this.onTeleportation = onTeleportation; this.onTeleportationSuccessful = onTeleportationSuccessful; @@ -70,20 +70,15 @@ public TeleportationRunnable(Teleporter teleporter, Set<UUID> playersToTeleport, } @Override - public void run() - { - try - { + public void run() { + try { UUID player = teleportationQueue.remove(); QSGUtils.callIfDefined(onTeleportation, player); - if (teleporter.teleportPlayer(player, false)) - { + if (teleporter.teleportPlayer(player, false)) { QSGUtils.callIfDefined(onTeleportationSuccessful, player); - } - else - { + } else { QSGUtils.callIfDefined(onTeleportationFailed, player); failed.add(player); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java index 37188f7..90472b9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/teleporter/Teleporter.java @@ -29,26 +29,25 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.game.teleporter; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config; import fr.zcraft.quartzlib.tools.Callback; import fr.zcraft.quartzlib.tools.runners.RunTask; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; /** * Manages the initial teleportation process, and stores the spawn points of the players. */ -public class Teleporter -{ +public class Teleporter { /** * The spawn point designed for each player. */ @@ -87,8 +86,7 @@ public class Teleporter * @param playerUUID The player's UUID. * @param spawn The spawn location. */ - public void setSpawnForPlayer(final UUID playerUUID, final Location spawn) - { + public void setSpawnForPlayer(final UUID playerUUID, final Location spawn) { spawnPoints.put(playerUUID, spawn); } @@ -98,8 +96,7 @@ public void setSpawnForPlayer(final UUID playerUUID, final Location spawn) * @param playerUUID The player UUID. * @return {@code true} if a spawn point is registered. */ - public boolean hasSpawnForPlayer(final UUID playerUUID) - { + public boolean hasSpawnForPlayer(final UUID playerUUID) { return spawnPoints.containsKey(playerUUID); } @@ -107,8 +104,7 @@ public boolean hasSpawnForPlayer(final UUID playerUUID) * @param playerUUID A player's UUID. * @return The registered spawn point for that player, or {@code null} if no-one was ever registered. */ - public Location getSpawnForPlayer(final UUID playerUUID) - { + public Location getSpawnForPlayer(final UUID playerUUID) { return spawnPoints.get(playerUUID).clone(); } @@ -119,23 +115,22 @@ public Location getSpawnForPlayer(final UUID playerUUID) * @param playerUUID The player's UUID. * @param teleportOnGround if {@code true} the player will be teleported on the ground; else, at * the location directly. - * * @return {@code true} if the player was teleported (i.e. was online and with an associated * spawn point). */ - public boolean teleportPlayer(UUID playerUUID, Boolean teleportOnGround) - { + public boolean teleportPlayer(UUID playerUUID, Boolean teleportOnGround) { Player player = Bukkit.getPlayer(playerUUID); - if (player == null) + if (player == null) { return false; + } Location spawn = spawnPoints.get(playerUUID); - if (spawn == null) + if (spawn == null) { return false; - - else if (teleportOnGround) + } else if (teleportOnGround) { spawn = spawn.getWorld().getHighestBlockAt(spawn).getLocation().add(0, 2, 0); + } player.teleport(spawn); return true; @@ -146,11 +141,9 @@ else if (teleportOnGround) * Registers a callback called just before trying to teleport a player. * * @param callback The callback. Argument: the teleported player's UUID. - * * @return Same instance for chaining. */ - public Teleporter whenTeleportationOccurs(Callback<UUID> callback) - { + public Teleporter whenTeleportationOccurs(Callback<UUID> callback) { onTeleportation = callback; return this; } @@ -159,11 +152,9 @@ public Teleporter whenTeleportationOccurs(Callback<UUID> callback) * Registers a callback called when a player is teleported successfully. * * @param callback The callback. Argument: the non-teleported player's UUID. - * * @return Same instance for chaining. */ - public Teleporter whenTeleportationSuccesses(Callback<UUID> callback) - { + public Teleporter whenTeleportationSuccesses(Callback<UUID> callback) { onTeleportationSuccessful = callback; return this; } @@ -172,11 +163,9 @@ public Teleporter whenTeleportationSuccesses(Callback<UUID> callback) * Registers a callback called when a player cannot be teleported. * * @param callback The callback. Argument: the non-teleported player's UUID. - * * @return Same instance for chaining. */ - public Teleporter whenTeleportationFails(Callback<UUID> callback) - { + public Teleporter whenTeleportationFails(Callback<UUID> callback) { onTeleportationFailed = callback; return this; } @@ -189,11 +178,9 @@ public Teleporter whenTeleportationFails(Callback<UUID> callback) * * @param callback The callback. Argument: a set containing the UUID of all non-teleported * players. - * * @return Same instance for chaining. */ - public Teleporter whenTeleportationEnds(Callback<Set<UUID>> callback) - { + public Teleporter whenTeleportationEnds(Callback<Set<UUID>> callback) { onTeleportationProcessFinished = callback; return this; } @@ -205,19 +192,18 @@ public Teleporter whenTeleportationEnds(Callback<Set<UUID>> callback) * @param slowMode if {@code true}, the players will be slowly teleported one by one, with a * delay between them. */ - public void startTeleportationProcess(Boolean slowMode) - { + public void startTeleportationProcess(Boolean slowMode) { RunTask.timer( - new TeleportationRunnable( - this, - spawnPoints.keySet(), - onTeleportation, - onTeleportationSuccessful, - onTeleportationFailed, - onTeleportationProcessFinished - ), - 1L, - slowMode ? 1L : Config.SLOW.DELAY_BETWEEN_TP.get() * 20L + new TeleportationRunnable( + this, + spawnPoints.keySet(), + onTeleportation, + onTeleportationSuccessful, + onTeleportationFailed, + onTeleportationProcessFinished + ), + 1L, + slowMode ? 1L : Config.SLOW.DELAY_BETWEEN_TP.get() * 20L ); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java index c81aa52..880e68d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java @@ -58,7 +58,7 @@ description = "Offers to the users a way to manage modules.", when = ModuleLoadTime.STARTUP, category = ModuleCategory.CORE, - icon = Material.COMMAND, + icon = Material.COMMAND_BLOCK, can_be_unloaded = false ) public class ModulesModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java index 898b03d..ed11beb 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java @@ -49,10 +49,11 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.runners.RunTask; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.guis.TeamsSelectorGUI; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.guis.TeamsSelectorGUI; import org.bukkit.*; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.scheduler.BukkitTask; import java.util.Set; @@ -84,8 +85,7 @@ protected void onUpdate() headCycleNames = Stream.concat(alivePlayers.stream(), spectators.stream()).toArray(String[]::new); - action("players", 10, new ItemStackBuilder(Material.SKULL_ITEM) - .data((short) SkullType.PLAYER.ordinal()) + action("players", 10, new ItemStackBuilder(Material.PLAYER_HEAD) .amount(Math.max(alivePlayers.size(), 1)) .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Players")) .loreLine( @@ -107,15 +107,15 @@ protected void onUpdate() action("teams", 12, new ItemStackBuilder( QSG.module(WaitModule.class) != null ? Config.TEAM_SELECTOR.ITEM.get() : Material.NETHER_STAR) .title(ChatColor.AQUA, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teams")) - .amount(Math.max(ZTeams.get().countTeams(), 1)) - .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", ZTeams.get().countTeams())) + .amount(Math.max(QuartzTeams.get().countTeams(), 1)) + .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", QuartzTeams.get().countTeams())) .loreSeparator() .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "The game can either be solo or in teams. In the second case, click here to create or update teams."), 38) .loreSeparator() .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage the teams")) ); - action("title", 14, new ItemStackBuilder(Material.BOOK_AND_QUILL) + action("title", 14, new ItemStackBuilder(Material.WRITABLE_BOOK) .title(ChatColor.DARK_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Game Title")) .loreSeparator() .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click to update the game title. It is displayed on the sidebar and may be used by other modules (like the reports one)."), 38) @@ -130,7 +130,7 @@ protected void onUpdate() final int modulesEnabled = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); final int modulesLoaded = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); - action("modules", 16, new ItemStackBuilder(Material.COMMAND) + action("modules", 16, new ItemStackBuilder(Material.REPEATING_COMMAND_BLOCK) .title(ChatColor.LIGHT_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Modules")) .loreLine( ChatColor.DARK_GRAY, @@ -148,8 +148,7 @@ protected void onUpdate() if (!QSG.game().currentPhaseAfter(GamePhase.WAIT)) { - action("start", 31, new ItemStackBuilder(Material.INK_SACK) // FIXME 1.13 - .data(DyeColor.LIME.getDyeData()) + action("start", 31, new ItemStackBuilder(Material.LIME_DYE) .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Start the game")) .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If you're ready, click here to start the game!")) ); @@ -161,7 +160,10 @@ protected void onUpdate() final ItemStack skull = getInventory().getItem(10); if (skull != null) { - new ItemStackBuilder(getInventory().getItem(10)).head(headCycleNames[headCycleIndex]).item(); + // TODO replace with QL 0.1 ISB + final SkullMeta meta = (SkullMeta) getInventory().getItem(10).getItemMeta(); + meta.setOwner(headCycleNames[headCycleIndex]); + getInventory().getItem(10).setItemMeta(meta); headCycleIndex = (headCycleIndex + 1) % headCycleNames.length; if (headCycleIndex < 0) headCycleIndex += headCycleNames.length; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java index aac7dfa..c43e6be 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java @@ -39,12 +39,10 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.mojang.MojangHead; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; - import java.util.List; import java.util.stream.Collectors; +import org.bukkit.ChatColor; +import org.bukkit.Material; public class ConfirmModuleDisableGUI extends FramedModuleGUI { @@ -72,13 +70,11 @@ protected void onUpdate() .longLore(ChatColor.WHITE, I.t("Are you sure you want to disable {0}?", module.getName()), 38) .item()); - final ItemStackBuilder no = new ItemStackBuilder(Material.STAINED_GLASS_PANE) - .data(DyeColor.RED.getWoolData()) // FIXME 1.13 + final ItemStackBuilder no = new ItemStackBuilder(Material.RED_STAINED_GLASS_PANE) .title(ChatColor.GREEN, ChatColor.BOLD + I.t("I changed my mind")) .longLore(ChatColor.GRAY, I.t("Go back without disabling the module")); - final ItemStackBuilder yes = new ItemStackBuilder(Material.STAINED_GLASS_PANE) - .data(DyeColor.GREEN.getWoolData()) // FIXME 1.13 + final ItemStackBuilder yes = new ItemStackBuilder(Material.LIME_STAINED_GLASS_PANE) .title(ChatColor.RED, ChatColor.BOLD + I.t("Yes, disable")) .longLore(ChatColor.GRAY, I.t("Disable {0} without any possibility of re-enabling it", module.getName())); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java index 5a6a5d7..615b432 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java @@ -36,8 +36,7 @@ import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import fr.zcraft.quartzlib.components.gui.ActionGui; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; -import fr.zcraft.zteams.colors.ColorsUtils; -import org.bukkit.Material; +import fr.zcraft.quartzteams.colors.ColorsUtils; import org.bukkit.inventory.ItemStack; public abstract class FramedModuleGUI extends ActionGui @@ -52,9 +51,8 @@ public FramedModuleGUI(ModuleWrapper module) @Override protected void onAfterUpdate() { - final ItemStack framePart = new ItemStackBuilder(Material.STAINED_GLASS_PANE) + final ItemStack framePart = new ItemStackBuilder(ColorsUtils.chat2Block(module.getCategory().getColor(), "STAINED_GLASS_PANE")) .title("") - .data(ColorsUtils.chat2Dye(module.getCategory().getColor()).getWoolData()) // FIXME 1.13 .item(); // Top and bottom diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java index c0fa7cc..b398226 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java @@ -43,7 +43,7 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.mojang.MojangHead; -import fr.zcraft.zteams.colors.ColorsUtils; +import fr.zcraft.quartzteams.colors.ColorsUtils; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -128,8 +128,7 @@ protected void onUpdate() // Displays the bottom bar of color - final ItemStackBuilder bottomColorStripe = new ItemStackBuilder(Material.STAINED_GLASS_PANE) - .data(ColorsUtils.chat2Dye(filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE).getWoolData()) // FIXME 1.13 + final ItemStackBuilder bottomColorStripe = new ItemStackBuilder(ColorsUtils.chat2Block(filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE, "STAINED_GLASS_PANE")) .title(filterCategory != null ? filterCategory.getColor() + "" + ChatColor.BOLD + filterCategory.getDisplayName() : ""); if (filterCategory != null) bottomColorStripe.longLore(ChatColor.GRAY, filterCategory.getDescription(), 38); @@ -162,8 +161,7 @@ protected void onUpdate() // Displays the state filter button - final ItemStackBuilder stateFilter = new ItemStackBuilder(Material.INK_SACK) // FIXME 1.13 - .data(filterState.color.getDyeData()) + final ItemStackBuilder stateFilter = new ItemStackBuilder(ColorsUtils.dye2Block(filterState.color, "DYE")) .title(ChatColor.YELLOW, ChatColor.BOLD + I.tl(getPlayerLocale(), "Filter modules state")) .loreSeparator(); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java index 183cddb..d4b26ae 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java @@ -44,7 +44,7 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.mojang.MojangHead; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -73,7 +73,7 @@ protected void onUpdate() .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If your server is a little bit small, use this option to teleport players slowly, loading the chunks one player at a time. You'll have to confirm the game start using a link in the chat."), 52) ); - if (ZTeams.get().countTeams() > 0) + if (QuartzTeams.get().countTeams() > 0) { action("teleportation_mode", 13, new ItemStackBuilder() .material(mode == TeleportationMode.NORMAL ? Material.SUGAR : Material.GLOWSTONE_DUST) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java index add1706..56be4f5 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java @@ -45,7 +45,7 @@ name = "Sidebar", description = "Manages the sidebar and allows hooks for all modules into it.", category = ModuleCategory.CORE, - icon = Material.BOOK_AND_QUILL, + icon = Material.WRITABLE_BOOK, internal = true, can_be_unloaded = false ) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java index 7a4245f..d946055 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java @@ -45,7 +45,7 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.components.commands.Command; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -301,7 +301,7 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) final int regionDiameter = QSG.module(BorderModule.class).getCurrentBorderDiameter(); final int playersWithoutTeam = (int) Bukkit.getOnlinePlayers().stream() - .filter(player -> ZTeams.get().getTeamForPlayer(player) == null) + .filter(player -> QuartzTeams.get().getTeamForPlayer(player) == null) .count(); int spawnsNeeded = 0; @@ -309,11 +309,11 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) switch (game.getTeleportationMode()) { case NORMAL: - spawnsNeeded = ZTeams.get().countTeams() + playersWithoutTeam; + spawnsNeeded = QuartzTeams.get().countTeams() + playersWithoutTeam; break; case IGNORE_TEAMS: - spawnsNeeded = ZTeams.get().getTeams().stream().mapToInt(team -> team.getPlayers().size()).sum() + spawnsNeeded = QuartzTeams.get().getTeams().stream().mapToInt(team -> team.getPlayers().size()).sum() + playersWithoutTeam; break; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java index 21369e2..2dcd607 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java @@ -43,8 +43,8 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -375,7 +375,7 @@ protected void generate() throws CommandException double zCenter = world.getSpawnLocation().getZ(); int spawnsCount = 0; - for (final ZTeam team : ZTeams.get().getTeams()) + for (final QuartzTeam team : QuartzTeams.get().getTeams()) { if (!team.isEmpty()) spawnsCount++; } @@ -412,7 +412,7 @@ else if (sender instanceof BlockCommandSender) int playersWithoutTeam = 0; for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (ZTeams.get().getTeamForPlayer(player) == null) + if (QuartzTeams.get().getTeamForPlayer(player) == null) { playersWithoutTeam++; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index b95d222..3237a90 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -147,7 +147,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // Not above the water? if (avoidWater) { - if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.STATIONARY_WATER) + if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) { continue; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java index 58b839d..a5c2d27 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -176,7 +176,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // Not above the water? if (avoidWater) { - if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.STATIONARY_WATER) + if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) { continue; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index 94d7a90..a8d712a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -171,7 +171,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // Not above the water? if (avoidWater) { - if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.STATIONARY_WATER) + if (surfaceBlock.getType() == Material.WATER) { pointsAboveWater++; continue; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java index 8a65a97..abb0702 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java @@ -66,7 +66,7 @@ description = "Handles non-playing players.", when = ModuleLoadTime.POST_WORLD, category = ModuleCategory.CORE, - icon = Material.EYE_OF_ENDER, + icon = Material.ENDER_EYE, settings = Config.class, can_be_unloaded = false ) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java index a576a7c..d809f33 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java @@ -32,7 +32,7 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorPlusDependency; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -48,7 +48,7 @@ public abstract class SpectatorsManager static { - spectatorPlusDependency = ZLib.loadComponent(SpectatorPlusDependency.class); + spectatorPlusDependency = QuartzLib.loadComponent(SpectatorPlusDependency.class); } /** diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java index 10ff16f..0f89c3f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java @@ -29,118 +29,98 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; -import fr.zcraft.zteams.guis.TeamsGUIItemType; - +import fr.zcraft.quartzteams.guis.TeamsGUIItemType; import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - static public final ConfigurationItem<Boolean> CAN_SEE_FRIENDLY_INVISIBLES = item("can-see-friendly-invisibles", true); +public class Config extends ConfigurationInstance { + static public final ConfigurationItem<Boolean> CAN_SEE_FRIENDLY_INVISIBLES = + item("can-see-friendly-invisibles", true); static public final ConfigurationItem<Boolean> ALLOW_FRIENDLY_FIRE = item("allow-friendly-fire", true); static public final ConfigurationItem<Integer> MAX_PLAYERS_PER_TEAM = item("max-players-per-team", 0); - static public final ConfigurationItem<Boolean> COLORIZE_CHAT = item("colorize-chat", true); - static public final BannerSection BANNER = section("banner", BannerSection.class); + static public final ChestGuiSection GUI = section("gui", ChestGuiSection.class); + static public final TeamChatSection TEAM_CHAT = section("team-chat", TeamChatSection.class); + static public final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); - static public class BannerSection extends ConfigurationSection - { + public Config(File file) { + super(file); + } + + static public class BannerSection extends ConfigurationSection { public final ShapeSection SHAPE = section("shape", ShapeSection.class); + public final GiveSection GIVE = section("give", GiveSection.class); + public final ShieldSection SHIELDS = section("shields", ShieldSection.class); - static public class ShapeSection extends ConfigurationSection - { + static public class ShapeSection extends ConfigurationSection { public final ConfigurationItem<Boolean> WRITE_LETTER = item("write-letter", true); public final ConfigurationItem<Boolean> ADD_BORDER = item("add-border", true); } - public final GiveSection GIVE = section("give", GiveSection.class); - - static public class GiveSection extends ConfigurationSection - { + static public class GiveSection extends ConfigurationSection { public final ConfigurationItem<Boolean> PLACE_ON_SPAWN = item("place-on-spawn", true); public final ConfigurationItem<Boolean> GIVE_IN_HOTBAR = item("give-in-hotbar", false); public final ConfigurationItem<Boolean> GIVE_ON_HEAD = item("give-on-head", false); } - public final ShieldSection SHIELDS = section("shields", ShieldSection.class); - - static public class ShieldSection extends ConfigurationSection - { + static public class ShieldSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ADD_ON_SHIELDS = item("add-on-shields", true); } } - static public final ChestGuiSection GUI = section("gui", ChestGuiSection.class); - - static public class ChestGuiSection extends ConfigurationSection - { + static public class ChestGuiSection extends ConfigurationSection { public final DisplaySection DISPLAY = section("display", DisplaySection.class); - static public class DisplaySection extends ConfigurationSection - { + static public class DisplaySection extends ConfigurationSection { public final ConfigurationItem<TeamsGUIItemType> TEAM_ITEM = item("team-item", TeamsGUIItemType.BANNER); public final ConfigurationItem<Boolean> GLOW_ON_SELECTED_TEAM = item("glow-on-selected-team", true); } } - static public final TeamChatSection TEAM_CHAT = section("team-chat", TeamChatSection.class); - - static public class TeamChatSection extends ConfigurationSection - { + static public class TeamChatSection extends ConfigurationSection { public final ConfigurationItem<Boolean> DISABLE_LOCK_ON_DEATH = item("disable-lock-on-death", true); public final ConfigurationItem<Boolean> LOG = item("log", false); } - static public final SidebarSection SIDEBAR = section("sidebar", SidebarSection.class); - - static public class SidebarSection extends ConfigurationSection - { + static public class SidebarSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); public final TitleSection TITLE = section("title", TitleSection.class); + public final ContentSection CONTENT = section("content", ContentSection.class); - static public class TitleSection extends ConfigurationSection - { + static public class TitleSection extends ConfigurationSection { public final ConfigurationItem<String> COLOR = item("color", ""); public final ConfigurationItem<Boolean> USE_TEAM_NAME = item("use-team-name", false); } - public final ContentSection CONTENT = section("content", ContentSection.class); - - static public class ContentSection extends ConfigurationSection - { + static public class ContentSection extends ConfigurationSection { public final ConfigurationItem<Boolean> DISPLAY_HEARTS = item("display-hearts", true); public final ConfigurationItem<Boolean> COLOR_NAME = item("color-name", false); public final ConfigurationItem<Boolean> STRIKE_DEAD_PLAYERS = item("strike-dead-players", false); public final LoginStateSection LOGIN_STATE = section("login-state", LoginStateSection.class); + public final DisplayMetPlayersOnlySection DISPLAY_MET_PLAYERS_ONLY = + section("display-met-players-only", DisplayMetPlayersOnlySection.class); - static public class LoginStateSection extends ConfigurationSection - { + static public class LoginStateSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ITALIC = item("italic", true); public final ConfigurationItem<String> SUFFIX = item("suffix", "➥"); } - public final DisplayMetPlayersOnlySection DISPLAY_MET_PLAYERS_ONLY = section("display-met-players-only", DisplayMetPlayersOnlySection.class); - - static public class DisplayMetPlayersOnlySection extends ConfigurationSection - { + static public class DisplayMetPlayersOnlySection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", false); - public final ConfigurationItem<Double> DISPLAYED_WHEN_CLOSER_THAN = item("displayed-when-closer-than", 10d); + public final ConfigurationItem<Double> DISPLAYED_WHEN_CLOSER_THAN = + item("displayed-when-closer-than", 10d); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java index 8cd9dab..f2deade 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/TeamsModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams; import com.google.common.collect.ImmutableMap; @@ -46,11 +47,24 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.commands.*; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.commands.GlobalChatCommand; +import fr.zcraft.quartzteams.commands.MyTeamCommand; +import fr.zcraft.quartzteams.commands.TeamChatCommand; +import fr.zcraft.quartzteams.commands.TeamsCommand; +import fr.zcraft.quartzteams.commands.TeamsGuiCommand; +import fr.zcraft.quartzteams.commands.ToggleChatCommand; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -65,17 +79,8 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BlockStateMeta; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; - -@ModuleInfo ( +@ModuleInfo( name = "Teams", description = "Manages the teams and related commands.", category = ModuleCategory.CORE, @@ -84,22 +89,17 @@ internal = true, can_be_unloaded = false ) -public class TeamsModule extends QSGModule -{ +public class TeamsModule extends QSGModule { private final String HEART = "\u2764"; + private final Map<UUID, SidebarPlayerCache> sidebarCache = new HashMap<>(); private double TEAMMATES_DISTANCE_SQUARED; - private GameModule game = null; - private final Map<UUID, SidebarPlayerCache> sidebarCache = new HashMap<>(); - - @Override - protected void onEnable() - { - ZLib.loadComponent(ZTeams.class); + protected void onEnable() { + QuartzLib.loadComponent(QuartzTeams.class); - ZTeams.settings() + QuartzTeams.settings() .setScoreboard(QuartzSurvivalGames.get().getScoreboard()) .setTeamsOptions( Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), @@ -120,19 +120,20 @@ protected void onEnable() ) .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_TEAM.get()); - TEAMMATES_DISTANCE_SQUARED = Math.pow(Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.DISPLAYED_WHEN_CLOSER_THAN.get(), 2d); + TEAMMATES_DISTANCE_SQUARED = + Math.pow(Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.DISPLAYED_WHEN_CLOSER_THAN.get(), 2d); } @EventHandler - public void onGameStarting(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.STARTING) return; - ZLib.registerEvents(new SidebarCacheListener()); + public void onGameStarting(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.STARTING) { + return; + } + QuartzLib.registerEvents(new SidebarCacheListener()); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList( TeamsCommand.class, TeamChatCommand.class, @@ -144,8 +145,7 @@ public List<Class<? extends Command>> getCommands() } @Override - public Map<String, Class<? extends Command>> getCommandsAliases() - { + public Map<String, Class<? extends Command>> getCommandsAliases() { return ImmutableMap.of( "t", TeamChatCommand.class, "g", GlobalChatCommand.class, @@ -156,46 +156,58 @@ public Map<String, Class<? extends Command>> getCommandsAliases() } @Override - public void injectIntoSidebar(final Player player, final SidebarInjector injector) - { - if (game == null) game = QSG.module(GameModule.class); - if (game == null) return; // Module not ready + public void injectIntoSidebar(final Player player, final SidebarInjector injector) { + if (game == null) { + game = QSG.module(GameModule.class); + } + if (game == null) { + return; // Module not ready + } - if (!game.isTeamsGame() || !Config.SIDEBAR.ENABLED.get() || game.getPhase().ordinal() < GamePhase.IN_GAME.ordinal()) + if (!game.isTeamsGame() || !Config.SIDEBAR.ENABLED.get() || + game.getPhase().ordinal() < GamePhase.IN_GAME.ordinal()) { return; + } - final ZTeam team = ZTeams.get().getTeamForPlayer(player); + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); - if (team == null) return; + if (team == null) { + return; + } /* *** TEAM NAME *** */ injector.injectLines( - true, false, - (Config.SIDEBAR.TITLE.COLOR.get().isEmpty() ? team.getColorOrWhite().toChatColor() : Config.SIDEBAR.TITLE.COLOR.get()) - + (Config.SIDEBAR.TITLE.USE_TEAM_NAME.get() ? ChatColor.BOLD + team.getName() : I.t("{bold}Your team")) + true, false, + (Config.SIDEBAR.TITLE.COLOR.get().isEmpty() ? team.getColorOrWhite().toChatColor() : + Config.SIDEBAR.TITLE.COLOR.get()) + + (Config.SIDEBAR.TITLE.USE_TEAM_NAME.get() ? ChatColor.BOLD + team.getName() : + I.t("{bold}Your team")) ); /* *** TEAM PLAYERS: WHICH ONES *** */ final Set<OfflinePlayer> displayedPlayers = new TreeSet<>((player1, player2) -> { - if (player1.equals(player2)) return 0; - if (game.isAlive(player1) != game.isAlive(player2)) return game.isAlive(player1) ? -1 : 1; + if (player1.equals(player2)) { + return 0; + } + if (game.isAlive(player1) != game.isAlive(player2)) { + return game.isAlive(player1) ? -1 : 1; + } return player1.getName().toLowerCase().compareTo(player2.getName().toLowerCase()); }); final SidebarPlayerCache playerCache = getSidebarPlayerCache(player.getUniqueId()); - if (Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.ENABLED.get()) - { + if (Config.SIDEBAR.CONTENT.DISPLAY_MET_PLAYERS_ONLY.ENABLED.get()) { playerCache.updateTeammatesDisplayed(TEAMMATES_DISTANCE_SQUARED, player.getLocation(), team); displayedPlayers.addAll(playerCache.getMetTeammates()); + } else { + displayedPlayers.addAll(team.getPlayers()); } - else displayedPlayers.addAll(team.getPlayers()); - /* *** TEAM PLAYERS: DISPLAY *** */ @@ -205,15 +217,20 @@ public void injectIntoSidebar(final Player player, final SidebarInjector injecto final SidebarPlayerCache cache = getSidebarPlayerCache(displayedPlayer.getUniqueId()); final boolean alive = game.isAlive(displayedPlayer); - final String strike = Config.SIDEBAR.CONTENT.STRIKE_DEAD_PLAYERS.get() && !alive ? ChatColor.STRIKETHROUGH.toString() : ""; + final String strike = + Config.SIDEBAR.CONTENT.STRIKE_DEAD_PLAYERS.get() && !alive ? ChatColor.STRIKETHROUGH.toString() : + ""; final ChatColor aliveColor = alive ? ChatColor.WHITE : ChatColor.GRAY; - final String heart = Config.SIDEBAR.CONTENT.DISPLAY_HEARTS.get() ? cache.getHealthColor() + strike + HEART + " " : ""; + final String heart = + Config.SIDEBAR.CONTENT.DISPLAY_HEARTS.get() ? cache.getHealthColor() + strike + HEART + " " : ""; final String name = (Config.SIDEBAR.CONTENT.COLOR_NAME.get() ? cache.getHealthColor() : aliveColor) + strike + (Config.SIDEBAR.CONTENT.LOGIN_STATE.ITALIC.get() && !cache.isOnline() ? ChatColor.ITALIC : "") + cache.getPlayerName() - + (!cache.isOnline() ? ChatColor.RESET + "" + (Config.SIDEBAR.CONTENT.COLOR_NAME.get() ? cache.getHealthColor() : aliveColor) + " " + Config.SIDEBAR.CONTENT.LOGIN_STATE.SUFFIX.get() : ""); + + (!cache.isOnline() ? ChatColor.RESET + "" + + (Config.SIDEBAR.CONTENT.COLOR_NAME.get() ? cache.getHealthColor() : aliveColor) + " " + + Config.SIDEBAR.CONTENT.LOGIN_STATE.SUFFIX.get() : ""); playersSidebar.add(heart + name); }); @@ -227,98 +244,104 @@ public void injectIntoSidebar(final Player player, final SidebarInjector injecto * @param id The player's UUID. * @return The cached data, created on the fly if needed. */ - public SidebarPlayerCache getSidebarPlayerCache(final UUID id) - { + public SidebarPlayerCache getSidebarPlayerCache(final UUID id) { return sidebarCache.computeIfAbsent(id, SidebarPlayerCache::new); } @EventHandler - public void onGameStart(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + public void onGameStart(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) { + return; + } - if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) - { + if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get() || Config.BANNER.GIVE.GIVE_ON_HEAD.get() || + Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) { RunTask.later(() -> - ZTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> - { - final ItemStack banner = team.getBanner(); - - team.getOnlinePlayers().forEach(player -> + QuartzTeams.get().getTeams().stream().filter(team -> !team.isEmpty()).forEach(team -> { - if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get()) - { - player.getInventory().setItem(8, banner.clone()); - } + final ItemStack banner = team.getBanner(); - if (Config.BANNER.GIVE.GIVE_ON_HEAD.get()) + team.getOnlinePlayers().forEach(player -> { - player.getInventory().setHelmet(banner.clone()); - } + if (Config.BANNER.GIVE.GIVE_IN_HOTBAR.get()) { + player.getInventory().setItem(8, banner.clone()); + } - if (Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) - { - final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); - final Block under = place.getRelative(BlockFace.DOWN); + if (Config.BANNER.GIVE.GIVE_ON_HEAD.get()) { + player.getInventory().setHelmet(banner.clone()); + } - // We don't want a stack of banners - if (under.getType() != Material.STANDING_BANNER) - { - if (!under.getType().isSolid()) - under.setType(Material.WOOD); + if (Config.BANNER.GIVE.PLACE_ON_SPAWN.get()) { + final Block place = player.getWorld().getHighestBlockAt(player.getLocation()); + final Block under = place.getRelative(BlockFace.DOWN); - place.setType(Material.STANDING_BANNER); + // We don't want a stack of banners + if (!under.getType().name().endsWith("_BANNER")) { + if (!under.getType().isSolid()) { + under.setType(Material.STRIPPED_OAK_WOOD); + } - Banner bannerBlock = (Banner) place.getState(); - BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); + place.setType(banner.getType()); - bannerBlock.setBaseColor(bannerMeta.getBaseColor()); - bannerBlock.setPatterns(bannerMeta.getPatterns()); + Banner bannerBlock = (Banner) place.getState(); + BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); - bannerBlock.update(); + bannerBlock.setPatterns(bannerMeta.getPatterns()); + + bannerBlock.update(); + } } - } - }); - }), 5L); + }); + }), 5L); } } /** * Adds the team banner on crafted shields. - * + * <p> * Done indirectly because the plugin must be able to run * on Minecraft 1.8. */ - @EventHandler (ignoreCancelled = true) - public void onShieldPreCraft(final PrepareItemCraftEvent ev) - { - if (!Config.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) return; + @EventHandler(ignoreCancelled = true) + public void onShieldPreCraft(final PrepareItemCraftEvent ev) { + if (!Config.BANNER.SHIELDS.ADD_ON_SHIELDS.get()) { + return; + } // The viewers list is empty for crafts from the small crafting // grid in the inventory. In this case we use another data source. - final Player player = !ev.getViewers().isEmpty() ? (Player) ev.getViewers().get(0) : (Player) ev.getView().getPlayer(); - if (player == null) return; + final Player player = + !ev.getViewers().isEmpty() ? (Player) ev.getViewers().get(0) : (Player) ev.getView().getPlayer(); + if (player == null) { + return; + } - final ZTeam team = ZTeams.get().getTeamForPlayer(player); - if (team == null || team.getBanner() == null) return; + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); + if (team == null || team.getBanner() == null) { + return; + } final Recipe recipe = ev.getRecipe(); - if (recipe == null) return; + if (recipe == null) { + return; + } final ItemStack result = recipe.getResult(); - if (result == null) return; + if (result == null) { + return; + } final Material MATERIAL_SHIELD = Material.getMaterial("SHIELD"); - if (MATERIAL_SHIELD == null) return; // MC 1.8 + if (MATERIAL_SHIELD == null) { + return; // MC 1.8 + } - if (result.getType() == MATERIAL_SHIELD) - { - try - { + if (result.getType() == MATERIAL_SHIELD) { + try { final BannerMeta banner = (BannerMeta) team.getBanner().getItemMeta(); final BlockStateMeta bsMeta = (BlockStateMeta) result.getItemMeta(); - final Banner shieldBanner = (Banner) bsMeta.getBlockState(); + final Banner shieldBanner = (Banner) bsMeta.getBlockState(); shieldBanner.setBaseColor(banner.getBaseColor()); shieldBanner.setPatterns(banner.getPatterns()); @@ -330,22 +353,18 @@ public void onShieldPreCraft(final PrepareItemCraftEvent ev) ev.getInventory().setResult(result); } - catch (ClassCastException | NullPointerException ignored) - { + catch (ClassCastException | NullPointerException ignored) { // Bad Minecraft version (1.8) } } } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { // Disables the team-chat-lock if needed - if (Config.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) - { - if (ZTeams.chatManager().isTeamChatEnabled(ev.getPlayer().getUniqueId())) - { - ZTeams.chatManager().toggleChatForPlayer(ev.getPlayer().getUniqueId()); + if (Config.TEAM_CHAT.DISABLE_LOCK_ON_DEATH.get()) { + if (QuartzTeams.chatManager().isTeamChatEnabled(ev.getPlayer().getUniqueId())) { + QuartzTeams.chatManager().toggleChatForPlayer(ev.getPlayer().getUniqueId()); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java index 4ced7fb..6a07532 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarCacheListener.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -48,14 +49,12 @@ import org.bukkit.event.player.PlayerQuitEvent; -public class SidebarCacheListener implements Listener -{ +public class SidebarCacheListener implements Listener { private final static GameModule game = QSG.module(GameModule.class); private final static TeamsModule teams = QSG.module(TeamsModule.class); @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent ev) - { + public void onPlayerJoin(PlayerJoinEvent ev) { final SidebarPlayerCache cache = teams.getSidebarPlayerCache(ev.getPlayer().getUniqueId()); cache.updateName(ev.getPlayer().getName()); @@ -66,52 +65,48 @@ public void onPlayerJoin(PlayerJoinEvent ev) } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerQuitEvent ev) - { + public void onPlayerQuit(PlayerQuitEvent ev) { onPlayerQuit(ev.getPlayer()); } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerKickEvent ev) - { + public void onPlayerQuit(PlayerKickEvent ev) { onPlayerQuit(ev.getPlayer()); } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerRegainHealth(EntityRegainHealthEvent ev) - { - if (ev.getEntity() instanceof Player) + public void onPlayerRegainHealth(EntityRegainHealthEvent ev) { + if (ev.getEntity() instanceof Player) { onPlayerHealthChange((Player) ev.getEntity()); + } } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLoseHealth(EntityDamageEvent ev) - { - if (ev.getEntity() instanceof Player) + public void onPlayerLoseHealth(EntityDamageEvent ev) { + if (ev.getEntity() instanceof Player) { onPlayerHealthChange((Player) ev.getEntity()); + } } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerDeath(AlivePlayerDeathEvent ev) - { - if (ev.getPlayer().isOnline()) + public void onPlayerDeath(AlivePlayerDeathEvent ev) { + if (ev.getPlayer().isOnline()) { onPlayerHealthChange(ev.getPlayer().getPlayer()); + } } @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerResurrect(PlayerResurrectedEvent ev) - { - if (ev.getPlayer().isOnline()) + public void onPlayerResurrect(PlayerResurrectedEvent ev) { + if (ev.getPlayer().isOnline()) { onPlayerHealthChange(ev.getPlayer().getPlayer()); + } } - private void onPlayerQuit(Player player) - { + private void onPlayerQuit(Player player) { teams.getSidebarPlayerCache(player.getUniqueId()).updateOnlineStatus(false); } - private void onPlayerHealthChange(final Player player) - { + private void onPlayerHealthChange(final Player player) { // One tick later to use the updated health value. RunTask.nextTick(() -> { final SidebarPlayerCache cache = teams.getSidebarPlayerCache(player.getUniqueId()); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java index f3378c2..a375ffb 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/sidebar/SidebarPlayerCache.java @@ -29,102 +29,91 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.sidebar; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; import java.util.HashSet; import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; /** * This class stores the data displayed in the sidebar for a player, like the color, the health, the name... */ -public class SidebarPlayerCache -{ - private UUID playerID; - +public class SidebarPlayerCache { + private final Set<UUID> metTeammates = new HashSet<>(); + private final UUID playerID; private String playerName; private ChatColor healthColor = ChatColor.WHITE; - private boolean isOnline; - private final Set<UUID> metTeammates = new HashSet<>(); - - public SidebarPlayerCache(final UUID id) - { + public SidebarPlayerCache(final UUID id) { playerID = id; final OfflinePlayer player = Bukkit.getOfflinePlayer(id); - if (player != null) - { + if (player != null) { playerName = player.getName(); isOnline = player.isOnline(); - if (isOnline) + if (isOnline) { updateHealth(player.getPlayer().getHealth()); - } - else - { + } + } else { playerName = null; isOnline = false; } } - public void updateName(String name) - { + public void updateName(String name) { playerName = name; } - public void updateHealth(double health) - { - if (health <= 0) + public void updateHealth(double health) { + if (health <= 0) { healthColor = ChatColor.GRAY; - else if (health <= 4.1) + } else if (health <= 4.1) { healthColor = ChatColor.DARK_RED; - else if (health <= 8.1) + } else if (health <= 8.1) { healthColor = ChatColor.RED; - else if (health <= 12.1) + } else if (health <= 12.1) { healthColor = ChatColor.YELLOW; - else if (health <= 16.1) + } else if (health <= 16.1) { healthColor = ChatColor.GREEN; - else + } else { healthColor = ChatColor.DARK_GREEN; + } } - public void updateOnlineStatus(boolean isOnline) - { + public void updateOnlineStatus(boolean isOnline) { this.isOnline = isOnline; } - public UUID getPlayerID() - { + public UUID getPlayerID() { return playerID; } - public String getPlayerName() - { - if (playerName != null && !playerName.isEmpty()) + public String getPlayerName() { + if (playerName != null && !playerName.isEmpty()) { return playerName; + } final OfflinePlayer player = OfflinePlayersLoader.getOfflinePlayer(playerID); - if (player != null && player.getName() != null && !player.getName().isEmpty()) - { + if (player != null && player.getName() != null && !player.getName().isEmpty()) { playerName = player.getName(); return playerName; } @@ -133,52 +122,53 @@ public String getPlayerName() return I.t("Unknown"); } - public ChatColor getHealthColor() - { + public ChatColor getHealthColor() { return healthColor; } - public boolean isOnline() - { + public boolean isOnline() { return isOnline; } - public Set<OfflinePlayer> getMetTeammates() - { + public Set<OfflinePlayer> getMetTeammates() { return metTeammates.stream() .map(Bukkit::getOfflinePlayer) .filter(Objects::nonNull) .collect(Collectors.toSet()); } - public void updateTeammatesDisplayed(final double distanceThreshold) - { + public void updateTeammatesDisplayed(final double distanceThreshold) { final Player player = Bukkit.getPlayer(playerID); - if (player != null) - { + if (player != null) { updateTeammatesDisplayed( distanceThreshold * distanceThreshold, player.getLocation(), - ZTeams.get().getTeamForPlayer(playerID) + QuartzTeams.get().getTeamForPlayer(playerID) ); } } - public void updateTeammatesDisplayed(final double distanceThresholdSquared, final Location reference, final ZTeam team) - { + public void updateTeammatesDisplayed(final double distanceThresholdSquared, final Location reference, + final QuartzTeam team) { final GameModule game = QSG.module(GameModule.class); // For each non-encountered online teammate, we check if they are close team.getOnlinePlayers().stream() - .filter(p -> !metTeammates.contains(p.getUniqueId())) - .filter(game::isAlive) - .forEach(p -> { - if (p.getWorld() == null) return; - if (!p.getWorld().equals(reference.getWorld())) return; - if (p.getLocation().distanceSquared(reference) > distanceThresholdSquared) return; - - // Close enough - metTeammates.add(p.getUniqueId()); - }); + .filter(p -> !metTeammates.contains(p.getUniqueId())) + .filter(game::isAlive) + .forEach(p -> { + if (p.getWorld() == null) { + return; + } + if (!p.getWorld().equals(reference.getWorld())) { + return; + } + if (p.getLocation().distanceSquared(reference) > distanceThresholdSquared) { + return; + } + + // Close enough + metTeammates.add(p.getUniqueId()); + }); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java index 1d718c1..811c2f4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java @@ -52,7 +52,7 @@ name = "Timers", description = "The timekeeper of the whole UHCReloaded plugin & companions.", category = ModuleCategory.CORE, - icon = Material.WATCH, + icon = Material.CLOCK, internal = true, can_be_unloaded = false ) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java index cf1b3df..6f7603b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java @@ -68,7 +68,7 @@ description = "Displays time marks every 20 minutes (by default), e.g. to divide a recording for diffusion.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.COSMETICS, - icon = Material.SIGN, + icon = Material.BIRCH_SIGN, settings = Config.class, can_be_loaded_late = false ) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java index 1ea67aa..61af776 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -37,7 +37,7 @@ import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import org.bukkit.Material; @@ -46,7 +46,7 @@ description = "Replaces hearts with hardcore hearts.", depends = "ProtocolLib", category = ModuleCategory.COSMETICS, - icon = Material.RED_ROSE, // FIXME 1.13 + icon = Material.WITHER_ROSE, settings = Config.class ) public class HardcoreHeartsModule extends QSGModule @@ -63,7 +63,7 @@ protected void onEnable() if (Config.AUTO_RESPAWN.DO.get()) { - ZLib.registerEvents(packetsListener); + QuartzLib.registerEvents(packetsListener); } log().info("Successfully hooked into ProtocolLib."); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java index 46f1fb8..167f2ea 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -46,7 +46,7 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.ListHeaderFooter; -import fr.zcraft.zteams.events.*; +import fr.zcraft.quartzteams.events.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java index 6969879..d7eea15 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/EndAnnouncementModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,49 +43,45 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.Titles; -import fr.zcraft.zteams.ZTeam; +import fr.zcraft.quartzteams.QuartzTeam; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -@ModuleInfo ( +@ModuleInfo( name = "End Announcement", description = "Announces the winner's name to the whole server when the game ends.", when = ModuleLoadTime.ON_GAME_END, category = ModuleCategory.END, icon = Material.ITEM_FRAME ) -public class EndAnnouncementModule extends QSGModule -{ +public class EndAnnouncementModule extends QSGModule { @Override - protected void onEnable() - { + protected void onEnable() { RunTask.later(() -> { - if (QSG.game().getPhase() != GamePhase.END) return; + if (QSG.game().getPhase() != GamePhase.END) { + return; + } - final ZTeam winnerTeam = QSG.game().getWinner(); + final QuartzTeam winnerTeam = QSG.game().getWinner(); - if (winnerTeam == null) return; // No winner + if (winnerTeam == null) { + return; // No winner + } Bukkit.broadcastMessage(""); - if (QSG.game().isTeamsGame()) - { + if (QSG.game().isTeamsGame()) { final StringBuilder winners = new StringBuilder(); int j = 0; - for (final OfflinePlayer winner : winnerTeam.getPlayers()) - { - if (j != 0) - { - if (j == winnerTeam.size() - 1) - { + for (final OfflinePlayer winner : winnerTeam.getPlayers()) { + if (j != 0) { + if (j == winnerTeam.size() - 1) { /// The "and" in the winners players list (like "player1, player2 and player3"). winners.append(" ").append(I.tc("winners_list", "and")).append(" "); - } - else - { + } else { winners.append(", "); } } @@ -93,11 +90,13 @@ protected void onEnable() j++; } - Bukkit.broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", winners.toString(), winnerTeam.getDisplayName())); - } - else - { - Bukkit.broadcastMessage(I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", winnerTeam.getName())); + Bukkit.broadcastMessage( + I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} (team {1}{green}) for their victory! {darkgreen}{obfuscated}--", + winners.toString(), winnerTeam.getDisplayName())); + } else { + Bukkit.broadcastMessage( + I.t("{darkgreen}{obfuscated}--{green} Congratulations to {0} for his victory! {darkgreen}{obfuscated}--", + winnerTeam.getName())); } Bukkit.broadcastMessage(""); @@ -106,15 +105,12 @@ protected void onEnable() final String title; final String subtitle; - if (QSG.game().isTeamsGame()) - { + if (QSG.game().isTeamsGame()) { /// The main title of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); /// The subtitle of the /title displayed when a team wins the game. {0} becomes the team display name (with colors). subtitle = I.t("{green}This team wins the game!", winnerTeam.getDisplayName()); - } - else - { + } else { /// The main title of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). title = I.t("{darkgreen}{0}", winnerTeam.getDisplayName()); /// The subtitle of the /title displayed when a player wins the game (in solo). {0} becomes the player display name (with colors). diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java index d73549a..578aa64 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/FireworksModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -48,32 +49,33 @@ import org.bukkit.scheduler.BukkitRunnable; -@ModuleInfo ( +@ModuleInfo( name = "Fireworks", description = "When the game ends, this module sends some fireworks from the winners o/", when = ModuleLoadTime.ON_GAME_END, category = ModuleCategory.END, - icon = Material.FIREWORK + icon = Material.FIREWORK_ROCKET ) -public class FireworksModule extends QSGModule -{ +public class FireworksModule extends QSGModule { private final int area = 6; // Fireworks launched on a 6×6 area around the winners private final TimeDelta duration = new TimeDelta(10); @Override - protected void onEnable() - { + protected void onEnable() { RunTask.later(() -> { - if (QSG.game().getPhase() != GamePhase.END) return; + if (QSG.game().getPhase() != GamePhase.END) { + return; + } final long start = System.currentTimeMillis(); RunTask.timer(new BukkitRunnable() { @Override - public void run() - { - if (QSG.game().getWinner() == null) return; + public void run() { + if (QSG.game().getWinner() == null) { + return; + } QSG.game().getWinner().getOnlinePlayers().forEach(winner -> { @@ -94,8 +96,7 @@ public void run() QSGUtils.generateRandomFirework(fireworkLocation.add(4, 0, 4), 5, 15); }); - if ((System.currentTimeMillis() - start) / 1000 > duration.getSeconds()) - { + if ((System.currentTimeMillis() - start) / 1000 > duration.getSeconds()) { cancel(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java index 51018c4..4e0182e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java @@ -31,28 +31,24 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.deathAnnouncement; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import eu.carrade.amaury.quartzsurvivalgames.utils.QSGSound; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Boolean> NOTIFY_IF_TEAM_HAS_FALLEN = item("notify-if-team-has-fallen", true); public static final ConfigurationItem<String> DEATH_MESSAGES_FORMAT = item("death-messages-format", "§6"); public static final ConfigurationItem<String> TEAM_DEATH_MESSAGES_FORMAT = item("team-death-messages-format", "§6"); - public static final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); public static final ConfigurationItem<Boolean> PLAY_SOUND = item("play-sound", true); public static final ConfigurationItem<QSGSound> SOUND = item("sound", new QSGSound("ENTITY_WITHER_SPAWN")); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java index 649f5aa..a0aa8e8 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/DeathAnnouncementModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.deathAnnouncement; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -45,8 +46,8 @@ import fr.zcraft.quartzlib.components.rawtext.RawTextPart; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.RawMessage; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -54,7 +55,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; -@ModuleInfo ( +@ModuleInfo( name = "Death Announcements", description = "Adds announcements for players & teams deaths.", when = ModuleLoadTime.ON_GAME_START, @@ -62,73 +63,67 @@ icon = Material.BLAZE_ROD, settings = Config.class ) -public class DeathAnnouncementModule extends QSGModule -{ +public class DeathAnnouncementModule extends QSGModule { private QSGSound deathSound; @Override - protected void onEnable() - { + protected void onEnable() { deathSound = Config.SOUND.get(); } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { final PlayerDeathEvent pdev = ev.getPlayerDeathEvent(); // Highlights the death message in the console - Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "-- Death of " + ev.getPlayer().getName() + (pdev != null ? " (" + pdev.getDeathMessage() + ")" : "") + " --"); + Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "-- Death of " + ev.getPlayer().getName() + + (pdev != null ? " (" + pdev.getDeathMessage() + ")" : "") + " --"); // If this is a real death - if (pdev != null) - { + if (pdev != null) { // We send a lightning strike. - if (Config.LIGHTNING_STRIKE.get()) - { + if (Config.LIGHTNING_STRIKE.get()) { pdev.getEntity().getLocation().getWorld().strikeLightningEffect(pdev.getEntity().getLocation()); } } // If it is a death of an offline player - else - { - Bukkit.broadcastMessage(colorizePlayerInString(I.t("{0} died, following a game master's order.", ev.getPlayer().getName()), ev.getPlayer())); + else { + Bukkit.broadcastMessage( + colorizePlayerInString(I.t("{0} died, following a game master's order.", ev.getPlayer().getName()), + ev.getPlayer())); } // Play sound - if (Config.PLAY_SOUND.get()) - { + if (Config.PLAY_SOUND.get()) { deathSound.broadcast(); } } @EventHandler - public void onTeamDeath(final TeamDeathEvent ev) - { - if (Config.NOTIFY_IF_TEAM_HAS_FALLEN.get()) - { + public void onTeamDeath(final TeamDeathEvent ev) { + if (Config.NOTIFY_IF_TEAM_HAS_FALLEN.get()) { // Used to display this message after the death message. RunTask.later(() -> { - final ZTeam team = ev.getTeam(); - final String format = ChatColor.translateAlternateColorCodes('&', Config.TEAM_DEATH_MESSAGES_FORMAT.get()); + final QuartzTeam team = ev.getTeam(); + final String format = + ChatColor.translateAlternateColorCodes('&', Config.TEAM_DEATH_MESSAGES_FORMAT.get()); final RawTextPart<?> teamTooltip = new RawText() .then(team.getName()).style(team.getColorOrWhite().toChatColor(), ChatColor.BOLD); - for (final OfflinePlayer player : team.getPlayers()) - { + for (final OfflinePlayer player : team.getPlayers()) { teamTooltip.then("\n") .then("- ").color(ChatColor.GRAY) .then(player.getName()).color(ChatColor.WHITE); } RawMessage.broadcast( - new RawText(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)) - .hover(teamTooltip) + new RawText(I.t("{0}The team {1} has fallen!", format, team.getDisplayName() + format)) + .hover(teamTooltip) ); }, 1L); } @@ -138,22 +133,22 @@ public void onTeamDeath(final TeamDeathEvent ev) * Colorizes each instance of the given player name in the string with its team color, * if the player is in a team. * - * @param str The string to colorize. + * @param str The string to colorize. * @param player The player to look for in the string. * @return The colorized string. */ - private String colorizePlayerInString(final String str, final OfflinePlayer player) - { - final ZTeam team = ZTeams.get().getTeamForPlayer(player); - if (team == null) return str; + private String colorizePlayerInString(final String str, final OfflinePlayer player) { + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); + if (team == null) { + return str; + } // We split the name to recompose the string with the colored name in each hole final String[] strParts = str.split(player.getName()); final ChatColor color = team.getColorOrWhite().toChatColor(); final StringBuilder colorizedStr = new StringBuilder(); - for (int i = 0; i < strParts.length; i++) - { + for (int i = 0; i < strParts.length; i++) { colorizedStr.append(strParts[i]); if (i != strParts.length - 1) // If not the last one diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java index debe2fa..fa332b4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java @@ -31,24 +31,21 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.kick; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.i18n.I; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<TimeDelta> DELAY = item("delay", new TimeDelta(30)); static public final ConfigurationItem<String> MESSAGE = item("message", I.t("jayjay")); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java index f6fa413..c60102c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/KickModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.kick; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,7 +43,7 @@ import org.bukkit.Material; import org.bukkit.event.EventHandler; -@ModuleInfo ( +@ModuleInfo( name = "Kick On Death", description = "Kicks players on death after a delay.", when = ModuleLoadTime.ON_GAME_START, @@ -50,14 +51,12 @@ icon = Material.BARRIER, settings = Config.class ) -public class KickModule extends QSGModule -{ +public class KickModule extends QSGModule { @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (ev.getPlayer().isOnline()) - { - RunTask.later(() -> ev.getPlayer().getPlayer().kickPlayer(Config.MESSAGE.get()), Config.DELAY.get().getSeconds() * 20L); + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (ev.getPlayer().isOnline()) { + RunTask.later(() -> ev.getPlayer().getPlayer().kickPlayer(Config.MESSAGE.get()), + Config.DELAY.get().getSeconds() * 20L); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java index 4029b15..2b0e5ea 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java @@ -31,22 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.xpToKillers; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Integer> LEVELS = item("levels", 2); public static final ConfigurationItem<Boolean> ONLY_OTHER_TEAM = item("only-other-team", true); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java index 267a417..54f9e41 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/XpToKillersModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.end.xpToKillers; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -38,37 +39,35 @@ import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.AlivePlayerDeathEvent; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; +import java.util.Objects; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import java.util.Objects; - -@ModuleInfo ( +@ModuleInfo( name = "XP to Killers", description = "Gives a configurable amount of XP levels on player kill " + "(optionally only for different team).", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.END, - icon = Material.EXP_BOTTLE, + icon = Material.EXPERIENCE_BOTTLE, settings = Config.class ) -public class XpToKillersModule extends QSGModule -{ +public class XpToKillersModule extends QSGModule { @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (!ev.getPlayer().isOnline()) return; + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (!ev.getPlayer().isOnline()) { + return; + } final Player killer = ev.getPlayer().getPlayer().getKiller(); - if (killer != null) - { - boolean inSameTeam = Objects.equals(ZTeams.get().getTeamForPlayer(ev.getPlayer()), ZTeams.get().getTeamForPlayer(killer)); + if (killer != null) { + boolean inSameTeam = Objects.equals(QuartzTeams.get().getTeamForPlayer(ev.getPlayer()), + QuartzTeams.get().getTeamForPlayer(killer)); boolean onlyOtherTeam = Config.ONLY_OTHER_TEAM.get(); - if (!onlyOtherTeam || !inSameTeam) - { + if (!onlyOtherTeam || !inSameTeam) { killer.giveExpLevels(Config.LEVELS.get()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java index 67471c2..9f113a5 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java @@ -43,10 +43,10 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.colors.TeamColor; +import fr.zcraft.quartzlib.core.QuartzLib; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.colors.TeamColor; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -86,7 +86,7 @@ protected void onEnable() if (markerAPI == null) { log().warning("Dynmap is available, but the markers API is not. The integration was disabled."); - ZLib.unregisterEvents(this); + QuartzLib.unregisterEvents(this); return; } @@ -195,7 +195,7 @@ public void showSpawnLocation(final OfflinePlayer player, final Location spawnPo if (!Config.SHOW_SPAWN_LOCATIONS.get()) return; if (player == null) return; - final ZTeam team = ZTeams.get().getTeamForPlayer(player); + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); if (team == null) return; final String markerLabel; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java index f09d5ce..14739d4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java @@ -33,20 +33,20 @@ */ package eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; -import org.bukkit.Material; -import org.bukkit.Statistic; - import java.io.File; import java.util.Arrays; import java.util.List; +import org.bukkit.Material; +import org.bukkit.Statistic; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; - +@SuppressWarnings("CheckStyle") public class Config extends ConfigurationInstance { public Config(File file) @@ -124,9 +124,9 @@ static public List<Material> defaultUsedHighlight() Material.DIAMOND_SWORD, Material.DIAMOND_AXE, Material.DIAMOND_PICKAXE, Material.DIAMOND_HOE, Material.IRON_SWORD, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_HOE, Material.CAKE, Material.SADDLE, Material.GOLDEN_APPLE, Material.POTION, - Material.GOLD_RECORD, Material.GREEN_RECORD, Material.RECORD_3, Material.RECORD_4, - Material.RECORD_5, Material.RECORD_6, Material.RECORD_7, Material.RECORD_8, - Material.RECORD_9, Material.RECORD_10, Material.RECORD_11, Material.RECORD_12 + Material.MUSIC_DISC_11, Material.MUSIC_DISC_13, Material.MUSIC_DISC_BLOCKS, Material.MUSIC_DISC_CAT, + Material.MUSIC_DISC_CHIRP, Material.MUSIC_DISC_FAR, Material.MUSIC_DISC_MALL, Material.MUSIC_DISC_MELLOHI, + Material.MUSIC_DISC_STAL, Material.MUSIC_DISC_STRAD, Material.MUSIC_DISC_WAIT, Material.MUSIC_DISC_WARD ); } @@ -137,8 +137,8 @@ static public List<Material> defaultMinedHighlight() Material.GOLD_INGOT, Material.GOLD_ORE, Material.IRON_INGOT, Material.IRON_ORE, Material.EMERALD, Material.EMERALD_ORE, - Material.OBSIDIAN, Material.NETHER_WARTS, - Material.MOB_SPAWNER, Material.STONE + Material.OBSIDIAN, Material.NETHER_WART, + Material.SPAWNER, Material.STONE ); } @@ -147,7 +147,8 @@ static public List<Material> defaultPickedUpHighlight() return Arrays.asList( Material.APPLE, Material.BOW, Material.ENDER_PEARL, Material.GOLD_INGOT, - Material.SKULL_ITEM + Material.PLAYER_HEAD, Material.CREEPER_HEAD, Material.DRAGON_HEAD, + Material.ZOMBIE_HEAD, Material.SKELETON_SKULL, Material.WITHER_SKELETON_SKULL ); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java index f0469b3..45d9378 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java @@ -56,9 +56,9 @@ import fr.zcraft.quartzlib.tools.reflection.Reflection; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.RawMessage; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.events.*; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.events.*; import me.cassayre.florian.hawk.ReportsManager; import me.cassayre.florian.hawk.report.InvalidReportException; import me.cassayre.florian.hawk.report.Report; @@ -94,7 +94,7 @@ authors = "Florian Cassayre & Amaury Carrade through the Hawk Project", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.EXTERNAL, - icon = Material.BOOK_AND_QUILL, + icon = Material.KNOWLEDGE_BOOK, settings = Config.class, can_be_unloaded = false ) @@ -231,7 +231,7 @@ private void updateReportTeams() if (game.isTeamsGame()) { - ZTeams.get().getTeams().stream() + QuartzTeams.get().getTeams().stream() .map(team -> new ReportTeam(team.getName(), team.getColor() != null ? team.getColor().toChatColor() : null, team.getPlayers())) .forEach(report::registerTeam); } @@ -242,7 +242,7 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { if (ev.getNewPhase() == GamePhase.END) { - final ZTeam winner = game.getWinner(); + final QuartzTeam winner = game.getWinner(); if (winner != null) report.setWinners(winner.getPlayers()); waitingAfterEnd = true; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java index 55f2121..d6e2318 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java @@ -40,7 +40,7 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; +import fr.zcraft.quartzteams.QuartzTeam; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -51,7 +51,7 @@ name = "MOTD", description = "Updates the MOTD according to the current game state.", category = ModuleCategory.EXTERNAL, - icon = Material.SIGN, + icon = Material.DARK_OAK_SIGN, settings = Config.class ) public class MotdModule extends QSGModule @@ -95,7 +95,7 @@ private String getMOTD() case END: default: - final ZTeam winner = game.getWinner(); + final QuartzTeam winner = game.getWinner(); if (game.isTeamsGame()) { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java index 2ddad42..ab58833 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java @@ -51,12 +51,12 @@ description = "Changes the vanilla recipe for glistering melon, replacing gold nuggets by gold ingots, to make healing potions harder to get.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.SPECKLED_MELON // FIXME 1.13 + icon = Material.GLISTERING_MELON_SLICE // FIXME 1.13 ) public class OnerousGlisteringMelon extends QSGModule { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( - new ItemStack(Material.SPECKLED_MELON), + new ItemStack(Material.GLISTERING_MELON_SLICE), "AAA", "ABA", "AAA", @@ -64,7 +64,7 @@ public class OnerousGlisteringMelon extends QSGModule ); private final Recipe ONEROUS_RECIPE = CraftingRecipes.shaped( - new ItemStack(Material.SPECKLED_MELON), + new ItemStack(Material.GLISTERING_MELON_SLICE), "AAA", "ABA", "AAA", diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java index c0cef49..806d05f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java @@ -44,10 +44,10 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.i18n.I18n; import fr.zcraft.quartzlib.components.rawtext.RawText; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.MessageSender; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; import org.apache.commons.lang.math.RandomUtils; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -81,7 +81,7 @@ public class CompassModule extends QSGModule @Override public void onEnable() { - recipes = ZLib.loadComponent(CompassRecipes.class); + recipes = QuartzLib.loadComponent(CompassRecipes.class); } @Override @@ -89,7 +89,7 @@ protected void onDisable() { if (recipes != null) { - ZLib.unregisterEvents(recipes); + QuartzLib.unregisterEvents(recipes); recipes = null; } } @@ -190,7 +190,7 @@ private boolean activateCompass(final Player compassUser) { distance = calc; - if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(ZTeams.get().getTeamForPlayer(compassUser), ZTeams.get().getTeamForPlayer(otherPlayer)))) + if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(QuartzTeams.get().getTeamForPlayer(compassUser), QuartzTeams.get().getTeamForPlayer(otherPlayer)))) { nearest = otherPlayer.getPlayer(); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java index 8314dd6..386d48c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java @@ -34,7 +34,7 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; import eu.carrade.amaury.quartzsurvivalgames.utils.RecipesUtils; -import fr.zcraft.quartzlib.core.ZLibComponent; +import fr.zcraft.quartzlib.core.QuartzComponent; import fr.zcraft.quartzlib.tools.items.CraftingRecipes; import fr.zcraft.quartzlib.tools.runners.RunTask; import org.bukkit.Material; @@ -53,7 +53,7 @@ import java.util.ArrayList; -public class CompassRecipes extends ZLibComponent implements Listener +public class CompassRecipes extends QuartzComponent implements Listener { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( new ItemStack(Material.COMPASS), @@ -132,7 +132,7 @@ public boolean isValidCompassRecipe(final ItemStack[] matrix) return corners.contains(Material.BONE) && corners.contains(Material.ROTTEN_FLESH) && corners.contains(Material.SPIDER_EYE) - && corners.contains(Material.SULPHUR); + && corners.contains(Material.GUNPOWDER); } private Material getCentralIngredient() @@ -143,7 +143,7 @@ private Material getCentralIngredient() return Material.ENDER_PEARL; case HARD: - return Material.EYE_OF_ENDER; + return Material.ENDER_EYE; default: return Material.REDSTONE; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java index 27964f5..2106f4a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java @@ -54,7 +54,7 @@ name = "Daylight Cycle", description = "Configures the daylight cycle (disabled, slowed down, normal, accelerated) and the initial time.", category = ModuleCategory.GAMEPLAY, - icon = Material.WATCH, + icon = Material.CLOCK, settings = Config.class ) public class DaylightCycleModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java index bd210c0..3676cf6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -122,10 +122,7 @@ private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted goldenAppleFromHeadRecipe.shape("GGG", "GHG", "GGG"); goldenAppleFromHeadRecipe.setIngredient('G', enchanted ? Material.GOLD_BLOCK : Material.GOLD_INGOT); - - // TODO: deprecated, but no alternative found... - // FIXME 1.13 - goldenAppleFromHeadRecipe.setIngredient('H', Material.SKULL_ITEM, player ? SkullType.PLAYER.ordinal() : SkullType.WITHER.ordinal()); + goldenAppleFromHeadRecipe.setIngredient('H', player ? Material.PLAYER_HEAD : Material.WITHER_SKELETON_SKULL); return goldenAppleFromHeadRecipe; } @@ -161,6 +158,8 @@ private void writeHeadType(final ItemStack stack, final SkullType type) * if it's a regular golden apple, a Wither golden head or a Player golden * head. * + * TODO replace SkullType with Material + * * @param stack The ItemStack to analyze. * @return Either {@link SkullType#PLAYER} (Player golden head), * {@link SkullType#WITHER} (Wither golden head) or {@code null} (regular @@ -190,9 +189,9 @@ public void onPreCraft(final PrepareItemCraftEvent ev) /* *** We remove these recipes if disabled *** */ final ItemStack result = ev.getInventory().getResult(); - if (result == null || (result.getType() != Material.GOLDEN_APPLE /* && result.getType() != Material.ENCHANTED_GOLDEN_APPLE FIXME 1.13 */)) return; + if (result == null || (result.getType() != Material.GOLDEN_APPLE && result.getType() != Material.ENCHANTED_GOLDEN_APPLE)) return; - final boolean isEnchanted = result.getData().getData() == 1; + final boolean isEnchanted = result.getType() == Material.ENCHANTED_GOLDEN_APPLE; if ((!Config.GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && !isEnchanted) || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && isEnchanted)) @@ -223,12 +222,12 @@ else if (headType == SkullType.PLAYER && for (final ItemStack item : ev.getInventory().getContents()) { // An human head - if (item.getType() == Material.SKULL_ITEM && item.getDurability() == (short) SkullType.PLAYER.ordinal()) + if (item.getType() == Material.PLAYER_HEAD) { SkullMeta sm = (SkullMeta) item.getItemMeta(); if (sm.hasOwner()) // An human head { - name = sm.getOwner(); + name = sm.getOwningPlayer() != null ? sm.getOwningPlayer().getName() : null; } break; } @@ -282,8 +281,7 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) { if (Config.DROP_HEAD_ON_DEATH.get() && ev.getPlayer().isOnline() && (!Config.DROP_HEAD_ON_DEATH_PVP_ONLY.get() || ev.getPlayer().getPlayer().getKiller() != null)) { - final ItemStackBuilder headBuilder = new ItemStackBuilder(Material.SKULL_ITEM) - .data((short) 3) + final ItemStackBuilder headBuilder = new ItemStackBuilder(Material.PLAYER_HEAD) .title(ChatColor.AQUA, I.t("{0}'s head", ev.getPlayer().getName())); if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get() || Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) @@ -291,10 +289,11 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) headBuilder.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Old legends tell how the heads of the brave fallen warriors can become, through a rich and complex transformation, a precious healing balm..."), 38); } + // TODO update with QLib 0.1's ISB final ItemStack head = headBuilder.item(); final SkullMeta meta = (SkullMeta) head.getItemMeta(); - meta.setOwner(ev.getPlayer().getName()); + meta.setOwningPlayer(ev.getPlayer()); head.setItemMeta(meta); ItemUtils.dropNaturally(ev.getPlayer().getPlayer().getLocation(), head); @@ -308,13 +307,13 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) @EventHandler public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) { - if (ev.getItem().getType() == Material.GOLDEN_APPLE) // FIXME 1.13 + if (ev.getItem().getType() == Material.GOLDEN_APPLE || ev.getItem().getType() == Material.ENCHANTED_GOLDEN_APPLE) { final SkullType headType = readHeadType(ev.getItem()); - final short dataValue = ev.getItem().getDurability(); + final boolean isEnchanted = ev.getItem().getType() == Material.ENCHANTED_GOLDEN_APPLE; - final int halfHearts = getRegenerationFor(headType, dataValue == 1); - final int level = dataValue == 0 ? REGENERATION_LEVEL_GOLDEN_APPLE : REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE; + final int halfHearts = getRegenerationFor(headType, isEnchanted); + final int level = isEnchanted ? REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE : REGENERATION_LEVEL_GOLDEN_APPLE; // Technically, a level-I effect is « level 0 ». @@ -322,15 +321,15 @@ public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) // What is needed to do? - if ((dataValue == 0 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (dataValue == 1 && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) + if ((!isEnchanted && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN) + || (isEnchanted && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) { // Default behavior, nothing to do. return; } - if ((dataValue == 0 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (dataValue == 1 && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) + if ((!isEnchanted && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) + || (isEnchanted && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) { // If the heal needs to be increased, the effect can be applied immediately. diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java index 8cf9ad2..1ad60dd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java @@ -71,7 +71,7 @@ public void run() if (Config.DISABLE_EXTENDED.get()) forbiddenIngredients.add(Material.REDSTONE); if (Config.DISABLE_LEVEL_II.get()) forbiddenIngredients.add(Material.GLOWSTONE_DUST); - if (Config.DISABLE_SPLASH.get()) forbiddenIngredients.add(Material.SULPHUR); + if (Config.DISABLE_SPLASH.get()) forbiddenIngredients.add(Material.GUNPOWDER); if (Config.DISABLE_LINGERING.get()) { // 1.9 - 1.12 diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java index d87ec66..0b7893d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java @@ -51,7 +51,7 @@ "splash or lingering potions.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.BREWING_STAND_ITEM, + icon = Material.BREWING_STAND, settings = Config.class ) public class PotionsModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java index dba4820..f6bc779 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java @@ -55,7 +55,7 @@ description = "Manages the in-game weather.", settings = Config.class, category = ModuleCategory.GAMEPLAY, - icon = Material.DOUBLE_PLANT // Sunflower - FIXME 1.13 + icon = Material.SUNFLOWER ) public class WeatherModule extends QSGModule { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java index 074286f..4501ccb 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java @@ -54,7 +54,7 @@ "to keep old statistics!", when = ModuleLoadTime.POST_WORLD, category = ModuleCategory.OTHER, - icon = Material.WORKBENCH + icon = Material.CRAFTING_TABLE ) public class StatisticsModule extends QSGModule { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java index fbd192c..e429bf9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java @@ -42,9 +42,9 @@ import fr.zcraft.quartzlib.components.rawtext.RawText; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.RawMessage; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.colors.TeamColor; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.colors.TeamColor; import me.cassayre.florian.hawk.report.ReportEvent; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; @@ -66,8 +66,8 @@ public class AllianceRequest private final UUID requestedID; private final Map<UUID, Boolean> approvalsIDs = new HashMap<>(); - private final ZTeam requesterTeam; - private final ZTeam requestedTeam; + private final QuartzTeam requesterTeam; + private final QuartzTeam requestedTeam; private final RequestError requestError; @@ -82,8 +82,8 @@ public AllianceRequest(final UUID requesterID, final UUID requestedTo) this.requesterID = requesterID; this.requestedID = requestedTo; - this.requesterTeam = ZTeams.get().getTeamForPlayer(requesterID); - this.requestedTeam = ZTeams.get().getTeamForPlayer(requestedTo); + this.requesterTeam = QuartzTeams.get().getTeamForPlayer(requesterID); + this.requestedTeam = QuartzTeams.get().getTeamForPlayer(requestedTo); final Player requesterPlayer = Bukkit.getPlayer(requesterID); final Player requestedPlayer = Bukkit.getPlayer(requestedID); @@ -268,7 +268,7 @@ public void registerApproval(final UUID approver, final boolean approval) // If one of the sides is an existing alliance, we notify the players in that // alliance. - final ZTeam notifiedTeam; + final QuartzTeam notifiedTeam; final UUID allianceWith; if (alliances.allianceSize(requesterTeam) > 1) @@ -314,7 +314,7 @@ private void denyAndClose(final UUID closedBy) alliances.unregisterRequest(this); - final ZTeam notifiedTeam; + final QuartzTeam notifiedTeam; final OfflinePlayer allianceWith; final OfflinePlayer closer = Bukkit.getOfflinePlayer(closedBy); @@ -376,7 +376,7 @@ private void applyApprovedRequest() // We create a new team for this new alliance. Old teams are dropped. - final ZTeam allianceTeam = ZTeams.get().createTeam(I.t("Your alliance"), TeamColor.WHITE); + final QuartzTeam allianceTeam = QuartzTeams.get().createTeam(I.t("Your alliance"), TeamColor.WHITE); final Set<UUID> alliancePlayers = Stream.of(requesterTeam, requestedTeam) .flatMap(team -> team.getPlayersUUID().stream()) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java index f55f9ed..9fbca36 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java @@ -47,9 +47,9 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.colors.TeamColor; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.colors.TeamColor; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -101,7 +101,7 @@ protected void onEnable() eu.carrade.amaury.quartzsurvivalgames.modules.core.game.Config.SIDEBAR.TEAMS.set(false); eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); - ZTeams.settings() + QuartzTeams.settings() .setTeamsOptions( eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), false, @@ -114,7 +114,7 @@ protected void onEnable() // ...And permissions - ZTeams.setPermissionsChecker(new TeamsPermissionsChecker(ZTeams.get().permissionsChecker())); + QuartzTeams.setPermissionsChecker(new TeamsPermissionsChecker(QuartzTeams.get().permissionsChecker())); } @Override @@ -218,13 +218,13 @@ public AllianceRequest getRequestByCouple(final UUID requestSenderID, final UUID public int allianceSize(UUID playerID) { - final ZTeam team = ZTeams.get().getTeamForPlayer(playerID); + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(playerID); if (team != null) return allianceSize(team); else return 1; } - public int allianceSize(final ZTeam team) + public int allianceSize(final QuartzTeam team) { return (int) team.getPlayers().stream().filter(game::isAlive).count(); } @@ -240,10 +240,10 @@ private void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) { final SpectatorsModule spectators = QSG.module(SpectatorsModule.class); - new HashSet<>(ZTeams.get().getTeams()).forEach(ZTeam::deleteTeam); + new HashSet<>(QuartzTeams.get().getTeams()).forEach(QuartzTeam::deleteTeam); Bukkit.getOnlinePlayers().stream() .filter(player -> !spectators.isSpectator(player)) - .forEach(player -> ZTeams.get().createTeam(I.t("Alone"), TeamColor.WHITE, player)); + .forEach(player -> QuartzTeams.get().createTeam(I.t("Alone"), TeamColor.WHITE, player)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java index ea3cb04..0ac7aff 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java @@ -33,8 +33,8 @@ */ package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; -import fr.zcraft.zteams.ZTeamsPermission; -import fr.zcraft.zteams.permissions.PermissionsChecker; +import fr.zcraft.quartzteams.QuartzTeamsPermission; +import fr.zcraft.quartzteams.permissions.PermissionsChecker; import org.bukkit.permissions.Permissible; public class TeamsPermissionsChecker implements PermissionsChecker @@ -47,7 +47,7 @@ public TeamsPermissionsChecker(PermissionsChecker delegate) } @Override - public boolean hasPermission(Permissible permissible, ZTeamsPermission permission) + public boolean hasPermission(Permissible permissible, QuartzTeamsPermission permission) { switch (permission) { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java index 15a5159..4c2b3fc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java @@ -43,7 +43,7 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -113,7 +113,7 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge { yourRequestHasBeenSent(requested); - ZTeams.get().getTeamForPlayer(requested).getOnlinePlayers().forEach(teammate -> { + QuartzTeams.get().getTeamForPlayer(requested).getOnlinePlayers().forEach(teammate -> { teammate.sendMessage(""); teammate.sendMessage(I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because your alliance is already at full capacity.", sender.getName())); teammate.sendMessage(I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", sender.getName())); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java index 5d49190..81ba9b6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java @@ -31,17 +31,16 @@ */ package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.colors.ColorsUtils; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.colors.ColorsUtils; +import java.util.HashMap; +import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.material.MaterialData; - -import java.util.HashMap; -import java.util.Map; +import org.bukkit.block.data.BlockData; public class Cage @@ -49,7 +48,6 @@ public class Cage private final Location baseLocation; private Material material = Material.BARRIER; - private MaterialData materialData = null; private final boolean buildCeiling; private final boolean visibleWalls; @@ -58,7 +56,7 @@ public class Cage private int internalHeight = 3; private boolean built = false; - private Map<Location, SimpleBlock> blocksBuilt = new HashMap<>(); + private final Map<Location, SimpleBlock> blocksBuilt = new HashMap<>(); /** @@ -73,29 +71,6 @@ public Cage(Location baseLocation, boolean buildCeiling, boolean visibleWalls) this.visibleWalls = visibleWalls; } - /** - * Sets the custom material to use. - * - * @param customMaterial A material. - * @param data The data value (or {@code null}). - */ - public void setCustomMaterial(Material customMaterial, MaterialData data) - { - this.material = customMaterial == null ? Material.BARRIER : customMaterial; - this.materialData = data; - } - - /** - * Sets the custom material to use. - * - * @param customMaterial A material. - * @param data The data value. - */ - public void setCustomMaterial(Material customMaterial, byte data) - { - setCustomMaterial(customMaterial, new MaterialData(this.material, data)); - } - /** * Sets the custom material to use. * @@ -103,7 +78,7 @@ public void setCustomMaterial(Material customMaterial, byte data) */ public void setCustomMaterial(Material customMaterial) { - setCustomMaterial(customMaterial, null); + this.material = customMaterial == null ? Material.BARRIER : customMaterial; } @@ -138,38 +113,13 @@ public void setRadius(int radius) * @param material The block material */ private void setBlock(final Location location, final Material material) - { - setBlock(location, material, null); - } - - /** - * Sets a block (and remembers the old one to clean up things after). - * - * @param location The location - * @param material The block material - * @param data The block data value (as byte) - */ - private void setBlock(final Location location, final Material material, final byte data) - { - setBlock(location, material, new MaterialData(material, data)); - } - - /** - * Sets a block (and remembers the old one to clean up things after). - * - * @param location The location - * @param material The block material - * @param data The block data value (as {@link MaterialData}) - */ - private void setBlock(final Location location, final Material material, final MaterialData data) { final Block block = location.getBlock(); if (!blocksBuilt.containsKey(location)) - blocksBuilt.put(location, new SimpleBlock(block.getType(), block.getState().getData().clone())); + blocksBuilt.put(location, new SimpleBlock(block.getType(), block.getState().getBlockData().clone())); block.setType(material); - if (data != null) block.setData(data.getData()); } @@ -201,20 +151,19 @@ public boolean build() for (int x = xMin + 1; x <= xMax - 1; x++) for (int z = zMin + 1; z <= zMax - 1; z++) - setBlock(new Location(world, x, baseLocation.getBlockY() - 1, z), material, materialData); + setBlock(new Location(world, x, baseLocation.getBlockY() - 1, z), material); // Builds the walls final Material wallsMaterial = visibleWalls ? material : Material.BARRIER; - final MaterialData wallsMaterialData = visibleWalls ? materialData : null; for (int x = xMin; x <= xMax; x++) { for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) { - setBlock(new Location(world, x, y, zMin), wallsMaterial, wallsMaterialData); - setBlock(new Location(world, x, y, zMax), wallsMaterial, wallsMaterialData); + setBlock(new Location(world, x, y, zMin), wallsMaterial); + setBlock(new Location(world, x, y, zMax), wallsMaterial); } } @@ -222,8 +171,8 @@ public boolean build() { for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) { - setBlock(new Location(world, xMin, y, z), wallsMaterial, wallsMaterialData); - setBlock(new Location(world, xMax, y, z), wallsMaterial, wallsMaterialData); + setBlock(new Location(world, xMin, y, z), wallsMaterial); + setBlock(new Location(world, xMax, y, z), wallsMaterial); } } @@ -231,7 +180,6 @@ public boolean build() // Builds the ceiling final Material ceilingMaterial = buildCeiling ? material : Material.BARRIER; - final MaterialData ceilingMaterialData = buildCeiling ? materialData : null; int xMinCeiling = xMin, xMaxCeiling = xMax, zMinCeiling = zMin, zMaxCeiling = zMax; @@ -245,7 +193,7 @@ public boolean build() for (int x = xMinCeiling; x <= xMaxCeiling; x++) for (int z = zMinCeiling; z <= zMaxCeiling; z++) - setBlock(new Location(world, x, baseLocation.getBlockY() + internalHeight, z), ceilingMaterial, ceilingMaterialData); + setBlock(new Location(world, x, baseLocation.getBlockY() + internalHeight, z), ceilingMaterial); built = true; @@ -267,7 +215,7 @@ public void destroy() block.setType(originalBlock.material); if (originalBlock.data != null) - block.getState().setData(originalBlock.data); + block.getState().setBlockData(originalBlock.data); } built = false; @@ -282,39 +230,34 @@ public void destroy() * * @return A Cage */ - static public Cage createInstanceForTeam(final ZTeam team, final Location location) + static public Cage createInstanceForTeam(final QuartzTeam team, final Location location) { final Material cageMaterial; - final Byte cageData; switch (Config.TYPE.get()) { case TEAM_COLOR_TRANSPARENT: - cageMaterial = Material.STAINED_GLASS; - cageData = ColorsUtils.chat2Dye(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE).getWoolData(); + cageMaterial = ColorsUtils.chat2Block(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE, "STAINED_GLASS"); break; case TEAM_COLOR_SOLID: - cageMaterial = Material.STAINED_CLAY; - cageData = ColorsUtils.chat2Dye(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE).getWoolData(); + cageMaterial = ColorsUtils.chat2Block(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE, "TERRACOTTA"); break; case CUSTOM: cageMaterial = Config.CUSTOM_BLOCK.get(); - cageData = null; break; // Should never happen default: cageMaterial = null; - cageData = null; } final Cage cage = new Cage(location, Config.BUILD_CEILING.get(), Config.VISIBLE_WALLS.get()); if (cageMaterial != null) // Should always be true { - cage.setCustomMaterial(cageMaterial, cageData != null ? cageData : 0); + cage.setCustomMaterial(cageMaterial); cage.setInternalHeight(Config.HEIGHT.get()); cage.setRadius(Config.RADIUS.get()); } @@ -335,11 +278,17 @@ public enum CageType TEAM_COLOR_TRANSPARENT, /** - * Cages in stained hardened clay, using the team color (or the closest + * Cages in stained terracotta clay, using the team color (or the closest * color available). */ TEAM_COLOR_SOLID, + /** + * Cages in stained glazed terracotta, using the team color (or the closest + * color available). + */ + TEAM_COLOR_FANCY, + /** * Cages in a custom provided block. */ @@ -353,9 +302,9 @@ public enum CageType private class SimpleBlock { public Material material; - public MaterialData data; + public BlockData data; - public SimpleBlock(Material material, MaterialData data) + public SimpleBlock(Material material, BlockData data) { this.material = material; this.data = data; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java index 735f25d..414547a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java @@ -42,7 +42,7 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerAboutToBeTeleportedToSpawnPointEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; -import fr.zcraft.zteams.ZTeams; +import fr.zcraft.quartzteams.QuartzTeams; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -70,7 +70,7 @@ public class CagesModule extends QSGModule public void onPlayerSpawnSelected(PlayerSpawnPointSelectedEvent ev) { final Location spawn = cloneAndNormalize(ev.getSpawnPoint()); - cages.putIfAbsent(spawn, Cage.createInstanceForTeam(ZTeams.get().getTeamForPlayer(ev.getPlayer()), spawn)); + cages.putIfAbsent(spawn, Cage.createInstanceForTeam(QuartzTeams.get().getTeamForPlayer(ev.getPlayer()), spawn)); } @EventHandler diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java index 2dd79f7..9f4aa75 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java @@ -47,7 +47,7 @@ name = "Border Check", description = "Offers a command to check how far players are from a given border size.", category = ModuleCategory.UTILITIES, - icon = Material.FENCE, + icon = Material.JUNGLE_FENCE, when = ModuleLoadTime.ON_GAME_START ) public class CheckModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java index 7cee576..72a56ae 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java @@ -51,7 +51,7 @@ description = "Provides commands to update food level & saturation of some or all players.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.UTILITIES, - icon = Material.MUSHROOM_SOUP + icon = Material.MUSHROOM_STEW ) public class FoodModule extends QSGModule { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java index a562894..16fbb50 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java @@ -40,7 +40,7 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -85,7 +85,7 @@ public void onEnable() @Override protected void onDisable() { - ZLib.unregisterEvents(freezerListener); + QuartzLib.unregisterEvents(freezerListener); freezerListener = null; } @@ -284,7 +284,7 @@ private void updateListenerRegistration() { if (!this.frozenPlayers.isEmpty() || this.getGlobalFreezeState()) { - ZLib.registerEvents(freezerListener); + QuartzLib.registerEvents(freezerListener); this.isListenerRegistered = true; } } @@ -294,7 +294,7 @@ private void updateListenerRegistration() { if (this.frozenPlayers.isEmpty() && !this.getGlobalFreezeState()) { - ZLib.unregisterEvents(freezerListener); + QuartzLib.unregisterEvents(freezerListener); this.isListenerRegistered = false; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java index 4ba303a..b1f3d78 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java @@ -47,7 +47,7 @@ description = "Loads player into the server even if they never came before, so you can add them to teams and such. " + "An interface to the built-in players loader.", category = ModuleCategory.UTILITIES, - icon = Material.SKULL_ITEM // FIXME 1.13 + icon = Material.PLAYER_HEAD ) public class PlayersLoaderModule extends QSGModule { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java index 9641a9d..73354b1 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java @@ -62,7 +62,7 @@ "This is a powerful tool to schedule any command at any time relative to the game progression.", when = ModuleLoadTime.STARTUP, category = ModuleCategory.UTILITIES, - icon = Material.COMMAND, + icon = Material.COMMAND_BLOCK, settings = Config.class ) public class RuntimeCommandsExecutor extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java index de89cd6..d20037d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java @@ -54,7 +54,7 @@ name = "Teleportation Commands", description = "Provides commands to teleport to spawn, death location, or groups of players.", category = ModuleCategory.UTILITIES, - icon = Material.COMMAND_MINECART + icon = Material.COMMAND_BLOCK_MINECART ) public class TeleportationModule extends QSGModule { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java index 45875e5..8a7ba10 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java @@ -36,9 +36,9 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.texts.TextUtils; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.texts.TextUtils; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -57,7 +57,7 @@ protected void run() throws CommandException // possibly /uh tp-team <x> <y> <z> "<team ...>" if (qargs.length == 4) { - final ZTeam team = ZTeams.get().getTeamByName(qargs[3]); + final QuartzTeam team = QuartzTeams.get().getTeamByName(qargs[3]); // ok, the team exists. if (team != null) @@ -92,7 +92,7 @@ protected void run() throws CommandException // /uh tp team <target> "<team ...>" if (qargs.length == 2) { - final ZTeam team = ZTeams.get().getTeamByName(qargs[1]); + final QuartzTeam team = QuartzTeams.get().getTeamByName(qargs[1]); if (team == null) { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java index 4ffafa1..6acb80c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java @@ -112,42 +112,31 @@ protected Boolean isBlockTransparentOrNatural(Material blockType) switch (blockType) { + // TODO re-add stained glass, stained glass pane, logs, leaves, beds, signs, fences + // Low priority as this is mostly unused anyway, with vanilla world border. case GLASS: // The glass isn't a transparent block for the `isTransparent` method. - case STAINED_GLASS: - case THIN_GLASS: - case STAINED_GLASS_PANE: - case LEAVES: - case LEAVES_2: - case LOG: - case LOG_2: case CHEST: // Avoid a cube of the solid block where there where a chest. case TRAPPED_CHEST: case ENDER_CHEST: case WATER: - case STATIONARY_WATER: - case BED_BLOCK: - case PISTON_STICKY_BASE: // Same idea (in jungle temples). - case PISTON_BASE: + case STICKY_PISTON: // Same idea (in jungle temples). + case PISTON: + case PISTON_HEAD: case BOOKSHELF: // Same idea (in villages & fortresses). - case MOB_SPAWNER: // Same idea (in dungeons). - case SIGN_POST: - case WALL_SIGN: + case SPAWNER: // Same idea (in dungeons). case ICE: // Same idea (in cold biomes). case PACKED_ICE: case CACTUS: // Same idea (in deserts) - case FENCE: - case FENCE_GATE: - case IRON_FENCE: - case NETHER_FENCE: case PUMPKIN: - case MELON_BLOCK: // Same idea (in jungles) + case MELON: // Same idea (in jungles) case GLOWSTONE: // Same idea (in the Nether - why not?) case JACK_O_LANTERN: - case HUGE_MUSHROOM_1: // Same idea (in dark forests). - case HUGE_MUSHROOM_2: - case CAKE_BLOCK: // It may be a lie, but hey, why not. + case BROWN_MUSHROOM_BLOCK: // Same idea (in dark forests). + case RED_MUSHROOM_BLOCK: + case MUSHROOM_STEM: + case CAKE: // It may be a lie, but hey, why not. case BEACON: - case COBBLE_WALL: + case COBBLESTONE_WALL: case ANVIL: return true; default: diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java index 0051116..74e3f30 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java @@ -58,7 +58,7 @@ description = "Warns players about the future border size.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.UTILITIES, - icon = Material.FENCE_GATE, + icon = Material.NETHER_BRICK_FENCE, settings = Config.class ) public class WarningModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java index 0a14d74..b512e67 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java @@ -33,15 +33,14 @@ */ package eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; -import org.bukkit.Material; - import java.io.File; - -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; +import org.bukkit.Material; public class Config extends ConfigurationInstance { @@ -74,7 +73,7 @@ static public class TeamSelectorSection extends ConfigurationSection static public class ConfigAccessorSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Material> ITEM = item("item", Material.REDSTONE_COMPARATOR); + public final ConfigurationItem<Material> ITEM = item("item", Material.COMPARATOR); } public static final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("team-in-action-bar", true); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java index 430f11b..9c215e9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java @@ -47,19 +47,19 @@ import fr.zcraft.quartzlib.components.attributes.Attributes; import fr.zcraft.quartzlib.components.gui.Gui; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.ZLib; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.reflection.NMSException; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.ActionBar; -import fr.zcraft.zteams.ZTeam; -import fr.zcraft.zteams.ZTeams; -import fr.zcraft.zteams.events.PlayerJoinedTeamEvent; -import fr.zcraft.zteams.events.PlayerLeftTeamEvent; -import fr.zcraft.zteams.events.TeamUnregisteredEvent; -import fr.zcraft.zteams.events.TeamUpdatedEvent; -import fr.zcraft.zteams.guis.TeamsSelectorGUI; +import fr.zcraft.quartzteams.QuartzTeam; +import fr.zcraft.quartzteams.QuartzTeams; +import fr.zcraft.quartzteams.events.PlayerJoinedTeamEvent; +import fr.zcraft.quartzteams.events.PlayerLeftTeamEvent; +import fr.zcraft.quartzteams.events.TeamUnregisteredEvent; +import fr.zcraft.quartzteams.events.TeamUpdatedEvent; +import fr.zcraft.quartzteams.guis.TeamsSelectorGUI; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -84,7 +84,7 @@ name = "Waiting phase", description = "Manages the waiting phase: inventory, effects, modes, teleportation, etc.", category = ModuleCategory.WAITING_PHASE, - icon = Material.WATCH, + icon = Material.CLOCK, settings = Config.class, can_be_loaded_late = false ) @@ -318,7 +318,7 @@ private void displayTeamInActionBar(final OfflinePlayer player) if (onlinePlayer == null) return; - final ZTeam team = ZTeams.get().getTeamForPlayer(player); + final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); if (team != null) ActionBar.sendPermanentMessage(onlinePlayer, I.t("{gold}Your team: {0}", team.getDisplayName())); @@ -511,7 +511,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) break; case IN_GAME: - ZLib.unregisterEvents(this); + QuartzLib.unregisterEvents(this); if (inventoriesUpdateTask != null) { inventoriesUpdateTask.cancel(); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java index d794a0d..e9f6a90 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java @@ -60,7 +60,7 @@ "For best results, enable before generating the worlds.", when = ModuleLoadTime.STARTUP, category = ModuleCategory.WORLD_GENERATION, - icon = Material.MOB_SPAWNER, + icon = Material.SPAWNER, settings = Config.class ) public class CreaturesModule extends QSGModule diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java index 3f74e5e..aee02f4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/CommandUtils.java @@ -29,33 +29,32 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.quartzsurvivalgames.utils; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +package eu.carrade.amaury.quartzsurvivalgames.utils; import java.text.Collator; import java.util.ArrayList; import java.util.List; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; -public class CommandUtils -{ - public final static String CHAT_SEPARATOR = ChatColor.GRAY + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"; +public class CommandUtils { + public final static String CHAT_SEPARATOR = ChatColor.GRAY + + "⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅"; /** * Returns a list of autocompletion suggestions based on what the user typed and on a list of * available commands. * - * @param typed What the user typed. This string needs to include <em>all</em> the words typed. - * @param suggestionsList The list of the suggestions. + * @param typed What the user typed. This string needs to include <em>all</em> the words typed. + * @param suggestionsList The list of the suggestions. * @param numberOfWordsToIgnore If non-zero, this number of words will be ignored at the beginning of the string. This is used to handle multiple-words autocompletion. - * * @return The list of matching suggestions. */ - public static List<String> getAutocompleteSuggestions(String typed, List<String> suggestionsList, int numberOfWordsToIgnore) - { + public static List<String> getAutocompleteSuggestions(String typed, List<String> suggestionsList, + int numberOfWordsToIgnore) { List<String> list = new ArrayList<String>(); // For each suggestion: @@ -64,22 +63,17 @@ public static List<String> getAutocompleteSuggestions(String typed, List<String> // then, if the raw suggestion matches the typed text, we adds to the suggestion list // the filtered suggestion, because the Bukkit's autocompleter works on a “per-word” basis. - for (String rawSuggestion : suggestionsList) - { + for (String rawSuggestion : suggestionsList) { String suggestion; - if (numberOfWordsToIgnore == 0) - { + if (numberOfWordsToIgnore == 0) { suggestion = rawSuggestion; - } - else - { + } else { // Not the primary use, but, hey! It works. suggestion = QSGUtils.getStringFromCommandArguments(rawSuggestion.split(" "), numberOfWordsToIgnore); } - if (rawSuggestion.toLowerCase().startsWith(typed.toLowerCase())) - { + if (rawSuggestion.toLowerCase().startsWith(typed.toLowerCase())) { list.add(suggestion); } } @@ -93,13 +87,11 @@ public static List<String> getAutocompleteSuggestions(String typed, List<String> * Returns a list of autocompletion suggestions based on what the user typed and on a list of * available commands. * - * @param typed What the user typed. + * @param typed What the user typed. * @param suggestionsList The list of the suggestions. - * * @return The list of matching suggestions. */ - public static List<String> getAutocompleteSuggestions(String typed, List<String> suggestionsList) - { + public static List<String> getAutocompleteSuggestions(String typed, List<String> suggestionsList) { return getAutocompleteSuggestions(typed, suggestionsList, 0); } @@ -108,15 +100,13 @@ public static List<String> getAutocompleteSuggestions(String typed, List<String> * Displays a separator around the output of the commands. * * <p> - * To be called before and after the output (prints a line only). + * To be called before and after the output (prints a line only). * </p> * * @param sender The line will be displayed for this sender. */ - public static void displaySeparator(CommandSender sender) - { - if (!(sender instanceof Player)) - { + public static void displaySeparator(CommandSender sender) { + if (!(sender instanceof Player)) { return; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java index b2fe59f..24b6abc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/EntitiesUtils.java @@ -31,13 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.utils; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Slime; import org.bukkit.event.entity.CreatureSpawnEvent; -public class EntitiesUtils -{ +public class EntitiesUtils { /** * Checks if a spawn is natural. * @@ -45,10 +49,8 @@ public class EntitiesUtils * @return {@code true} if it's a natural spawn (not from a player or an interaction * with another entity, as example). */ - public static boolean isNaturalSpawn(final CreatureSpawnEvent.SpawnReason reason) - { - switch (reason) - { + public static boolean isNaturalSpawn(final CreatureSpawnEvent.SpawnReason reason) { + switch (reason) { case NATURAL: case NETHER_PORTAL: case LIGHTNING: @@ -62,11 +64,11 @@ public static boolean isNaturalSpawn(final CreatureSpawnEvent.SpawnReason reason /** * Checks if the given mod is hostile. + * * @param entity The entity. * @return {@code true} if hostile. */ - public static boolean isHostile(final EntityType entity) - { + public static boolean isHostile(final EntityType entity) { final Class<? extends Entity> entityClass = entity.getEntityClass(); return Monster.class.isAssignableFrom(entityClass) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java index 9d842d8..f1bbc1c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/ModulesUtils.java @@ -29,41 +29,37 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.quartzsurvivalgames.utils; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; +package eu.carrade.amaury.quartzsurvivalgames.utils; import java.util.Arrays; import java.util.List; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; -public class ModulesUtils -{ +public class ModulesUtils { /** * Tries to find a class from its name, by combining suffixes, packages, capitalization. * - * @param name The class base name to search for. + * @param name The class base name to search for. * @param optionalPackage An optional package to search in. - * @param optionalSuffix An optional suffix to test, appended to the class name. - * @param superClass The superclass this class must have. - * @param <T> The superclass type this class must have. - * + * @param optionalSuffix An optional suffix to test, appended to the class name. + * @param superClass The superclass this class must have. + * @param <T> The superclass type this class must have. * @return The {@link Class}, if found; else, {@code null}. */ - public static <T> Class<? extends T> getClassFromName(final String name, final String optionalPackage, final String optionalSuffix, final Class<T> superClass) - { + public static <T> Class<? extends T> getClassFromName(final String name, final String optionalPackage, + final String optionalSuffix, final Class<T> superClass) { final String alternateName; final String alternativePackage; - if (name.contains(".")) - { + if (name.contains(".")) { final String[] lastClassPathParts = name.split("\\."); alternateName = lastClassPathParts[lastClassPathParts.length - 1]; - alternativePackage = String.join(".", (String[]) ArrayUtils.remove(lastClassPathParts, lastClassPathParts.length - 1)); - } - else - { + alternativePackage = + String.join(".", (String[]) ArrayUtils.remove(lastClassPathParts, lastClassPathParts.length - 1)); + } else { alternateName = name; alternativePackage = ""; } @@ -79,11 +75,13 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + name + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name), - optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name) + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(name) + + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + alternateName, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + alternateName + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName), - optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName) + optionalSuffix, + optionalPackage + "." + StringUtils.uncapitalize(name) + "." + StringUtils.capitalize(alternateName) + + optionalSuffix, optionalPackage + "." + StringUtils.uncapitalize(name) + "." + optionalSuffix, optionalPackage + "." + alternativePackage + "." + name, optionalPackage + "." + alternativePackage + "." + name + optionalSuffix, @@ -92,17 +90,18 @@ public static <T> Class<? extends T> getClassFromName(final String name, final S optionalPackage + "." + alternativePackage + "." + alternateName, optionalPackage + "." + alternativePackage + "." + alternateName + optionalSuffix, optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(alternateName), - optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(alternateName) + optionalSuffix, + optionalPackage + "." + alternativePackage + "." + StringUtils.capitalize(alternateName) + + optionalSuffix, optionalPackage + "." + alternativePackage + "." + optionalSuffix, name ); - for (final String clazzName : possibilities) - { - try - { + for (final String clazzName : possibilities) { + try { final Class clazz = Class.forName(clazzName); - if (superClass.isAssignableFrom(clazz)) return (Class<? extends T>) clazz; + if (superClass.isAssignableFrom(clazz)) { + return (Class<? extends T>) clazz; + } } catch (ClassNotFoundException e) { /* The search continues... */ } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java index e5c2723..d6849d6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersComparator.java @@ -29,23 +29,22 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.quartzsurvivalgames.utils; -import org.bukkit.OfflinePlayer; +package eu.carrade.amaury.quartzsurvivalgames.utils; import java.util.Comparator; +import org.bukkit.OfflinePlayer; -public class OfflinePlayersComparator implements Comparator<OfflinePlayer> -{ +public class OfflinePlayersComparator implements Comparator<OfflinePlayer> { @Override - public int compare(OfflinePlayer player1, OfflinePlayer player2) - { - if (player1.isOnline() == player2.isOnline()) + public int compare(OfflinePlayer player1, OfflinePlayer player2) { + if (player1.isOnline() == player2.isOnline()) { return player1.getName().toLowerCase().compareTo(player2.getName().toLowerCase()); - else if (player1.isOnline()) + } else if (player1.isOnline()) { return -1; - else + } else { return 1; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java index 400e00b..a3a0877 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/OfflinePlayersLoader.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.utils; import fr.zcraft.quartzlib.components.worker.Worker; @@ -39,10 +40,6 @@ import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.mojang.UUIDFetcher; import fr.zcraft.quartzlib.tools.reflection.Reflection; -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; - import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; @@ -54,12 +51,14 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; -@WorkerAttributes (name = "Offline Players Loader") -public class OfflinePlayersLoader extends Worker -{ - private static Map<UUID, OfflinePlayer> offlinePlayers = new HashMap<>(); +@WorkerAttributes(name = "Offline Players Loader") +public class OfflinePlayersLoader extends Worker { + private static final Map<UUID, OfflinePlayer> offlinePlayers = new HashMap<>(); /** * Returns a list of offline players, including the players who logged in the server and the explicitly @@ -67,8 +66,7 @@ public class OfflinePlayersLoader extends Worker * * @return A list of OfflinePlayers. */ - public static Set<OfflinePlayer> getOfflinePlayers() - { + public static Set<OfflinePlayer> getOfflinePlayers() { final Set<OfflinePlayer> players = new HashSet<>(offlinePlayers.values()); Collections.addAll(players, Bukkit.getOfflinePlayers()); @@ -77,7 +75,7 @@ public static Set<OfflinePlayer> getOfflinePlayers() /** * Retrieves an OfflinePlayer by ID. - * + * <p> * Tries to load a logged-in player, then an explicitly loaded player, then * a server-wide OfflinePlayer. * @@ -86,39 +84,39 @@ public static Set<OfflinePlayer> getOfflinePlayers() * be loaded with a name and other data if the player never came to the server and * was not explicitly loaded. */ - public static OfflinePlayer getOfflinePlayer(UUID id) - { + public static OfflinePlayer getOfflinePlayer(UUID id) { OfflinePlayer player = Bukkit.getPlayer(id); - if (player == null) player = offlinePlayers.get(id); - if (player == null) player = Bukkit.getOfflinePlayer(id); + if (player == null) { + player = offlinePlayers.get(id); + } + if (player == null) { + player = Bukkit.getOfflinePlayer(id); + } return player; } /** * Retrieves an OfflinePlayer by name. - * + * <p> * Tries to load a logged-in player, then an explicitly loaded player, then * a server-wide OfflinePlayer. * * @param name The player's name. * @return An OfflinePlayer. {@code null} if no player was found with this name. */ - public static OfflinePlayer getOfflinePlayer(String name) - { + public static OfflinePlayer getOfflinePlayer(String name) { OfflinePlayer player = Bukkit.getOnlinePlayers().stream() .filter(onlinePlayer -> onlinePlayer.getName().equalsIgnoreCase(name)) .findFirst().orElse(null); - if (player == null) - { + if (player == null) { player = Arrays.stream(Bukkit.getOfflinePlayers()) .filter(offlinePlayer -> offlinePlayer.getName().equalsIgnoreCase(name)) .findFirst().orElse(null); } - if (player == null) - { + if (player == null) { player = offlinePlayers.values().stream() .filter(offlinePlayer -> offlinePlayer.getName().equalsIgnoreCase(name)) .findFirst().orElse(null); @@ -130,19 +128,18 @@ public static OfflinePlayer getOfflinePlayer(String name) /** * Loads the given players list in the system, making it available in the players list and to be added in teams. * - * @param pseudonym A pseudonym. + * @param pseudonym A pseudonym. * @param successCallback A callback called when the process ended. Called with {@code null} if no player was found. */ - public static void loadPlayer(final String pseudonym, final Callback<OfflinePlayer> successCallback) - { + public static void loadPlayer(final String pseudonym, final Callback<OfflinePlayer> successCallback) { loadPlayers(Collections.singletonList(pseudonym), retrieved -> { - if (successCallback != null) - { - if (retrieved.size() == 1) + if (successCallback != null) { + if (retrieved.size() == 1) { successCallback.call(retrieved.values().iterator().next()); - else + } else { successCallback.call(null); + } } }); } @@ -150,128 +147,125 @@ public static void loadPlayer(final String pseudonym, final Callback<OfflinePlay /** * Loads the given players list in the system, making it available in the players list and to be added in teams. * - * @param pseudonyms A list of pseudonyms. + * @param pseudonyms A list of pseudonyms. * @param callbackSuccess A callback called when the process ended. */ - public static void loadPlayers(final List<String> pseudonyms, final Callback<Map<UUID, OfflinePlayer>> callbackSuccess) - { + public static void loadPlayers(final List<String> pseudonyms, + final Callback<Map<UUID, OfflinePlayer>> callbackSuccess) { loadPlayers( pseudonyms, callbackSuccess, - errors -> PluginLogger.error("Unable to retrieve the following names: {0}", StringUtils.join(errors, ", ")) + errors -> PluginLogger + .error("Unable to retrieve the following names: {0}", StringUtils.join(errors, ", ")) ); } /** * Loads the given players list in the system, making it available in the players list * and to be added in teams. - * + * <p> * Only works in online mode. In offline mode, the already known players will be sent * to the success callback and the others to the errors one. Use {@link UUIDFetcher} * directly if needed. * - * @param pseudonyms A list of pseudonyms. + * @param pseudonyms A list of pseudonyms. * @param callbackSuccess A callback called when the process ended. */ - public static void loadPlayers(final List<String> pseudonyms, final Callback<Map<UUID, OfflinePlayer>> callbackSuccess, final Callback<List<String>> callbackErrors) - { + public static void loadPlayers(final List<String> pseudonyms, + final Callback<Map<UUID, OfflinePlayer>> callbackSuccess, + final Callback<List<String>> callbackErrors) { final List<String> toRetrieve = new ArrayList<>(pseudonyms); final Map<UUID, OfflinePlayer> alreadyKnown = new HashMap<>(); - for (String pseudonym : pseudonyms) - { + for (String pseudonym : pseudonyms) { OfflinePlayer player = getOfflinePlayer(pseudonym); - if (player != null) - { + if (player != null) { alreadyKnown.put(player.getUniqueId(), player); toRetrieve.remove(pseudonym); } } - if (toRetrieve.size() == 0) - { - if (callbackSuccess != null) callbackSuccess.call(alreadyKnown); + if (toRetrieve.size() == 0) { + if (callbackSuccess != null) { + callbackSuccess.call(alreadyKnown); + } return; } // If the server is in offline mode, we don't even try to load the players, as they will // not be valid and be unusable. - if (!Bukkit.getOnlineMode()) - { - if (callbackSuccess != null) callbackSuccess.call(alreadyKnown); - if (callbackErrors != null && toRetrieve.size() > 0) callbackErrors.call(toRetrieve); + if (!Bukkit.getOnlineMode()) { + if (callbackSuccess != null) { + callbackSuccess.call(alreadyKnown); + } + if (callbackErrors != null && toRetrieve.size() > 0) { + callbackErrors.call(toRetrieve); + } return; } - submitQuery(new WorkerRunnable<Map<String, UUID>>() - { + submitQuery(new WorkerRunnable<Map<String, UUID>>() { @Override - public Map<String, UUID> run() throws Throwable - { + public Map<String, UUID> run() throws Throwable { final Map<String, UUID> uuids = UUIDFetcher.fetch(toRetrieve); UUIDFetcher.fetchRemaining(toRetrieve, uuids); return uuids; } - }, new WorkerCallback<Map<String, UUID>>() - { + }, new WorkerCallback<Map<String, UUID>>() { @Override - public void finished(final Map<String, UUID> result) - { + public void finished(final Map<String, UUID> result) { final Map<UUID, OfflinePlayer> added = new HashMap<>(alreadyKnown); final Class<?> gameProfileClass; - try - { + try { gameProfileClass = Class.forName("com.mojang.authlib.GameProfile"); } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { PluginLogger.error("Cannot load GameProfile class required to load OfflinePlayers.", e); return; } - for (Map.Entry<String, UUID> playerProfile : result.entrySet()) - { + for (Map.Entry<String, UUID> playerProfile : result.entrySet()) { final String name = playerProfile.getKey(); final UUID uuid = playerProfile.getValue(); - if (uuid == null) - { + if (uuid == null) { PluginLogger.error("Unable to load the player {0}, skipping.", name); continue; } - try - { + try { final Object profile = Reflection.instantiate(gameProfileClass, uuid, name); - final OfflinePlayer player = (OfflinePlayer) Reflection.call(Bukkit.getServer(), "getOfflinePlayer", profile); + final OfflinePlayer player = + (OfflinePlayer) Reflection.call(Bukkit.getServer(), "getOfflinePlayer", profile); offlinePlayers.put(uuid, player); added.put(uuid, player); } - catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) - { + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { PluginLogger.error("Unable to load the player {0}, skipping.", e, playerProfile.getKey()); } } - if (callbackSuccess != null) callbackSuccess.call(added); + if (callbackSuccess != null) { + callbackSuccess.call(added); + } - if (callbackErrors != null) - { + if (callbackErrors != null) { final List<String> notRetrieved = toRetrieve.stream() - .filter(pseudonym -> !result.keySet().contains(pseudonym)) + .filter(pseudonym -> !result.containsKey(pseudonym)) .collect(Collectors.toList()); - if (notRetrieved.size() > 0) callbackErrors.call(notRetrieved); + if (notRetrieved.size() > 0) { + callbackErrors.call(notRetrieved); + } } } @Override - public void errored(Throwable exception) - { + public void errored(Throwable exception) { PluginLogger.error("Unable to load players", exception); } }); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java index 1f2083a..3a5cde7 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGSound.java @@ -35,6 +35,10 @@ import fr.zcraft.quartzlib.components.configuration.ConfigurationParseException; import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandlers; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -42,129 +46,131 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Objects; - /** * Represents a sound, with volume and pitch. * * @author Amaury Carrade */ -public class QSGSound -{ - private Sound sound = null; +public class QSGSound { + static { + ConfigurationValueHandlers.registerHandlers(QSGSound.class); + } + + private Sound sound = null; private Float volume = 1f; - private Float pitch = 1f; + private Float pitch = 1f; /** * Constructs a sound with volume = 1f and pitch = 1f. * * @param sound The sound. */ - public QSGSound(final Sound sound) - { + public QSGSound(final Sound sound) { Validate.notNull(sound, "The sound cannot be null."); this.sound = sound; } - public QSGSound(final Sound sound, final Float volume, final Float pitch) - { + public QSGSound(final Sound sound, final Float volume, final Float pitch) { Validate.notNull(sound, "The sound cannot be null."); - this.sound = sound; + this.sound = sound; this.volume = volume; - this.pitch = pitch; + this.pitch = pitch; } /** * Constructs a sound from a string name with volume = 1f and pitch = 1f. - * + * <p> * This allows to support automatically all Minecraft versions as sounds names changed in enum * after version 1.10. * * @param sound The sound name to be looked up. */ - public QSGSound(final String sound) - { + public QSGSound(final String sound) { final Sound bukkitSound = string2Sound(sound); - if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching " + sound); + if (bukkitSound == null) { + throw new IllegalArgumentException("Cannot find a sound matching " + sound); + } this.sound = bukkitSound; } /** * Constructs a sound from a string name. - * + * <p> * This allows to support automatically all Minecraft versions as sounds names changed in enum * after version 1.10. * - * @param sound The sound name to be looked up. + * @param sound The sound name to be looked up. * @param volume The sound volume. - * @param pitch The sound pitch. + * @param pitch The sound pitch. */ - public QSGSound(final String sound, final Float volume, final Float pitch) - { + public QSGSound(final String sound, final Float volume, final Float pitch) { final Sound bukkitSound = string2Sound(sound); - if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching " + sound); + if (bukkitSound == null) { + throw new IllegalArgumentException("Cannot find a sound matching " + sound); + } - this.sound = bukkitSound; + this.sound = bukkitSound; this.volume = volume; - this.pitch = pitch; + this.pitch = pitch; } /** * Constructs a sound from string names with volume = 1f and pitch = 1f. - * + * <p> * This allows to support automatically all Minecraft versions as sounds names changed in enum * after version 1.10. * * @param sound A list of sounds to be looked up. The first one found will be used. */ - public QSGSound(final String... sound) - { + public QSGSound(final String... sound) { Sound bukkitSound = null; - for (String soundCandidate : sound) - { + for (String soundCandidate : sound) { bukkitSound = string2Sound(soundCandidate); - if (bukkitSound != null) break; + if (bukkitSound != null) { + break; + } } - if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + if (bukkitSound == null) { + throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + } this.sound = bukkitSound; } /** * Constructs a sound from a string name. - * + * <p> * This allows to support automatically all Minecraft versions as sounds names changed in enum * after version 1.10. * * @param volume The sound volume. - * @param pitch The sound pitch. - * @param sound A list of sounds to be looked up. The first one found will be used. + * @param pitch The sound pitch. + * @param sound A list of sounds to be looked up. The first one found will be used. */ - public QSGSound(final Float volume, final Float pitch, final String... sound) - { + public QSGSound(final Float volume, final Float pitch, final String... sound) { Sound bukkitSound = null; - for (String soundCandidate : sound) - { + for (String soundCandidate : sound) { bukkitSound = string2Sound(soundCandidate); - if (bukkitSound != null) break; + if (bukkitSound != null) { + break; + } } - if (bukkitSound == null) throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + if (bukkitSound == null) { + throw new IllegalArgumentException("Cannot find a sound matching one of these: " + Arrays.toString(sound)); + } - this.sound = bukkitSound; + this.sound = bukkitSound; this.volume = volume; - this.pitch = pitch; + this.pitch = pitch; } /** @@ -180,16 +186,82 @@ public QSGSound(final Float volume, final Float pitch, final String... sound) * * @param config The configuration section. */ - public QSGSound(ConfigurationSection config) - { - if (config == null) - { + public QSGSound(ConfigurationSection config) { + if (config == null) { return; } - this.sound = string2Sound(config.getString("name")); + this.sound = string2Sound(config.getString("name")); this.volume = (float) config.getDouble("volume"); - this.pitch = (float) config.getDouble("pitch"); + this.pitch = (float) config.getDouble("pitch"); + } + + /** + * Converts a string to a Sound. + * <p> + * "<code>ANVIL_LAND</code>", "<code>Anvil Land</code>" and "<code>ANVIL Land</code>" are recognized as + * <code>Sound.ANVIL_LAND</code>, as example. + * + * <p> + * If no sound match, common prefixes in the sounds name are tested. + * + * @param soundName The text to be converted. + * @return The corresponding Sound, or null if there isn't any match. + */ + public static Sound string2Sound(String soundName) { + if (soundName != null) { + soundName = soundName.trim().toUpperCase().replace(' ', '_').replace('.', '_'); + try { + return Sound.valueOf(soundName); + } + catch (IllegalArgumentException e) { + String[] prefixes = new String[] {"BLOCK_", "ENTITY_", "ITEM_", "MUSIC_", "WEATHER_"}; + for (String prefix : prefixes) { + try { + return Sound.valueOf(prefix + soundName); + } + catch (IllegalArgumentException ignored) { + } + } + + // Non-existent sound + return null; + } + } + + return null; + } + + @ConfigurationValueHandler + public static Sound handleSoundValue(final Object object) { + return string2Sound(object.toString()); + } + + @ConfigurationValueHandler + public static QSGSound handleUHSoundValue(final Map<String, Object> section) throws ConfigurationParseException { + if (!section.containsKey("name")) { + throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); + } + + final float volume = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("volume", 1f)); + final float pitch = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("pitch", 1f)); + + final Object names = section.get("name"); + + if (names == null) { + throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); + } else if (names instanceof Collection) { + final String[] soundNames = new String[((Collection) names).size()]; + + int i = 0; + for (final Object name : (Collection) names) { + soundNames[i++] = name.toString(); + } + + return new QSGSound(volume, pitch, soundNames); + } else { + return new QSGSound(names.toString(), volume, pitch); + } } /** @@ -201,8 +273,7 @@ public QSGSound(ConfigurationSection config) * * @param player The player. */ - public void play(Player player) - { + public void play(Player player) { play(player, player.getLocation()); } @@ -211,64 +282,53 @@ public void play(Player player) * <p> * If the sound is null, fails silently. * - * @param player The player. + * @param player The player. * @param location The location of the sound. */ - public void play(Player player, Location location) - { + public void play(Player player, Location location) { player.playSound(location, sound, volume, pitch); } /** * Plays this sound for all players, at the current location of the players. */ - public void broadcast() - { - for (Player player : Bukkit.getServer().getOnlinePlayers()) - { + public void broadcast() { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { play(player); } } - public Sound getSound() - { + public Sound getSound() { return sound; } - public void setSound(Sound sound) - { + public void setSound(Sound sound) { this.sound = sound; } - public Float getVolume() - { + public Float getVolume() { return volume; } - public void setVolume(Float volume) - { + public void setVolume(Float volume) { this.volume = volume; } - public Float getPitch() - { + public Float getPitch() { return pitch; } - public void setPitch(Float pitch) - { + public void setPitch(Float pitch) { this.pitch = pitch; } @Override - public String toString() - { + public String toString() { return "UHSound [sound=" + sound + ", volume=" + volume + ", pitch=" + pitch + "]"; } @Override - public int hashCode() - { + public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((pitch == null) ? 0 : pitch.hashCode()); @@ -278,103 +338,22 @@ public int hashCode() } @Override - public boolean equals(Object obj) - { - if (this == obj) return true; - if (!(obj instanceof QSGSound)) return false; - - final QSGSound other = (QSGSound) obj; - if (pitch == null) - { - if (other.pitch != null) - return false; + public boolean equals(Object obj) { + if (this == obj) { + return true; } - else if (!pitch.equals(other.pitch)) - { + if (!(obj instanceof QSGSound)) { return false; } - return sound == other.sound && (Objects.equals(volume, other.volume)); - } - - - /** - * Converts a string to a Sound. - * <p> - * "<code>ANVIL_LAND</code>", "<code>Anvil Land</code>" and "<code>ANVIL Land</code>" are recognized as - * <code>Sound.ANVIL_LAND</code>, as example. - * - * <p> - * If no sound match, common prefixes in the sounds name are tested. - * - * @param soundName The text to be converted. - * @return The corresponding Sound, or null if there isn't any match. - */ - public static Sound string2Sound(String soundName) - { - if (soundName != null) - { - soundName = soundName.trim().toUpperCase().replace(' ', '_').replace('.', '_'); - try - { - return Sound.valueOf(soundName); - } - catch (IllegalArgumentException e) - { - String[] prefixes = new String[] {"BLOCK_", "ENTITY_", "ITEM_", "MUSIC_", "WEATHER_"}; - for (String prefix : prefixes) - { - try { return Sound.valueOf(prefix + soundName); } - catch(IllegalArgumentException ignored) {} - } - - // Non-existent sound - return null; - } - } - - return null; - } - - @ConfigurationValueHandler - public static Sound handleSoundValue(final Object object) - { - return string2Sound(object.toString()); - } - - @ConfigurationValueHandler - public static QSGSound handleUHSoundValue(final Map<String, Object> section) throws ConfigurationParseException - { - if (!section.containsKey("name")) - throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); - - final float volume = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("volume", 1f)); - final float pitch = ConfigurationValueHandlers.handleFloatValue(section.getOrDefault("pitch", 1f)); - - final Object names = section.get("name"); - if (names == null) - { - throw new ConfigurationParseException("Missing key `name` in sound (either string or list)", section); - } - else if (names instanceof Collection) - { - final String[] soundNames = new String[((Collection) names).size()]; - - int i = 0; - for (final Object name : (Collection) names) - { - soundNames[i++] = name.toString(); + final QSGSound other = (QSGSound) obj; + if (pitch == null) { + if (other.pitch != null) { + return false; } - - return new QSGSound(volume, pitch, soundNames); - } - else - { - return new QSGSound(names.toString(), volume, pitch); + } else if (!pitch.equals(other.pitch)) { + return false; } - } - - static { - ConfigurationValueHandlers.registerHandlers(QSGSound.class); + return sound == other.sound && (Objects.equals(volume, other.volume)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java index 4d70f43..85a6f20 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/QSGUtils.java @@ -36,50 +36,47 @@ import fr.zcraft.quartzlib.components.rawtext.RawTextPart; import fr.zcraft.quartzlib.tools.Callback; import fr.zcraft.quartzlib.tools.PluginLogger; +import java.util.Random; +import java.util.stream.IntStream; import org.apache.commons.lang.Validate; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Builder; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; -import java.util.Random; -import java.util.stream.IntStream; - -public class QSGUtils -{ +public class QSGUtils { private final static Random random = new Random(); /** * Extracts a string from a list of arguments, starting at the given index. * - * @param args The raw arguments. + * @param args The raw arguments. * @param startIndex The index of the first item in the returned string (first argument given: 0). - * * @return The extracted string. - * * @throws IllegalArgumentException if the index of the first element is out of the bounds of the arguments' list. */ - public static String getStringFromCommandArguments(String[] args, int startIndex) - { - if (args.length < startIndex) - { - throw new IllegalArgumentException("The index of the first element is out of the bounds of the arguments' list."); + public static String getStringFromCommandArguments(String[] args, int startIndex) { + if (args.length < startIndex) { + throw new IllegalArgumentException( + "The index of the first element is out of the bounds of the arguments' list."); } final StringBuilder text = new StringBuilder(); - for (int index = startIndex; index < args.length; index++) - { - if (index < args.length - 1) - { + for (int index = startIndex; index < args.length; index++) { + if (index < args.length - 1) { text.append(args[index]).append(" "); - } - else - { + } else { text.append(args[index]); } } @@ -97,31 +94,26 @@ public static String getStringFromCommandArguments(String[] args, int startIndex * <li><tt>hh:mm:ss</tt> – hours, minutes and seconds.</li> * </ul> * - * * @param text The text to be converted. * @return The number of seconds represented by this string. - * * @throws IllegalArgumentException if the text is not formatted as above. - * @throws NumberFormatException if the text between the colons cannot be converted in integers. + * @throws NumberFormatException if the text between the colons cannot be converted in integers. */ - public static int string2Time(String text) - { + public static int string2Time(String text) { String[] split = text.split(":"); - if (text.isEmpty() || split.length > 3) - { - throw new IllegalArgumentException("Badly formatted string in string2time, formats allowed are mm, mm:ss or hh:mm:ss."); + if (text.isEmpty() || split.length > 3) { + throw new IllegalArgumentException( + "Badly formatted string in string2time, formats allowed are mm, mm:ss or hh:mm:ss."); } if (split.length == 1) // "mm" { return Integer.valueOf(split[0]) * 60; - } - else if (split.length == 2) // "mm:ss" + } else if (split.length == 2) // "mm:ss" { return Integer.valueOf(split[0]) * 60 + Integer.valueOf(split[1]); - } - else // "hh:mm:ss" + } else // "hh:mm:ss" { return Integer.valueOf(split[0]) * 3600 + Integer.valueOf(split[1]) * 60 + Integer.valueOf(split[2]); } @@ -129,23 +121,19 @@ else if (split.length == 2) // "mm:ss" /** * Converts a string to a number of seconds. - * + * <p> * Prints a warning if the format is invalid. * - * @param text The text to be converted. + * @param text The text to be converted. * @param defaultValue The default value returned if the format is invalid. - * * @return The extracted seconds, or the default value if invalid. * @see #string2Time(String) */ - public static int string2Time(String text, Integer defaultValue) - { - try - { + public static int string2Time(String text, Integer defaultValue) { + try { return string2Time(text); } - catch (IllegalArgumentException | NullPointerException e) - { + catch (IllegalArgumentException | NullPointerException e) { PluginLogger.warning("Invalid duration '{0}', using {1} seconds instead.", text, defaultValue); return defaultValue; } @@ -155,15 +143,14 @@ public static int string2Time(String text, Integer defaultValue) * Converts a string to a boolean. * * <p> - * {@code true, on, 1, yes} (case insensitive) -> {@code true}.<br /> - * Anything else ({@code null} included) -> {@code false}. + * {@code true, on, 1, yes} (case insensitive) -> {@code true}.<br /> + * Anything else ({@code null} included) -> {@code false}. * </p> * * @param raw The raw string. * @return a boolean. */ - public static boolean stringToBoolean(String raw) - { + public static boolean stringToBoolean(String raw) { return raw != null && ( raw.equalsIgnoreCase("true") @@ -177,9 +164,8 @@ public static boolean stringToBoolean(String raw) * @param integer An integer. * @return A string representation of this integer, with an explicit "+" if positive. */ - public static String integerToStringWithSign(int integer) - { - return (integer < 0 ? "" : "+") + String.valueOf(integer); + public static String integerToStringWithSign(int integer) { + return (integer < 0 ? "" : "+") + integer; } @@ -189,21 +175,18 @@ public static String integerToStringWithSign(int integer) * * @param player * @param location - * @param force If true the player will be teleported to the exact given location if there is no safe spot. + * @param force If true the player will be teleported to the exact given location if there is no safe spot. * @return true if the player was effectively teleported. */ - public static boolean safeTP(Player player, Location location, boolean force) - { + public static boolean safeTP(Player player, Location location, boolean force) { // If the target is safe, let's go - if (isSafeSpot(location)) - { + if (isSafeSpot(location)) { player.teleport(location); return true; } // If the teleportation is forced, let's go - if (force) - { + if (force) { player.teleport(location); return true; } @@ -211,14 +194,12 @@ public static boolean safeTP(Player player, Location location, boolean force) final Location safeSpot = searchSafeSpot(location); // A spot was found, let's teleport. - if (safeSpot != null) - { + if (safeSpot != null) { player.teleport(safeSpot); return true; } // No spot found; the teleportation is cancelled. - else - { + else { return false; } } @@ -231,45 +212,40 @@ public static boolean safeTP(Player player, Location location, boolean force) * @param location * @return true if the player was effectively teleported. */ - public static boolean safeTP(Player player, Location location) - { + public static boolean safeTP(Player player, Location location) { return safeTP(player, location, false); } /** * Searches a safe spot in the given location. - * + * <p> * The spot is in the same X;Z coordinates. * * @param location The location where to find a safe spot. * @return A Location object representing the safe spot, or null if no safe spot is available. */ - public static Location searchSafeSpot(Location location) - { + public static Location searchSafeSpot(Location location) { // We try to find a spot above or below the target Location safeSpot = null; - final int maxHeight = (location.getWorld().getEnvironment() == World.Environment.NETHER) ? 125 : location.getWorld().getMaxHeight() - 2; // (thx to WorldBorder) + final int maxHeight = (location.getWorld().getEnvironment() == World.Environment.NETHER) ? 125 : + location.getWorld().getMaxHeight() - 2; // (thx to WorldBorder) - for (int yGrow = location.getBlockY(), yDecr = location.getBlockY(); yDecr >= 1 || yGrow <= maxHeight; yDecr--, yGrow++) - { + for (int yGrow = location.getBlockY(), yDecr = location.getBlockY(); yDecr >= 1 || yGrow <= maxHeight; + yDecr--, yGrow++) { // Above? - if (yGrow < maxHeight) - { + if (yGrow < maxHeight) { Location spot = new Location(location.getWorld(), location.getBlockX(), yGrow, location.getBlockZ()); - if (isSafeSpot(spot)) - { + if (isSafeSpot(spot)) { safeSpot = spot; break; } } // Below? - if (yDecr > 1 && yDecr != yGrow) - { + if (yDecr > 1 && yDecr != yGrow) { Location spot = new Location(location.getWorld(), location.getX(), yDecr, location.getZ()); - if (isSafeSpot(spot)) - { + if (isSafeSpot(spot)) { safeSpot = spot; break; } @@ -277,8 +253,7 @@ public static Location searchSafeSpot(Location location) } // A spot was found, we changes the pitch & yaw according to the original location. - if (safeSpot != null) - { + if (safeSpot != null) { safeSpot.setPitch(location.getPitch()); safeSpot.setYaw(location.getYaw()); } @@ -294,22 +269,26 @@ public static Location searchSafeSpot(Location location) * @param location * @return true if the location is safe. */ - public static boolean isSafeSpot(Location location) - { - Block blockCenter = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - Block blockAbove = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()); - Block blockBelow = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() - 1, location.getBlockZ()); - - if ((blockCenter.getType().isTransparent() || (blockCenter.isLiquid() && !blockCenter.getType().equals(Material.LAVA) && !blockCenter.getType().equals(Material.STATIONARY_LAVA))) - && (blockAbove.getType().isTransparent() || (blockAbove.isLiquid() && !blockAbove.getType().equals(Material.LAVA) && !blockCenter.getType().equals(Material.STATIONARY_LAVA)))) - { + public static boolean isSafeSpot(Location location) { + Block blockCenter = + location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + Block blockAbove = + location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()); + Block blockBelow = + location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() - 1, location.getBlockZ()); + + if ((blockCenter.getType().isTransparent() || + (blockCenter.isLiquid() && !blockCenter.getType().equals(Material.LAVA) && + !blockCenter.getType().equals(Material.LAVA))) + && (blockAbove.getType().isTransparent() || + (blockAbove.isLiquid() && !blockAbove.getType().equals(Material.LAVA) && + !blockCenter.getType().equals(Material.LAVA)))) { // two breathable blocks: ok // The block below is solid, or liquid (but not lava) - return blockBelow.getType().isSolid() || blockBelow.getType().equals(Material.WATER) || blockBelow.getType().equals(Material.STATIONARY_WATER); - } - else - { + return blockBelow.getType().isSolid() || blockBelow.getType().equals(Material.WATER) || + blockBelow.getType().equals(Material.LAVA); + } else { return false; } } @@ -317,22 +296,21 @@ public static boolean isSafeSpot(Location location) /** * Spawns a random firework at the given location. - * + * <p> * Please note: because the power of a firework is an integer, the min/max heights * are with a precision of ±5 blocks. * - * @param location The location where the firework will be spawned. + * @param location The location where the firework will be spawned. * @param heightMin The minimal height of the explosion. * @param heightMax The maximal height of the explosion. - * * @return The random firework generated. */ - public static Firework generateRandomFirework(Location location, int heightMin, int heightMax) - { + public static Firework generateRandomFirework(Location location, int heightMin, int heightMax) { final Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK); final FireworkMeta meta = firework.getFireworkMeta(); - IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomFireworkEffect()).forEach(meta::addEffect); + IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomFireworkEffect()) + .forEach(meta::addEffect); // One level of power is half a second of flight time. // In half a second, a firework fly ~5 blocks. @@ -349,15 +327,16 @@ public static Firework generateRandomFirework(Location location, int heightMin, * * @return The firework effect. */ - private static FireworkEffect generateRandomFireworkEffect() - { + private static FireworkEffect generateRandomFireworkEffect() { Builder fireworkBuilder = FireworkEffect.builder(); fireworkBuilder.flicker(random.nextInt(3) == 1); fireworkBuilder.trail(random.nextInt(3) == 1); - IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomColor()).forEach(fireworkBuilder::withColor); - IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomColor()).forEach(fireworkBuilder::withFade); + IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomColor()) + .forEach(fireworkBuilder::withColor); + IntStream.range(0, random.nextInt(3) + 1).mapToObj(i -> generateRandomColor()) + .forEach(fireworkBuilder::withFade); // Random shape FireworkEffect.Type[] types = FireworkEffect.Type.values(); @@ -371,8 +350,7 @@ private static FireworkEffect generateRandomFireworkEffect() * * @return The color. */ - private static Color generateRandomColor() - { + private static Color generateRandomColor() { return Color.fromBGR(random.nextInt(256), random.nextInt(256), random.nextInt(256)); } @@ -381,11 +359,12 @@ private static Color generateRandomColor() * * @param callback The callback * @param argument The callback's argument. - * @param <T> The callback's argument type. + * @param <T> The callback's argument type. */ - public static <T> void callIfDefined(Callback<T> callback, T argument) - { - if (callback != null) callback.call(argument); + public static <T> void callIfDefined(Callback<T> callback, T argument) { + if (callback != null) { + callback.call(argument); + } } /** @@ -393,10 +372,10 @@ public static <T> void callIfDefined(Callback<T> callback, T argument) * * @return the... overworld? */ - public static World getOverworld() - { + public static World getOverworld() { return Bukkit.getServer().getWorlds().stream() - .filter(world -> world.getEnvironment() != World.Environment.NETHER && world.getEnvironment() != World.Environment.THE_END) + .filter(world -> world.getEnvironment() != World.Environment.NETHER && + world.getEnvironment() != World.Environment.THE_END) .findFirst().orElse(null); } @@ -408,11 +387,9 @@ public static World getOverworld() * @param shift A shift. If this is positive, will return the (shift)th * element after, else the |shift|th element before. The enum * is visited as a cycle. - * * @return The next/previous/other enum value, according to shift. */ - public static <T extends Enum> T getNextElement(final T enumValue, final int shift) - { + public static <T extends Enum> T getNextElement(final T enumValue, final int shift) { return getNextElement(enumValue, shift, false, null); } @@ -420,25 +397,27 @@ public static <T extends Enum> T getNextElement(final T enumValue, final int shi * Returns the next (or other...) enum value, as declared in the source * code. * - * @param enumValue An enum value. - * @param shift A shift. If this is positive, will return the (shift)th - * element after, else the |shift|th element before. The enum - * is visited as a cycle. + * @param enumValue An enum value. + * @param shift A shift. If this is positive, will return the (shift)th + * element after, else the |shift|th element before. The enum + * is visited as a cycle. * @param shiftThroughNull If {@code true}, will return {@code null} after the * last element, and the first element after {@code null}. * Else, will throw an {@link IllegalArgumentException} if * the given element is {@code null}. - * @param enumClass The (non-empty) enum class, required if - * {@code shiftThroughNull = true}. Else, can be {@code null}. - * @param <T> The enum type. - * + * @param enumClass The (non-empty) enum class, required if + * {@code shiftThroughNull = true}. Else, can be {@code null}. + * @param <T> The enum type. * @return The next/previous/other enum value, according to shift. */ - public static <T extends Enum> T getNextElement(final T enumValue, final int shift, final boolean shiftThroughNull, Class<T> enumClass) - { - Validate.isTrue(shiftThroughNull || enumValue != null, "The enum value cannot be null with shiftThroughNull = false."); + public static <T extends Enum> T getNextElement(final T enumValue, final int shift, final boolean shiftThroughNull, + Class<T> enumClass) { + Validate.isTrue(shiftThroughNull || enumValue != null, + "The enum value cannot be null with shiftThroughNull = false."); - if (enumValue != null) enumClass = (Class<T>) enumValue.getClass(); + if (enumValue != null) { + enumClass = (Class<T>) enumValue.getClass(); + } final T[] values = enumClass.getEnumConstants(); final int ord = enumValue != null ? enumValue.ordinal() : values.length; @@ -446,22 +425,24 @@ public static <T extends Enum> T getNextElement(final T enumValue, final int shi final int shiftLength = shiftThroughNull ? values.length + 1 : values.length; int newOrd = (ord + shift) % shiftLength; - if (newOrd < 0) newOrd += shiftLength; + if (newOrd < 0) { + newOrd += shiftLength; + } - if (shiftThroughNull && newOrd == values.length) return null; + if (shiftThroughNull && newOrd == values.length) { + return null; + } return values[newOrd]; } /** * Generates a message prefixed with a prefix and a separator, for chat. * - * @param prefix The prefix. + * @param prefix The prefix. * @param message The message. - * * @return The formatted prefixed message. */ - public static String prefixedMessage(final String prefix, final String message) - { + public static String prefixedMessage(final String prefix, final String message) { return ChatColor.GREEN + prefix + ChatColor.GRAY + " \u2758 " + ChatColor.RESET + message; } @@ -472,8 +453,7 @@ public static String prefixedMessage(final String prefix, final String message) * @param prefix The prefix. * @return The RawText, ready to be extended. */ - public static RawTextPart prefixedRaxText(final String prefix) - { + public static RawTextPart prefixedRaxText(final String prefix) { return new RawText() .then(prefix).color(ChatColor.GREEN) .then(" \u2758 ").color(ChatColor.GRAY); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java index 1ddcc42..cfb728d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/RecipesUtils.java @@ -29,29 +29,28 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.utils; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - /** * Utility class to compare Bukkit recipes.<br> * Useful for identifying your recipes in events, where recipes are re-generated in a different manner. * - * @version R1.3 * @author Digi + * @version R1.3 */ -public class RecipesUtils -{ +public class RecipesUtils { /** * Checks if both recipes are equal.<br> * Compares both ingredients and results.<br> @@ -61,12 +60,12 @@ public class RecipesUtils * @param recipe1 the first recipe * @param recipe2 the second recipe * @return true if ingredients and results match, false otherwise. - * @throws IllegalArgumentException - * if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. + * @throws IllegalArgumentException if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. */ - public static boolean areEqual(Recipe recipe1, Recipe recipe2) - { - return recipe1 == recipe2 || !(recipe1 == null || recipe2 == null) && recipe1.getResult().equals(recipe2.getResult()) && match(recipe1, recipe2); + public static boolean areEqual(Recipe recipe1, Recipe recipe2) { + return recipe1 == recipe2 || + !(recipe1 == null || recipe2 == null) && recipe1.getResult().equals(recipe2.getResult()) && + match(recipe1, recipe2); } @@ -79,20 +78,15 @@ public static boolean areEqual(Recipe recipe1, Recipe recipe2) * @param recipe1 the first recipe * @param recipe2 the second recipe * @return true if ingredients match, false otherwise. - * @throws IllegalArgumentException - * if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. + * @throws IllegalArgumentException if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. */ - public static boolean areSimilar(Recipe recipe1, Recipe recipe2) - { + public static boolean areSimilar(Recipe recipe1, Recipe recipe2) { return recipe1 == recipe2 || !(recipe1 == null || recipe2 == null) && match(recipe1, recipe2); } - private static boolean match(Recipe recipe1, Recipe recipe2) - { - if (recipe1 instanceof ShapedRecipe) - { - if (!(recipe2 instanceof ShapedRecipe)) - { + private static boolean match(Recipe recipe1, Recipe recipe2) { + if (recipe1 instanceof ShapedRecipe) { + if (!(recipe2 instanceof ShapedRecipe)) { return false; // if other recipe is not the same type then they're not equal. } @@ -103,7 +97,8 @@ private static boolean match(Recipe recipe1, Recipe recipe2) final ItemStack[] matrix1 = shapeToMatrix(r1.getShape(), r1.getIngredientMap()); final ItemStack[] matrix2 = shapeToMatrix(r2.getShape(), r2.getIngredientMap()); - if (!Arrays.equals(matrix1, matrix2)) // compare arrays and if they don't match run another check with one shape mirrored. + if (!Arrays.equals(matrix1, + matrix2)) // compare arrays and if they don't match run another check with one shape mirrored. { mirrorMatrix(matrix1); @@ -111,11 +106,8 @@ private static boolean match(Recipe recipe1, Recipe recipe2) } return true; // ingredients match. - } - else if (recipe1 instanceof ShapelessRecipe) - { - if (!(recipe2 instanceof ShapelessRecipe)) - { + } else if (recipe1 instanceof ShapelessRecipe) { + if (!(recipe2 instanceof ShapelessRecipe)) { return false; // if other recipe is not the same type then they're not equal. } @@ -126,25 +118,19 @@ else if (recipe1 instanceof ShapelessRecipe) final List<ItemStack> find = r1.getIngredientList(); final List<ItemStack> compare = r2.getIngredientList(); - if (find.size() != compare.size()) - { + if (find.size() != compare.size()) { return false; // if they don't have the same amount of ingredients they're not equal. } - for (ItemStack item : compare) - { - if (!find.remove(item)) - { + for (ItemStack item : compare) { + if (!find.remove(item)) { return false; // if ingredient wasn't removed (not found) then they're not equal. } } return find.isEmpty(); // if there are any ingredients not removed then they're not equal. - } - else if (recipe1 instanceof FurnaceRecipe) - { - if (!(recipe2 instanceof FurnaceRecipe)) - { + } else if (recipe1 instanceof FurnaceRecipe) { + if (!(recipe2 instanceof FurnaceRecipe)) { return false; // if other recipe is not the same type then they're not equal. } @@ -152,22 +138,17 @@ else if (recipe1 instanceof FurnaceRecipe) final FurnaceRecipe r2 = (FurnaceRecipe) recipe2; return r1.getInput().getType() == r2.getInput().getType(); - } - else - { + } else { throw new IllegalArgumentException("Unsupported recipe type: '" + recipe1 + "', update this class!"); } } - private static ItemStack[] shapeToMatrix(String[] shape, Map<Character, ItemStack> map) - { + private static ItemStack[] shapeToMatrix(String[] shape, Map<Character, ItemStack> map) { final ItemStack[] matrix = new ItemStack[9]; int slot = 0; - for (int r = 0; r < shape.length; r++) - { - for (char col : shape[r].toCharArray()) - { + for (int r = 0; r < shape.length; r++) { + for (char col : shape[r].toCharArray()) { matrix[slot] = map.get(col); slot++; } @@ -178,12 +159,10 @@ private static ItemStack[] shapeToMatrix(String[] shape, Map<Character, ItemStac return matrix; } - private static void mirrorMatrix(ItemStack[] matrix) - { + private static void mirrorMatrix(ItemStack[] matrix) { ItemStack tmp; - for (int r = 0; r < 3; r++) - { + for (int r = 0; r < 3; r++) { tmp = matrix[(r * 3)]; matrix[(r * 3)] = matrix[(r * 3) + 2]; matrix[(r * 3) + 2] = tmp; @@ -194,22 +173,16 @@ private static void mirrorMatrix(ItemStack[] matrix) /** * Returns the list of the ingredients of the given recipe. * - * @author Amaury Carrade - * * @param recipe The recipe to analyze. * @return A list of the ingredients. + * @author Amaury Carrade */ - public static List<ItemStack> getListOfIngredients(Recipe recipe) - { + public static List<ItemStack> getListOfIngredients(Recipe recipe) { List<ItemStack> listOfItems; - if (recipe instanceof ShapelessRecipe) - { + if (recipe instanceof ShapelessRecipe) { listOfItems = ((ShapelessRecipe) recipe).getIngredientList(); - } - else - { - try - { + } else { + try { listOfItems = new LinkedList<>(((ShapedRecipe) recipe).getIngredientMap().values()); } catch (NullPointerException e) // If the list of items is null diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java index 0d1f2ad..4d519ee 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/Run.java @@ -31,44 +31,43 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.utils; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.ActionBar; import fr.zcraft.quartzlib.tools.text.MessageSender; +import java.util.function.Function; +import java.util.function.Supplier; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -import java.util.function.Function; -import java.util.function.Supplier; - -public class Run -{ +public class Run { private final static String ACTION_BAR_SEPARATOR = " " + ChatColor.GRAY + "\u2758" + ChatColor.RESET + " "; /** * Executes a task after a delay, displaying a countdown in the players' * action bar at the end. * - * @param title A title displayed in the left of the action bar. - * @param subtitle A subtitle displayed during the whole countdown in - * the right of the action bar. If {@code null}, the - * action bar will only display something when the - * countdown will be about to end. + * @param title A title displayed in the left of the action bar. + * @param subtitle A subtitle displayed during the whole countdown in + * the right of the action bar. If {@code null}, the + * action bar will only display something when the + * countdown will be about to end. * @param subtitleDuringCountdown A subtitle displayed during the last * seconds of the cooldown. Receives the * current second (will be decreasing) and * returns a subtitle. - * @param subtitleAfter A subtitle displayed a few seconds after the task - * has been run, e.g. to display a message stating that - * the task is done. If {@code null}, the last countdown - * message wil simply fade out. - * @param receivers The players who will receive the countdown in their - * action bar. - * @param task The task to execute after the delay. - * @param delay The delay. + * @param subtitleAfter A subtitle displayed a few seconds after the task + * has been run, e.g. to display a message stating that + * the task is done. If {@code null}, the last countdown + * message wil simply fade out. + * @param receivers The players who will receive the countdown in their + * action bar. + * @param task The task to execute after the delay. + * @param delay The delay. */ public static void withCountdown( final String title, @@ -77,8 +76,7 @@ public static void withCountdown( final String subtitleAfter, final Supplier<Iterable<Player>> receivers, final Runnable task, - final TimeDelta delay) - { + final TimeDelta delay) { withCountdown(title, subtitle, subtitleDuringCountdown, subtitleAfter, (short) 5, receivers, task, delay); } @@ -86,23 +84,23 @@ public static void withCountdown( * Executes a task after a delay, displaying a countdown in the players' * action bar at the end. * - * @param title A title displayed in the left of the action bar. - * @param subtitle A subtitle displayed during the whole countdown in - * the right of the action bar. If {@code null}, the - * action bar will only display something when the - * countdown will be about to end. + * @param title A title displayed in the left of the action bar. + * @param subtitle A subtitle displayed during the whole countdown in + * the right of the action bar. If {@code null}, the + * action bar will only display something when the + * countdown will be about to end. * @param subtitleDuringCountdown A subtitle displayed during the last * seconds of the cooldown. Receives the * current second (will be decreasing) and * returns a subtitle. - * @param visibleCountdownBefore When there will be less than this number of - * seconds before the end of the countdown, - * the subtitle will switch from the defined - * static subtitle to the visible countdown. - * @param receivers The players who will receive the countdown in their - * action bar. - * @param task The task to execute after the delay. - * @param delay The delay. + * @param visibleCountdownBefore When there will be less than this number of + * seconds before the end of the countdown, + * the subtitle will switch from the defined + * static subtitle to the visible countdown. + * @param receivers The players who will receive the countdown in their + * action bar. + * @param task The task to execute after the delay. + * @param delay The delay. */ public static void withCountdown( final String title, @@ -112,20 +110,19 @@ public static void withCountdown( final short visibleCountdownBefore, final Supplier<Iterable<Player>> receivers, final Runnable task, - final TimeDelta delay) - { + final TimeDelta delay) { // The countdown is not visible at the beginning - if (visibleCountdownBefore < delay.getSeconds()) - { - if (subtitle != null) - { + if (visibleCountdownBefore < delay.getSeconds()) { + if (subtitle != null) { final Iterable<Player> initialReceivers = receivers.get(); - initialReceivers.forEach(receiver -> ActionBar.sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitle)); + initialReceivers.forEach( + receiver -> ActionBar.sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitle)); // As the receivers list is recalculated each time (to allow for new players), this ensures // players who received the initial message will not have it kept during the whole game // if they were disconnected at the end. - RunTask.later(() -> initialReceivers.forEach(ActionBar::removeMessage), (delay.getSeconds() - visibleCountdownBefore) * 20L); + RunTask.later(() -> initialReceivers.forEach(ActionBar::removeMessage), + (delay.getSeconds() - visibleCountdownBefore) * 20L); } RunTask.timer( @@ -141,8 +138,7 @@ public static void withCountdown( } // The countdown is immediately visible. - else - { + else { RunTask.timer( new CountdownRunnable( title, @@ -156,14 +152,13 @@ public static void withCountdown( } } - private static class CountdownRunnable extends BukkitRunnable - { + private static class CountdownRunnable extends BukkitRunnable { private final String title; private final Function<Short, String> subtitleDuringCountdown; private final String subtitleAfter; private final Supplier<Iterable<Player>> receivers; - private short secondsLeft; private final Runnable task; + private short secondsLeft; private CountdownRunnable( final String title, @@ -171,8 +166,7 @@ private CountdownRunnable( final String subtitleAfter, final Supplier<Iterable<Player>> receivers, final short secondsLeft, - final Runnable task) - { + final Runnable task) { this.title = title; this.subtitleDuringCountdown = subtitleDuringCountdown; this.subtitleAfter = subtitleAfter; @@ -182,36 +176,30 @@ private CountdownRunnable( } @Override - public void run() - { - if (secondsLeft == 0) - { - if (subtitleAfter != null) - { + public void run() { + if (secondsLeft == 0) { + if (subtitleAfter != null) { final Iterable<Player> finalReceivers = receivers.get(); - finalReceivers.forEach(receiver -> ActionBar.sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitleAfter)); + finalReceivers.forEach(receiver -> ActionBar + .sendPermanentMessage(receiver, title + ACTION_BAR_SEPARATOR + subtitleAfter)); RunTask.later(() -> finalReceivers.forEach(ActionBar::removeMessage), 60L); - } - else - { + } else { receivers.get() - .forEach(receiver -> MessageSender.sendActionBarMessage( - receiver, - title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) - )); + .forEach(receiver -> MessageSender.sendActionBarMessage( + receiver, + title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) + )); } task.run(); cancel(); - } - else - { + } else { receivers.get() - .forEach(receiver -> MessageSender.sendActionBarMessage( - receiver, - title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) - )); + .forEach(receiver -> MessageSender.sendActionBarMessage( + receiver, + title + ACTION_BAR_SEPARATOR + subtitleDuringCountdown.apply(secondsLeft) + )); secondsLeft--; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java index 6edb92b..2cd378c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/utils/TextUtils.java @@ -29,37 +29,38 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.utils; import com.google.common.collect.Sets; -import org.apache.commons.lang.WordUtils; - import java.util.Set; +import org.apache.commons.lang.WordUtils; -public final class TextUtils -{ - private TextUtils() {} - +public final class TextUtils { private static final Set<String> SMALL_WORDS = Sets.newHashSet( // English "the", "a", "it", "they", "them", "an", "all", "of", "this", "is", "not", "that", // French - "un", "une", "le", "la", "les", "des", "je", "tu", "il", "elle", "on", "nous", "vous", "ils", "elles", "ça", "ca", "sa", "cela", "lui", "l" + "un", "une", "le", "la", "les", "des", "je", "tu", "il", "elle", "on", "nous", "vous", "ils", "elles", "ça", + "ca", "sa", "cela", "lui", "l" ); + private TextUtils() { + } + /** * Tries to find a single alphanumeric character best representing this string. * * @param text The string. * @return An alphanumeric character. A space if the initial text is blank. */ - public static char getInitialLetter(String text) - { + public static char getInitialLetter(String text) { text = toAlphanumeric(text); - if (text == null || text.isEmpty()) + if (text == null || text.isEmpty()) { return ' '; + } // We try to find the main word of the sentence, based on four principles: // - the main word is likely to be at the beginning of the string; @@ -70,32 +71,34 @@ public static char getInitialLetter(String text) String[] words = text.split(" "); Integer bestScore = Integer.MIN_VALUE; - String bestWord = " "; + String bestWord = " "; int averageWordLength = 0; - for (String word : words) + for (String word : words) { averageWordLength += word.length(); + } averageWordLength /= words.length; - for (int i = 0, wordsCount = words.length; i < wordsCount; i++) - { + for (int i = 0, wordsCount = words.length; i < wordsCount; i++) { String word = words[i].toLowerCase(); Integer score = 0; - if (i < 3) + if (i < 3) { score += 5; + } - if (word.length() == 1) + if (word.length() == 1) { score -= 3; - else if (word.length() >= averageWordLength) + } else if (word.length() >= averageWordLength) { score += 5; + } - if (SMALL_WORDS.contains(word)) + if (SMALL_WORDS.contains(word)) { score -= 10; + } - if (score > bestScore) - { + if (score > bestScore) { bestScore = score; bestWord = words[i]; } @@ -110,30 +113,33 @@ else if (word.length() >= averageWordLength) * @param text The text. * @return The same text, without non-alphanumeric characters. */ - public static String toAlphanumeric(String text) - { - if (text == null) return null; + public static String toAlphanumeric(String text) { + if (text == null) { + return null; + } final StringBuilder builder = new StringBuilder(); - for (Character character : text.toCharArray()) - { + for (Character character : text.toCharArray()) { // Convert all kind of spaces (unbreakable...) and apostrophes to basic spaces - if (Character.isSpaceChar(character) || character.equals('\'')) + if (Character.isSpaceChar(character) || character.equals('\'')) { builder.append(" "); + } - if (Character.isTitleCase(character)) + if (Character.isTitleCase(character)) { character = Character.toUpperCase(character); + } // Only keeps alphanumeric characters - if ((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9')) + if ((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || + (character >= '0' && character <= '9')) { builder.append(character); + } } return builder.toString(); } - public static String friendlyEnumName(Enum<?> enumConstant) - { + public static String friendlyEnumName(Enum<?> enumConstant) { return WordUtils.capitalizeFully(enumConstant.name().replace("_", " ")); } } From a4e07920fe40edbce9b8024c6cba88368003c588 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 26 Nov 2020 19:03:30 +0100 Subject: [PATCH 76/91] Migrate to Quartz{Lib,Teams} 0.0.2 --- pom.xml | 10 +- .../amaury/quartzsurvivalgames/QSGConfig.java | 10 +- .../QuartzSurvivalGames.java | 109 ++--- .../core/ModuleWrapper.java | 4 +- .../core/ModulesManager.java | 7 +- .../modules/core/border/BorderModule.java | 38 +- .../core/border/WorldBorderDependency.java | 18 +- .../core/game/submanagers/GameBeginning.java | 25 +- .../modules/core/modules/ModulesModule.java | 22 +- .../commands/ConfigurationCommand.java | 9 +- .../core/modules/commands/ModuleCommand.java | 116 ++--- .../core/modules/commands/ModulesCommand.java | 107 ++-- .../core/modules/gui/MainConfigGUI.java | 108 ++-- .../gui/modules/ConfirmModuleDisableGUI.java | 32 +- .../modules/gui/modules/FramedModuleGUI.java | 26 +- .../modules/gui/modules/ModulesListGUI.java | 213 ++++---- .../core/modules/gui/start/StartGameGUI.java | 50 +- .../modules/core/sidebar/GameSidebar.java | 21 +- .../modules/core/sidebar/SidebarInjector.java | 188 ++++--- .../modules/core/sidebar/SidebarModule.java | 14 +- .../modules/core/spawns/Config.java | 21 +- .../modules/core/spawns/Generator.java | 37 +- .../modules/core/spawns/SpawnsModule.java | 127 +++-- .../core/spawns/commands/SpawnsCommand.java | 348 ++++++------- .../CannotGenerateSpawnPointsException.java | 6 +- .../exceptions/UnknownGeneratorException.java | 7 +- .../CircularSpawnPointsGenerator.java | 60 +-- .../generators/GridSpawnPointsGenerator.java | 68 +-- .../RandomSpawnPointsGenerator.java | 82 ++-- .../generators/SpawnPointsGenerator.java | 15 +- .../modules/core/spectators/Config.java | 21 +- .../spectators/SpectatorPlusDependency.java | 33 +- .../core/spectators/SpectatorsModule.java | 124 +++-- .../commands/SpectatorsCommand.java | 80 ++- .../managers/SPlusSpectatorsManager.java | 17 +- .../managers/SpectatorsManager.java | 43 +- .../managers/VanillaSpectatorsManager.java | 32 +- .../modules/core/teams/Config.java | 4 +- .../modules/core/timers/TimeDelta.java | 107 ++-- .../modules/core/timers/Timer.java | 206 +++----- .../modules/core/timers/TimersModule.java | 78 ++- .../core/timers/commands/TimersCommand.java | 317 ++++++------ .../core/timers/events/TimerEndsEvent.java | 50 +- .../core/timers/events/TimerStartsEvent.java | 27 +- .../modules/cosmetics/KillsCountModule.java | 31 +- .../modules/cosmetics/ListHealthModule.java | 23 +- .../modules/cosmetics/episodes/Config.java | 17 +- .../cosmetics/episodes/EpisodesModule.java | 70 ++- .../episodes/commands/ShiftCommand.java | 18 +- .../episodes/events/EpisodeChangedEvent.java | 47 +- .../cosmetics/hardcoreHearts/Config.java | 22 +- .../hardcoreHearts/HardcoreHeartsModule.java | 15 +- .../hardcoreHearts/PacketsListener.java | 30 +- .../playerListHeaderFooter/Config.java | 15 +- .../ListPlaceholdersCommand.java | 41 +- .../PlayerListHeaderFooterModule.java | 119 +++-- .../modules/end/deathAnnouncement/Config.java | 1 + .../modules/end/kick/Config.java | 1 + .../modules/end/xpToKillers/Config.java | 1 + .../modules/external/dynmap/Config.java | 17 +- .../modules/external/dynmap/DynmapModule.java | 109 ++--- .../modules/external/hawk/Config.java | 108 ++-- .../modules/external/hawk/HawkModule.java | 460 +++++++++--------- .../modules/external/motd/Config.java | 17 +- .../modules/external/motd/MotdModule.java | 53 +- .../gameplay/NoEnderPearlDamagesModule.java | 12 +- .../modules/gameplay/NoGhastTearsModule.java | 36 +- .../gameplay/OnerousGlisteringMelon.java | 15 +- .../gameplay/compass/CompassModule.java | 137 +++--- .../gameplay/compass/CompassRecipes.java | 94 ++-- .../modules/gameplay/compass/Config.java | 27 +- .../gameplay/daylightCycle/Config.java | 21 +- .../daylightCycle/DaylightCycleModule.java | 47 +- .../modules/gameplay/goldenHeads/Config.java | 50 +- .../goldenHeads/GoldenHeadsModule.java | 232 ++++----- .../modules/gameplay/hardcore/Config.java | 19 +- .../gameplay/hardcore/HardcoreModule.java | 24 +- .../modules/gameplay/killerRabbit/Config.java | 17 +- .../killerRabbit/KillerRabbitModule.java | 21 +- .../modules/gameplay/noWitches/Config.java | 17 +- .../gameplay/noWitches/NoWitchesModule.java | 18 +- .../gameplay/potions/CancelBrewTask.java | 52 +- .../modules/gameplay/potions/Config.java | 17 +- .../gameplay/potions/PotionsModule.java | 18 +- .../modules/gameplay/weather/Config.java | 22 +- .../gameplay/weather/WeatherModule.java | 44 +- .../modules/other/AdvancementsModule.java | 55 +-- .../modules/other/PomfModule.java | 10 +- .../modules/other/StatisticsModule.java | 42 +- .../modules/other/about/AboutCommand.java | 27 +- .../modules/other/about/AboutModule.java | 98 ++-- .../scenarii/alliances/AllianceRequest.java | 321 ++++++------ .../scenarii/alliances/AlliancesModule.java | 101 ++-- .../modules/scenarii/alliances/Config.java | 20 +- .../alliances/TeamsPermissionsChecker.java | 15 +- .../commands/AllianceRequestCommand.java | 79 +-- .../commands/RequestAnswerCommand.java | 46 +- .../modules/starting/cages/Cage.java | 210 ++++---- .../modules/starting/cages/CagesModule.java | 44 +- .../modules/starting/cages/Config.java | 19 +- .../modules/utilities/check/CheckCommand.java | 16 +- .../modules/utilities/check/CheckModule.java | 12 +- .../modules/utilities/food/FoodModule.java | 12 +- .../food/commands/FeedAllCommand.java | 36 +- .../utilities/food/commands/FeedCommand.java | 46 +- .../utilities/freezer/FreezeCommand.java | 116 ++--- .../utilities/freezer/FreezerListener.java | 66 +-- .../utilities/freezer/FreezerModule.java | 150 +++--- .../utilities/health/HealthModule.java | 12 +- .../health/commands/HealAllCommand.java | 55 +-- .../health/commands/HealCommand.java | 48 +- .../playersLoader/LoadPlayersCommand.java | 33 +- .../playersLoader/PlayersLoaderModule.java | 17 +- .../modules/utilities/rules/Config.java | 22 +- .../modules/utilities/rules/RulesCommand.java | 44 +- .../modules/utilities/rules/RulesModule.java | 76 ++- .../runtimeCommandsExecutor/Config.java | 17 +- .../RuntimeCommandsExecutor.java | 177 +++---- .../ScheduledCommandsExecutorTask.java | 21 +- .../teleportation/TeleportationModule.java | 28 +- .../commands/TPDeathCommand.java | 49 +- .../commands/TPSpawnCommand.java | 60 +-- .../commands/TPSpectatorsCommand.java | 41 +- .../teleportation/commands/TPTeamCommand.java | 41 +- .../commands/WorldBasedCommand.java | 18 +- .../modules/utilities/walls/Config.java | 24 +- .../modules/utilities/walls/WallsCommand.java | 30 +- .../modules/utilities/walls/WallsModule.java | 33 +- .../CannotGenerateWallsException.java | 7 +- .../exceptions/UnknownWallGenerator.java | 7 +- .../generators/CircularWallGenerator.java | 50 +- .../generators/SquaredWallGenerator.java | 22 +- .../walls/generators/WallGenerator.java | 94 ++-- .../walls/generators/WallPosition.java | 5 +- .../utilities/warning/BorderWarningTask.java | 27 +- .../modules/utilities/warning/Config.java | 15 +- .../utilities/warning/WarningCommand.java | 36 +- .../utilities/warning/WarningModule.java | 91 ++-- .../modules/waitingPhase/wait/Config.java | 36 +- .../modules/waitingPhase/wait/WaitModule.java | 276 +++++------ .../modules/worldgen/creatures/Config.java | 14 +- .../worldgen/creatures/CreaturesModule.java | 361 +++++++------- .../quartzsurvivalgames/shortcuts/QSG.java | 125 +++-- src/main/resources/plugin.yml | 4 +- 144 files changed, 3955 insertions(+), 4794 deletions(-) diff --git a/pom.xml b/pom.xml index 5b5d4db..fe9671d 100644 --- a/pom.xml +++ b/pom.xml @@ -98,8 +98,8 @@ <minimizeJar>true</minimizeJar> <artifactSet> <includes> - <include>fr.zcraft:zlib</include> - <include>fr.zcraft:QuartzTeams</include> + <include>fr.zcraft:quartzlib</include> + <include>fr.zcraft:quartzteams</include> <include>me.cassayre.florian:Hawk</include> </includes> </artifactSet> @@ -110,7 +110,7 @@ </relocation> <relocation> <pattern>fr.zcraft.quartzteams</pattern> - <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartQuartzTeams</shadedPattern> + <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzteams</shadedPattern> </relocation> <relocation> <pattern>me.cassayre.florian.hawk</pattern> @@ -171,12 +171,12 @@ <dependency> <groupId>fr.zcraft</groupId> <artifactId>quartzlib</artifactId> - <version>0.0.1</version> + <version>0.0.2</version> </dependency> <dependency> <groupId>fr.zcraft</groupId> <artifactId>quartzteams</artifactId> - <version>1.0-SNAPSHOT</version> + <version>0.0.2</version> </dependency> <dependency> <groupId>me.cassayre.florian</groupId> diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java index 42ccc18..3b98067 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java @@ -12,18 +12,18 @@ import org.bukkit.ChatColor; -public class QSGConfig extends Configuration -{ +public class QSGConfig extends Configuration { static public final ConfigurationItem<Locale> LANG = item("lang", Locale.class); - static public final ConfigurationItem<String> TITLE = item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); + static public final ConfigurationItem<String> TITLE = + item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); static public final ConfigurationItem<Boolean> BUILT_IN_MODULES = item("built-in-modules", true); static public final ConfigurationMap<String, Boolean> MODULES = map("modules", String.class, Boolean.class); static public final WorldsSection WORLDS = section("worlds", WorldsSection.class); - static public class WorldsSection extends ConfigurationSection - { + + static public class WorldsSection extends ConfigurationSection { public final ConfigurationItem<String> OVERWORLD = item("overworld", "world"); public final ConfigurationItem<String> NETHER = item("nether", "world_nether"); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java index 4e71c29..87c03d6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QuartzSurvivalGames.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; @@ -52,6 +53,9 @@ import fr.zcraft.quartzlib.core.QuartzPlugin; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.Arrays; +import java.util.List; +import java.util.function.BiConsumer; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.event.EventHandler; @@ -61,13 +65,8 @@ import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.Scoreboard; -import java.util.Arrays; -import java.util.List; -import java.util.function.BiConsumer; - -public class QuartzSurvivalGames extends QuartzPlugin implements Listener -{ +public class QuartzSurvivalGames extends QuartzPlugin implements Listener { private static QuartzSurvivalGames instance; private ModulesManager modulesManager = null; @@ -79,10 +78,15 @@ public class QuartzSurvivalGames extends QuartzPlugin implements Listener private boolean worldsLoaded = false; + /** + * Returns the plugin's instance. + */ + public static QuartzSurvivalGames get() { + return instance; + } @Override - public void onEnable() - { + public void onEnable() { instance = this; this.saveDefaultConfig(); @@ -90,14 +94,17 @@ public void onEnable() /* *** Required zLib base components *** */ - loadComponents(QSGConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, OfflinePlayersLoader.class); + loadComponents(QSGConfig.class, I18n.class, Commands.class, SidebarScoreboard.class, Gui.class, + OfflinePlayersLoader.class); modulesManager = loadComponent(ModulesManager.class); /* *** Internationalization *** */ - if (QSGConfig.LANG.isDefined()) I18n.setPrimaryLocale(QSGConfig.LANG.get()); + if (QSGConfig.LANG.isDefined()) { + I18n.setPrimaryLocale(QSGConfig.LANG.get()); + } PluginLogger.info("Using locale {0} (fallback on {1})", I18n.getPrimaryLocale(), I18n.getFallbackLocale()); @@ -113,18 +120,18 @@ public void onEnable() ModulesModule.class, // Manages the modules from the game/commands. SidebarModule.class, // Manages the sidebar and provides hooks for other modules. - // Must be loaded before the game-related modules. + // Must be loaded before the game-related modules. TeamsModule.class, // Manages the teams (for both team & solo games). - // Must be loaded before the game-related modules. + // Must be loaded before the game-related modules. TimersModule.class, // Manages the time in everything. BorderModule.class, // Manages the border of the map. - // Must be loaded before the spawns module. + // Must be loaded before the spawns module. SpawnsModule.class, // Manages the spawn points and teleportation. - // Must be loaded before the game-related modules. + // Must be loaded before the game-related modules. GameModule.class, // Manages the game progression. @@ -134,8 +141,7 @@ public void onEnable() /* *** Built-in modules *** */ - if (QSGConfig.BUILT_IN_MODULES.get()) - { + if (QSGConfig.BUILT_IN_MODULES.get()) { modulesManager.registerBuiltInModules(); } @@ -152,8 +158,7 @@ public void onEnable() /* *** Loads modules from post-world time if worlds are loaded (server reloaded) *** */ - if (!getServer().getWorlds().isEmpty()) - { + if (!getServer().getWorlds().isEmpty()) { onEnableWhenWorldsAvailable(); } @@ -171,8 +176,7 @@ public void onEnable() /** * Run when the worlds are available (on plugin enabled if reloaded, on worlds ready else). */ - private void onEnableWhenWorldsAvailable() - { + private void onEnableWhenWorldsAvailable() { scoreboard = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); RunTask.nextTick(() -> { @@ -189,16 +193,14 @@ private void onEnableWhenWorldsAvailable() /** * @return The modules manager. */ - public ModulesManager getModulesManager() - { + public ModulesManager getModulesManager() { return modulesManager; } /** * @return The Bukkit scoreboard to use for everything. */ - public Scoreboard getScoreboard() - { + public Scoreboard getScoreboard() { return scoreboard; } @@ -206,12 +208,12 @@ public Scoreboard getScoreboard() * @param environment An environment. * @return The world to use for this environment in the game. */ - public World getWorld(final World.Environment environment) - { - if (environment == null) return worldNormal; + public World getWorld(final World.Environment environment) { + if (environment == null) { + return worldNormal; + } - switch (environment) - { + switch (environment) { case NORMAL: return worldNormal; @@ -227,23 +229,20 @@ public World getWorld(final World.Environment environment) /** * @return A stream containing all three playing worlds. */ - public List<World> getWorlds() - { + public List<World> getWorlds() { return Arrays.asList(worldNormal, worldNether, worldTheEnd); } - - @EventHandler (priority = EventPriority.LOWEST) - public final void onWorldsLoaded(final WorldLoadEvent e) - { - if (!worldsLoaded) onEnableWhenWorldsAvailable(); + @EventHandler(priority = EventPriority.LOWEST) + public final void onWorldsLoaded(final WorldLoadEvent e) { + if (!worldsLoaded) { + onEnableWhenWorldsAvailable(); + } } - @EventHandler (priority = EventPriority.LOWEST) - public void onGamePhaseChanged(final GamePhaseChangedEvent ev) - { - switch (ev.getNewPhase()) - { + @EventHandler(priority = EventPriority.LOWEST) + public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { + switch (ev.getNewPhase()) { case STARTING: modulesManager.loadModules(ModuleLoadTime.ON_GAME_STARTING); break; @@ -258,35 +257,27 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) } } - @EventHandler (priority = EventPriority.LOWEST) - public final void onPlayerJoin(final PlayerJoinEvent ev) - { + @EventHandler(priority = EventPriority.LOWEST) + public final void onPlayerJoin(final PlayerJoinEvent ev) { ev.getPlayer().setScoreboard(scoreboard); } - - private World setDefaultWorld(final World.Environment environment, final String worldName) - { + private World setDefaultWorld(final World.Environment environment, final String worldName) { final World userWorld = Bukkit.getWorld(worldName); // If the world is valid, it is used as-is. - if (userWorld != null && userWorld.getEnvironment() == environment) return userWorld; + if (userWorld != null && userWorld.getEnvironment() == environment) { + return userWorld; + } // Else we use the first world we found with the right type. - for (final World world : Bukkit.getWorlds()) - { - if (world.getEnvironment() == environment) return world; + for (final World world : Bukkit.getWorlds()) { + if (world.getEnvironment() == environment) { + return world; + } } // We finally fallback on the first world regardless of its type to have at least something. return Bukkit.getWorlds().get(0); } - - /** - * Returns the plugin's instance. - */ - public static QuartzSurvivalGames get() - { - return instance; - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java index d7ea5df..f4fcfbf 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java @@ -78,8 +78,8 @@ public class ModuleWrapper { private final boolean internal; private final boolean canBeUnloaded; private final boolean canBeLoadedLate; - private boolean enabled; private final String[] dependencies; + private boolean enabled; private QSGModule instance = null; public ModuleWrapper(final Class<? extends QSGModule> moduleClass) { @@ -337,7 +337,7 @@ public ItemStackBuilder getFullIcon(final boolean complete) { .longLore(ChatColor.WHITE, authors, 42); } - return icon.hideAttributes(); + return icon.hideAllAttributes(); } /** diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java index f2d40f7..422624f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java @@ -46,8 +46,8 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.ModulesUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.Commands; -import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.core.QuartzComponent; +import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; import java.io.IOException; @@ -319,8 +319,9 @@ private void collectCommandsFromModules() { for (final Map.Entry<String, Class<? extends Command>> commandAlias : commandAliases.entrySet()) { try { - pluginCommands.put(pluginCommandConstructor.newInstance(commandAlias.getKey(), QuartzLib.getPlugin()), - commandAlias.getValue()); + pluginCommands + .put(pluginCommandConstructor.newInstance(commandAlias.getKey(), QuartzLib.getPlugin()), + commandAlias.getValue()); registered.add(commandAlias.getKey()); } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java index 70d5404..ed27e28 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java @@ -51,16 +51,18 @@ import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.Titles; -import org.bukkit.*; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; @ModuleInfo( @@ -73,15 +75,13 @@ internal = true ) public class BorderModule extends QSGModule { - private MapShape mapShape = null; - private WorldBorder border = null; - - private WorldBorderDependency worldBorderDependency = null; - /** * The lines in the sidebar, calculated once for every player. Caching purposes. */ private final List<String> sidebar = new ArrayList<>(); + private MapShape mapShape = null; + private WorldBorder border = null; + private WorldBorderDependency worldBorderDependency = null; @Override public void onEnable() { @@ -167,22 +167,22 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) { } /** - * Sets the shape of the map. Updates the WorldBorder too. + * Returns the current shape of the map. * - * @param shape The shape. + * @return The shape. */ - public void setMapShape(MapShape shape) { - this.mapShape = shape; - border.setShape(shape); + public MapShape getMapShape() { + return mapShape; } /** - * Returns the current shape of the map. + * Sets the shape of the map. Updates the WorldBorder too. * - * @return The shape. + * @param shape The shape. */ - public MapShape getMapShape() { - return mapShape; + public void setMapShape(MapShape shape) { + this.mapShape = shape; + border.setShape(shape); } /** diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java index 7b75c08..6c6d4d6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java @@ -37,23 +37,18 @@ import fr.zcraft.quartzlib.tools.PluginLogger; -public class WorldBorderDependency extends ExternalPluginComponent<WorldBorder> -{ - public WorldBorderDependency() - { +public class WorldBorderDependency extends ExternalPluginComponent<WorldBorder> { + public WorldBorderDependency() { super("WorldBorder"); } @Override - protected void onLoad() - { - try - { + protected void onLoad() { + try { Class.forName("com.wimbli.WorldBorder.BorderData"); Class.forName("com.wimbli.WorldBorder.Config"); } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { PluginLogger.warning("WorldBorder is available, but the version you are using is too old."); PluginLogger.warning("This plugin is tested and works with WorldBorder 1.8.0 or later."); @@ -64,8 +59,7 @@ protected void onLoad() PluginLogger.info("Successfully hooked into WorldBorder."); } - public WorldBorder getWorldBorder() - { + public WorldBorder getWorldBorder() { return get(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java index bdc13dd..c813833 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/submanagers/GameBeginning.java @@ -58,16 +58,6 @@ import org.bukkit.event.entity.EntityDamageEvent; public class GameBeginning extends QuartzComponent implements Listener { - /** - * A flag used to disable damages at the beginning of the game to avoid fall damages and early ones. - */ - private boolean inGracePeriod = false; - - /** - * A flag used to disable hostile mobs spawn on the surface a few minutes after the beginning of the game. - */ - private boolean inMobsFreePeriod = false; - private static final Set<String> SURFACE_MATERIAL_ENDS = ImmutableSet.of( "LOG", "LEAVES", @@ -77,7 +67,14 @@ public class GameBeginning extends QuartzComponent implements Listener { "WALL", "FENCE" ); - + /** + * A flag used to disable damages at the beginning of the game to avoid fall damages and early ones. + */ + private boolean inGracePeriod = false; + /** + * A flag used to disable hostile mobs spawn on the surface a few minutes after the beginning of the game. + */ + private boolean inMobsFreePeriod = false; @EventHandler(priority = EventPriority.LOWEST) private void onGameStarts(GamePhaseChangedEvent ev) { @@ -182,12 +179,12 @@ private void onSurfaceCreatureSpawn(final CreatureSpawnEvent ev) { switch (type) { // Air case AIR: - - // Trees + + // Trees case BROWN_MUSHROOM_BLOCK: case RED_MUSHROOM_BLOCK: - // Vegetation + // Vegetation case DEAD_BUSH: case CHORUS_PLANT: case KELP_PLANT: diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java index 880e68d..ab4eec4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/ModulesModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules; import com.google.common.collect.ImmutableMap; @@ -38,22 +39,21 @@ import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ConfigurationCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ModuleCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ModulesCommand; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands.ConfigurationCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.Material; -import org.bukkit.entity.Player; - import java.util.Arrays; import java.util.List; import java.util.Map; +import org.bukkit.Material; +import org.bukkit.entity.Player; -@ModuleInfo ( +@ModuleInfo( name = "Modules", description = "Offers to the users a way to manage modules.", when = ModuleLoadTime.STARTUP, @@ -61,11 +61,9 @@ icon = Material.COMMAND_BLOCK, can_be_unloaded = false ) -public class ModulesModule extends QSGModule -{ +public class ModulesModule extends QSGModule { @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList( ModulesCommand.class, ModuleCommand.class, @@ -74,8 +72,7 @@ public List<Class<? extends Command>> getCommands() } @Override - public Map<String, Class<? extends Command>> getCommandsAliases() - { + public Map<String, Class<? extends Command>> getCommandsAliases() { return ImmutableMap.of( "modules", ModulesCommand.class, "config", ConfigurationCommand.class @@ -83,8 +80,7 @@ public Map<String, Class<? extends Command>> getCommandsAliases() } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { + public void injectIntoSidebar(Player player, SidebarInjector injector) { if (player.isOp() && QSG.module(GameModule.class).getPhase() == GamePhase.WAIT) // TODO Permissions { injector.injectLines( diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java index da75479..aee2547 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ConfigurationCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.MainConfigGUI; @@ -39,12 +40,10 @@ import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.gui.Gui; -@CommandInfo (name = "config") -public class ConfigurationCommand extends Command -{ +@CommandInfo(name = "config") +public class ConfigurationCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { Gui.open(playerSender(), new MainConfigGUI()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java index 74df62f..874e8dc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModuleCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; @@ -39,114 +40,95 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.ChatColor; - import java.text.Normalizer; import java.util.List; import java.util.Locale; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.bukkit.ChatColor; -@CommandInfo (name = "module", usageParameters = "enable|disable <module>") -public class ModuleCommand extends Command -{ +@CommandInfo(name = "module", usageParameters = "enable|disable <module>") +public class ModuleCommand extends Command { private static final Pattern NON_LATIN = Pattern.compile("[^\\w-]"); private static final Pattern WHITESPACE = Pattern.compile("[\\s]"); + /** + * Generates a slug from the (potentially Minecraft-formatted) given string. + * + * @param input The string to convert into a slug. May contain Minecraft + * formatting codes: they will be striped. + * @return The slug. + */ + private static String slug(final String input) { + final String nowhitespace = WHITESPACE.matcher(ChatColor.stripColor(input)).replaceAll("-"); + final String normalized = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD); + final String slug = NON_LATIN.matcher(normalized).replaceAll(""); + + return slug.toLowerCase(Locale.ENGLISH); + } @Override - protected void run() throws CommandException - { - if (args.length < 2 || (!args[0].equalsIgnoreCase("enable") && !args[0].equalsIgnoreCase("disable"))) - { + protected void run() throws CommandException { + if (args.length < 2 || (!args[0].equalsIgnoreCase("enable") && !args[0].equalsIgnoreCase("disable"))) { throwInvalidArgument(I.t("Invalid command usage.")); } ModuleWrapper module = null; - for (final ModuleWrapper m : QSG.get().getModulesManager().getModules()) - { - if (getModuleKey(m).equalsIgnoreCase(args[1])) - { - module = m; break; + for (final ModuleWrapper m : QSG.get().getModulesManager().getModules()) { + if (getModuleKey(m).equalsIgnoreCase(args[1])) { + module = m; + break; } } - if (module == null) - { + if (module == null) { throwInvalidArgument(I.t("No module with key {0}. Use autocompletion to get a list of keys.", args[1])); return; } - if (args[0].equalsIgnoreCase("enable")) - { - if (module.isEnabled()) - { + if (args[0].equalsIgnoreCase("enable")) { + if (module.isEnabled()) { error(I.t("{red}The module {darkred}{0}{red} is already enabled.", module.getName())); - } - else if (module.setEnabled(true)) - { + } else if (module.setEnabled(true)) { success(I.t("{green}The module {darkgreen}{0}{green} was successfully enabled.", module.getName())); - if (module.isLoaded()) - { + if (module.isLoaded()) { info(I.t("It was also loaded and is now running.")); - } - else - { + } else { info(I.t("It will be loaded when needed.")); } - } - else - { + } else { warning(I.t("{red}Unable to load the module {darkred}{0}{red}.", module.getName())); info("It is probably too late to enable this module."); } - } - else - { - if (!module.isEnabled()) - { + } else { + if (!module.isEnabled()) { error(I.t("{red}he module {darkred}{0}{red} is already disabled.", module.getName())); - } - else if (module.setEnabled(false)) - { + } else if (module.setEnabled(false)) { success(I.t("{green}The module {darkred}{0}{green} was successfully disabled.", module.getName())); - } - else - { - error(I.t("{red}Unable to disable the module {darkred}{0}{red}. It is probably protected.", module.getName())); + } else { + error(I.t("{red}Unable to disable the module {darkred}{0}{red}. It is probably protected.", + module.getName())); } } } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingSubset(args[0], "enable", "disable"); - else if (args.length == 2) return getMatchingSubset( - QSG.get().getModulesManager().getModules().stream().filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()).map(this::getModuleKey).collect(Collectors.toSet()), args[1]); - else return null; + protected List<String> complete() { + if (args.length == 1) { + return getMatchingSubset(args[0], "enable", "disable"); + } else if (args.length == 2) { + return getMatchingSubset( + QSG.get().getModulesManager().getModules().stream() + .filter(module -> args[0].equalsIgnoreCase("enable") != module.isEnabled()) + .map(this::getModuleKey).collect(Collectors.toSet()), args[1]); + } else { + return null; + } } - private String getModuleKey(final ModuleWrapper module) - { + private String getModuleKey(final ModuleWrapper module) { return slug(module.getName()); } - - /** - * Generates a slug from the (potentially Minecraft-formatted) given string. - * - * @param input The string to convert into a slug. May contain Minecraft - * formatting codes: they will be striped. - * @return The slug. - */ - private static String slug(final String input) - { - final String nowhitespace = WHITESPACE.matcher(ChatColor.stripColor(input)).replaceAll("-"); - final String normalized = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD); - final String slug = NON_LATIN.matcher(normalized).replaceAll(""); - - return slug.toLowerCase(Locale.ENGLISH); - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java index c247638..a179f9e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.commands; import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; @@ -40,56 +41,69 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.rawtext.RawText; import fr.zcraft.quartzlib.components.rawtext.RawTextPart; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import java.util.*; -import java.util.stream.Stream; - -@CommandInfo (name = "modules") -public class ModulesCommand extends Command -{ +@CommandInfo(name = "modules") +public class ModulesCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final Set<ModuleWrapper> modules = new TreeSet<>((module1, module2) -> { - if (module1.equals(module2)) return 0; + if (module1.equals(module2)) { + return 0; + } - if (module1.isLoaded() != module2.isLoaded()) return module1.isLoaded() ? -1 : 1; - if (module1.isEnabled() != module2.isEnabled()) return module1.isEnabled() ? -1 : 1; + if (module1.isLoaded() != module2.isLoaded()) { + return module1.isLoaded() ? -1 : 1; + } + if (module1.isEnabled() != module2.isEnabled()) { + return module1.isEnabled() ? -1 : 1; + } - if (module1.getWhen() != module2.getWhen()) + if (module1.getWhen() != module2.getWhen()) { return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal()); + } - if (module1.isInternal() != module2.isInternal()) return module1.isInternal() ? -1 : 1; + if (module1.isInternal() != module2.isInternal()) { + return module1.isInternal() ? -1 : 1; + } return module1.getName().compareTo(module2.getName()); }); modules.addAll(QuartzSurvivalGames.get().getModulesManager().getModules()); - success(I.tn("{0} module registered {gray}(hover for details)", "{0} modules registered {gray}(hover for details)", modules.size())); + success(I.tn("{0} module registered {gray}(hover for details)", + "{0} modules registered {gray}(hover for details)", modules.size())); modules.forEach(module -> { final List<String> commands = new ArrayList<>(); - if (module.isLoaded()) - { + if (module.isLoaded()) { final List<Class<? extends Command>> commandsClasses = module.get().getCommands(); - if (commandsClasses != null) - { + if (commandsClasses != null) { commandsClasses.forEach(clazz -> { final Command cmd = Commands.getCommandInfo(clazz); - if (cmd != null) commands.add(cmd.getUsageString()); + if (cmd != null) { + commands.add(cmd.getUsageString()); + } }); } final Map<String, Class<? extends Command>> commandsAliases = module.get().getCommandsAliases(); - if (commandsAliases != null) - { + if (commandsAliases != null) { commandsAliases.forEach((alias, clazz) -> { final Command cmd = Commands.getCommandInfo(clazz); - if (cmd != null) commands.add("/" + alias + " " + cmd.getUsageParameters() + ChatColor.DARK_GRAY + " (alias)"); + if (cmd != null) { + commands.add( + "/" + alias + " " + cmd.getUsageParameters() + ChatColor.DARK_GRAY + " (alias)"); + } }); } } @@ -97,48 +111,49 @@ protected void run() throws CommandException final RawTextPart<?> tooltip = new RawText(); tooltip - .then(module.getName()) - .style(ChatColor.BOLD, module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) - .then("\n") - .then(module.isLoaded() ? I.t("Loaded") : I.t("Unloaded")) + .then(module.getName()) + .style(ChatColor.BOLD, + module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + .then("\n") + .then(module.isLoaded() ? I.t("Loaded") : I.t("Unloaded")) .color(ChatColor.GRAY) - .then(" - ") + .then(" - ") .color(ChatColor.DARK_GRAY) - .then(module.isEnabled() ? I.t("Enabled") : I.t("Disabled")) + .then(module.isEnabled() ? I.t("Enabled") : I.t("Disabled")) .color(ChatColor.GRAY) - .then("\n\n") - .then(module.getDescription()) + .then("\n\n") + .then(module.getDescription()) .color(ChatColor.WHITE) - .then("\n\n") - .then(I.t("Load time")) + .then("\n\n") + .then(I.t("Load time")) .color(ChatColor.BLUE) - .then("\n") - .then(module.getWhen().toString()) + .then("\n") + .then(module.getWhen().toString()) .color(ChatColor.WHITE); - if (!commands.isEmpty()) - { + if (!commands.isEmpty()) { tooltip.then("\n\n").then(I.t("Provided commands")).style(ChatColor.BLUE); - commands.forEach(command -> tooltip.then("\n- ").style(ChatColor.GRAY).then(command).color(ChatColor.WHITE)); + commands.forEach( + command -> tooltip.then("\n- ").style(ChatColor.GRAY).then(command).color(ChatColor.WHITE)); } - if (module.getDependencies().length != 0) - { + if (module.getDependencies().length != 0) { tooltip.then("\n\n").then(I.t("External dependencies")).style(ChatColor.BLUE); - Stream.of(module.getDependencies()).forEach(dep -> tooltip.then("\n- ").style(ChatColor.GRAY).then(dep).color(Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED)); + Stream.of(module.getDependencies()).forEach(dep -> tooltip.then("\n- ").style(ChatColor.GRAY).then(dep) + .color(Bukkit.getPluginManager().getPlugin(dep) != null ? ChatColor.WHITE : ChatColor.RED)); } - if (module.isInternal()) - { + if (module.isInternal()) { tooltip.then("\n\n").then(I.t("Internal module")).style(ChatColor.DARK_GRAY); } - if (!module.canBeUnloaded()) - { - tooltip.then(module.isInternal() ? " - " : "\n\n").color(ChatColor.DARK_GRAY).then(I.t("Cannot be disabled")).color(ChatColor.DARK_GRAY); + if (!module.canBeUnloaded()) { + tooltip.then(module.isInternal() ? " - " : "\n\n").color(ChatColor.DARK_GRAY) + .then(I.t("Cannot be disabled")).color(ChatColor.DARK_GRAY); } send(new RawText().hover(tooltip) - .then("• ").color(module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) + .then("• ") + .color(module.isLoaded() ? ChatColor.GREEN : (module.isEnabled() ? ChatColor.GOLD : ChatColor.RED)) .then(module.getName()).color(ChatColor.WHITE) .build() ); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java index ed11beb..59766e3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/MainConfigGUI.java @@ -31,16 +31,17 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui; import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; -import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.Config; -import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.WaitModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules.ModulesListGUI; import eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.start.StartGameGUI; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.Config; +import eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait.WaitModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.gui.ActionGui; import fr.zcraft.quartzlib.components.gui.Gui; @@ -51,30 +52,31 @@ import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzteams.QuartzTeams; import fr.zcraft.quartzteams.guis.TeamsSelectorGUI; -import org.bukkit.*; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.scheduler.BukkitTask; - import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.scheduler.BukkitTask; -public class MainConfigGUI extends ActionGui -{ +public class MainConfigGUI extends ActionGui { private BukkitTask headsCycleTask = null; private String[] headCycleNames = null; private int headCycleIndex = 0; @Override - protected void onUpdate() - { + protected void onUpdate() { setTitle(I.tl(getPlayerLocale(), "{black}Game Configuration")); setHeight(QSG.game().currentPhaseAfter(GamePhase.WAIT) ? 3 : 5); final Set<String> alivePlayers = (QSG.game().currentPhaseBefore(GamePhase.IN_GAME) - ? Bukkit.getOnlinePlayers().stream().filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) - : QSG.game().getAlivePlayers().stream()) + ? Bukkit.getOnlinePlayers().stream() + .filter(player -> !QSG.module(SpectatorsModule.class).isSpectator(player)) + : QSG.game().getAlivePlayers().stream()) .map(OfflinePlayer::getName) .collect(Collectors.toSet()); @@ -92,43 +94,58 @@ protected void onUpdate() ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} player", "{0} players", alivePlayers.size()), " - ", - I.tln(getPlayerLocale(), "{0} spectator", "{0} spectators", QSG.module(SpectatorsModule.class).getSpectators().size()) + I.tln(getPlayerLocale(), "{0} spectator", "{0} spectators", + QSG.module(SpectatorsModule.class).getSpectators().size()) ) .loreSeparator() .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Players")) - .longLore(ChatColor.GRAY, alivePlayers.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : String.join(", ", alivePlayers), 38) + .longLore(ChatColor.GRAY, + alivePlayers.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : + String.join(", ", alivePlayers), 38) .loreSeparator() .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Spectators")) - .longLore(ChatColor.GRAY, spectators.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : String.join(", ", spectators), 38) + .longLore(ChatColor.GRAY, + spectators.isEmpty() ? ChatColor.DARK_GRAY + I.tl(getPlayerLocale(), "(none)") : + String.join(", ", spectators), 38) .loreSeparator() - .longLore(ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Actions on players coming soon: in the mean time, use commands."), 38) + .longLore(ChatColor.DARK_GRAY, + I.tl(getPlayerLocale(), "Actions on players coming soon: in the mean time, use commands."), 38) ); action("teams", 12, new ItemStackBuilder( QSG.module(WaitModule.class) != null ? Config.TEAM_SELECTOR.ITEM.get() : Material.NETHER_STAR) .title(ChatColor.AQUA, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teams")) .amount(Math.max(QuartzTeams.get().countTeams(), 1)) - .loreLine(ChatColor.DARK_GRAY, I.tln(getPlayerLocale(), "{0} team", "{0} teams", QuartzTeams.get().countTeams())) + .loreLine(ChatColor.DARK_GRAY, + I.tln(getPlayerLocale(), "{0} team", "{0} teams", QuartzTeams.get().countTeams())) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "The game can either be solo or in teams. In the second case, click here to create or update teams."), 38) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "The game can either be solo or in teams. In the second case, click here to create or update teams."), + 38) .loreSeparator() - .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage the teams")) + .longLore( + ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage the teams")) ); action("title", 14, new ItemStackBuilder(Material.WRITABLE_BOOK) .title(ChatColor.DARK_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Game Title")) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click to update the game title. It is displayed on the sidebar and may be used by other modules (like the reports one)."), 38) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "Click to update the game title. It is displayed on the sidebar and may be used by other modules (like the reports one)."), + 38) .loreSeparator() .longLore(ChatColor.BLUE, I.tl(getPlayerLocale(), "Current Title")) .longLore(QSGConfig.TITLE.get()) .loreSeparator() - .longLore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to change the title")) + .longLore( + ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to change the title")) ); final int modules = QSG.get().getModulesManager().getModules().size(); - final int modulesEnabled = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); - final int modulesLoaded = (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); + final int modulesEnabled = + (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isEnabled).count(); + final int modulesLoaded = + (int) QSG.get().getModulesManager().getModules().stream().filter(ModuleWrapper::isLoaded).count(); action("modules", 16, new ItemStackBuilder(Material.REPEATING_COMMAND_BLOCK) .title(ChatColor.LIGHT_PURPLE, ChatColor.BOLD + I.tl(getPlayerLocale(), "Modules")) @@ -141,41 +158,44 @@ protected void onUpdate() I.tln(getPlayerLocale(), "{0} loaded", "{0} loaded", modulesLoaded) ) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "This plugin is divided into modules, each one bringing one small or large piece of the game."), 52) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "This plugin is divided into modules, each one bringing one small or large piece of the game."), + 52) .loreSeparator() - .lore(ChatColor.DARK_GRAY + " » " + I.tl(getPlayerLocale(), "{white}Click {gray}to manage modules and their configuration")) + .lore(ChatColor.DARK_GRAY + " » " + + I.tl(getPlayerLocale(), "{white}Click {gray}to manage modules and their configuration")) ); - if (!QSG.game().currentPhaseAfter(GamePhase.WAIT)) - { + if (!QSG.game().currentPhaseAfter(GamePhase.WAIT)) { action("start", 31, new ItemStackBuilder(Material.LIME_DYE) .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Start the game")) .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If you're ready, click here to start the game!")) ); } - if (headsCycleTask != null) headsCycleTask.cancel(); + if (headsCycleTask != null) { + headsCycleTask.cancel(); + } headsCycleTask = RunTask.timer(() -> { final ItemStack skull = getInventory().getItem(10); - if (skull != null) - { + if (skull != null) { // TODO replace with QL 0.1 ISB final SkullMeta meta = (SkullMeta) getInventory().getItem(10).getItemMeta(); meta.setOwner(headCycleNames[headCycleIndex]); getInventory().getItem(10).setItemMeta(meta); headCycleIndex = (headCycleIndex + 1) % headCycleNames.length; - if (headCycleIndex < 0) headCycleIndex += headCycleNames.length; + if (headCycleIndex < 0) { + headCycleIndex += headCycleNames.length; + } } }, 0L, 40L); } @Override - protected void onClose() - { - if (headsCycleTask != null) - { + protected void onClose() { + if (headsCycleTask != null) { headsCycleTask.cancel(); headsCycleTask = null; headCycleIndex = 0; @@ -191,26 +211,24 @@ protected void players() { @GuiAction - protected void teams() - { + protected void teams() { Gui.open(getPlayer(), new TeamsSelectorGUI(), this); } @GuiAction - protected void title() - { - PromptGui.prompt(getPlayer(), newTitle -> QSGConfig.TITLE.set(ChatColor.translateAlternateColorCodes('&', newTitle), false), QSGConfig.TITLE.get().replace(ChatColor.COLOR_CHAR, '&'), this); + protected void title() { + PromptGui.prompt(getPlayer(), + newTitle -> QSGConfig.TITLE.set(ChatColor.translateAlternateColorCodes('&', newTitle), false), + QSGConfig.TITLE.get().replace(ChatColor.COLOR_CHAR, '&'), this); } @GuiAction - protected void modules() - { + protected void modules() { Gui.open(getPlayer(), new ModulesListGUI(), this); } @GuiAction - protected void start() - { + protected void start() { Gui.open(getPlayer(), new StartGameGUI()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java index c43e6be..44e1272 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ConfirmModuleDisableGUI.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; @@ -44,29 +45,30 @@ import org.bukkit.ChatColor; import org.bukkit.Material; -public class ConfirmModuleDisableGUI extends FramedModuleGUI -{ - public ConfirmModuleDisableGUI(final ModuleWrapper module) - { +public class ConfirmModuleDisableGUI extends FramedModuleGUI { + public ConfirmModuleDisableGUI(final ModuleWrapper module) { super(module); } @Override - protected void onUpdate() - { + protected void onUpdate() { setTitle(I.t("{darkgray}{0} » {black}Disable", module.getName())); setSize(5 * 9); - final List<String> title = GuiUtils.generateLore(I.t("If you disable this module, you won't be able to re-enable it."), 38); + final List<String> title = + GuiUtils.generateLore(I.t("If you disable this module, you won't be able to re-enable it."), 38); final String firstTitleLine = title.get(0); title.remove(0); action("", 22, MojangHead.QUESTION.asItemBuilder() .title(ChatColor.RED, ChatColor.BOLD + firstTitleLine) - .lore(title.stream().map(line -> ChatColor.RED + "" + ChatColor.BOLD + line).collect(Collectors.toList())) + .lore(title.stream().map(line -> ChatColor.RED + "" + ChatColor.BOLD + line) + .collect(Collectors.toList())) .loreSeparator() - .longLore(ChatColor.GRAY, I.t("This module cannot be re-loaded after its original load period. This means that if you disable this module, you won't be able to re-enable it during this game."), 38) + .longLore(ChatColor.GRAY, + I.t("This module cannot be re-loaded after its original load period. This means that if you disable this module, you won't be able to re-enable it during this game."), + 38) .longLore(ChatColor.WHITE, I.t("Are you sure you want to disable {0}?", module.getName()), 38) .item()); @@ -76,24 +78,22 @@ protected void onUpdate() final ItemStackBuilder yes = new ItemStackBuilder(Material.LIME_STAINED_GLASS_PANE) .title(ChatColor.RED, ChatColor.BOLD + I.t("Yes, disable")) - .longLore(ChatColor.GRAY, I.t("Disable {0} without any possibility of re-enabling it", module.getName())); + .longLore(ChatColor.GRAY, + I.t("Disable {0} without any possibility of re-enabling it", module.getName())); - for (int slot : new int[] {10, 11, 19, 20, 28, 29}) - { + for (int slot : new int[] {10, 11, 19, 20, 28, 29}) { action("cancel", slot, no); action("disable", slot + 5, yes); } } @GuiAction - protected void cancel() - { + protected void cancel() { close(); } @GuiAction - protected void disable() - { + protected void disable() { module.setEnabled(false); close(); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java index 615b432..105749f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/FramedModuleGUI.java @@ -31,40 +31,38 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import fr.zcraft.quartzlib.components.gui.ActionGui; +import fr.zcraft.quartzlib.tools.items.ColorableMaterial; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; -import fr.zcraft.quartzteams.colors.ColorsUtils; +import fr.zcraft.quartzlib.tools.items.ItemUtils; import org.bukkit.inventory.ItemStack; -public abstract class FramedModuleGUI extends ActionGui -{ +public abstract class FramedModuleGUI extends ActionGui { protected final ModuleWrapper module; - public FramedModuleGUI(ModuleWrapper module) - { + public FramedModuleGUI(ModuleWrapper module) { this.module = module; } @Override - protected void onAfterUpdate() - { - final ItemStack framePart = new ItemStackBuilder(ColorsUtils.chat2Block(module.getCategory().getColor(), "STAINED_GLASS_PANE")) - .title("") - .item(); + protected void onAfterUpdate() { + final ItemStack framePart = + new ItemStackBuilder(ItemUtils.colorize(ColorableMaterial.STAINED_GLASS_PANE, module.getCategory().getColor())) + .title("") + .item(); // Top and bottom - for (int slot = 0; slot < 9; slot++) - { + for (int slot = 0; slot < 9; slot++) { action("", slot, framePart); action("", getSize() - (slot + 1), framePart); } // Sides - for (int line = 0; line < getSize() / 9; line++) - { + for (int line = 0; line < getSize() / 9; line++) { action("", line * 9, framePart); action("", line * 9 + 8, framePart); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java index b398226..69d94d0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.modules; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,9 +42,10 @@ import fr.zcraft.quartzlib.components.gui.Gui; import fr.zcraft.quartzlib.components.gui.GuiAction; import fr.zcraft.quartzlib.components.i18n.I; +import fr.zcraft.quartzlib.tools.items.ColorableMaterial; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; +import fr.zcraft.quartzlib.tools.items.ItemUtils; import fr.zcraft.quartzlib.tools.mojang.MojangHead; -import fr.zcraft.quartzteams.colors.ColorsUtils; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -51,88 +53,93 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; -public class ModulesListGUI extends ExplorerGui<ModuleWrapper> -{ +public class ModulesListGUI extends ExplorerGui<ModuleWrapper> { /** * The category filtered. {@code null} means all. */ private ModuleCategory filterCategory; private StateFilter filterState = StateFilter.ALL; - public ModulesListGUI() - { + public ModulesListGUI() { this(null); } - public ModulesListGUI(final ModuleCategory filterCategory) - { + public ModulesListGUI(final ModuleCategory filterCategory) { this.filterCategory = filterCategory; } @Override - protected void onUpdate() - { + protected void onUpdate() { setSize(6 * 9); setMode(Mode.READONLY); setKeepHorizontalScrollingSpace(true); final ModuleWrapper[] modules = QSG.get().getModulesManager().getModules().stream() - .filter(module -> filterCategory == null || module.getCategory() == filterCategory) - .filter(module -> { - switch (filterState) - { - case ALL: - return true; - - case ENABLED: - return module.isEnabled(); - - case LOADED: - return module.isLoaded(); - - case DISABLED: - default: - return !module.isEnabled(); - } - }) - .sorted((module1, module2) -> { - if (module1.equals(module2)) return 0; - - if (module1.getCategory() != module2.getCategory()) - return Integer.compare(module1.getCategory().ordinal(), module2.getCategory().ordinal()); - - if (module1.getWhen() != module2.getWhen()) - return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal()); - - if (module1.isInternal() != module2.isInternal()) return module1.isInternal() ? -1 : 1; - - return module1.getName().compareTo(module2.getName()); - }) - .toArray(ModuleWrapper[]::new); + .filter(module -> filterCategory == null || module.getCategory() == filterCategory) + .filter(module -> { + switch (filterState) { + case ALL: + return true; + + case ENABLED: + return module.isEnabled(); + + case LOADED: + return module.isLoaded(); + + case DISABLED: + default: + return !module.isEnabled(); + } + }) + .sorted((module1, module2) -> { + if (module1.equals(module2)) { + return 0; + } + + if (module1.getCategory() != module2.getCategory()) { + return Integer.compare(module1.getCategory().ordinal(), module2.getCategory().ordinal()); + } + + if (module1.getWhen() != module2.getWhen()) { + return Integer.compare(module1.getWhen().ordinal(), module2.getWhen().ordinal()); + } + + if (module1.isInternal() != module2.isInternal()) { + return module1.isInternal() ? -1 : 1; + } + + return module1.getName().compareTo(module2.getName()); + }) + .toArray(ModuleWrapper[]::new); setData(modules); // Sets the title - if (filterCategory == null) - { + if (filterCategory == null) { setTitle(I.t("{black}All modules {darkgray}({0})", QSG.get().getModulesManager().getModules().size())); - } - else - { - setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + String.format(" (%d / %d)", modules.length, QSG - .get().getModulesManager().getModules().size())); + } else { + setTitle(ChatColor.BLACK + filterCategory.getDisplayName() + ChatColor.DARK_GRAY + + String.format(" (%d / %d)", modules.length, QSG + .get().getModulesManager().getModules().size())); } // Displays the bottom bar of color - final ItemStackBuilder bottomColorStripe = new ItemStackBuilder(ColorsUtils.chat2Block(filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE, "STAINED_GLASS_PANE")) + final ItemStackBuilder bottomColorStripe = new ItemStackBuilder() + .material(ItemUtils.colorize(ColorableMaterial.STAINED_GLASS_PANE, filterCategory != null ? filterCategory.getColor() : ChatColor.WHITE)) .title(filterCategory != null ? filterCategory.getColor() + "" + ChatColor.BOLD + filterCategory.getDisplayName() : ""); - if (filterCategory != null) bottomColorStripe.longLore(ChatColor.GRAY, filterCategory.getDescription(), 38); - for (int slot = getSize() - 9; slot < getSize(); slot++) action("", slot, bottomColorStripe); + if (filterCategory != null) { + bottomColorStripe.longLore(ChatColor.GRAY, filterCategory.getDescription(), 38); + } + + for (int slot = getSize() - 9; slot < getSize(); slot++) { + action("", slot, bottomColorStripe); + } final String prefixActive = ChatColor.YELLOW + "» "; @@ -142,36 +149,41 @@ protected void onUpdate() // Displays the category filter button final Material endCrystal = Material.getMaterial("END_CRYSTAL"); - final ItemStackBuilder catFilter = new ItemStackBuilder(filterCategory == null ? new ItemStack(endCrystal != null ? endCrystal : Material.HOPPER) : filterCategory.getIcon()) + final ItemStackBuilder catFilter = new ItemStackBuilder( + filterCategory == null ? new ItemStack(endCrystal != null ? endCrystal : Material.HOPPER) : + filterCategory.getIcon()) .title(ChatColor.YELLOW, ChatColor.BOLD + I.t("Filter modules category")) .loreSeparator(); catFilter.loreLine((filterCategory == null ? prefixActive : prefixInactive) + I.t("All modules")); - for (ModuleCategory category : ModuleCategory.values()) - { - catFilter.loreLine((filterCategory == category ? prefixActive : prefixInactive) + category.getDisplayName()); + for (ModuleCategory category : ModuleCategory.values()) { + catFilter + .loreLine((filterCategory == category ? prefixActive : prefixInactive) + category.getDisplayName()); } catFilter.loreSeparator(); - catFilter.longLore(ChatColor.WHITE, filterCategory == null ? I.t("Click to filter the modules by category. A description will be displayed here.") : filterCategory.getDescription(), 38); + catFilter.longLore(ChatColor.WHITE, filterCategory == null ? + I.t("Click to filter the modules by category. A description will be displayed here.") : + filterCategory.getDescription(), 38); action("switch_category", getSize() - 5, catFilter); // Displays the state filter button - final ItemStackBuilder stateFilter = new ItemStackBuilder(ColorsUtils.dye2Block(filterState.color, "DYE")) + final ItemStackBuilder stateFilter = new ItemStackBuilder(ItemUtils.colorize(ColorableMaterial.DYE, filterState.color)) .title(ChatColor.YELLOW, ChatColor.BOLD + I.tl(getPlayerLocale(), "Filter modules state")) .loreSeparator(); - for (StateFilter filter : StateFilter.values()) - { + for (StateFilter filter : StateFilter.values()) { stateFilter.loreLine(filterState == filter ? prefixActive : prefixInactive, filter.displayName); } stateFilter.loreSeparator(); - stateFilter.longLore(ChatColor.WHITE, I.tl(getPlayerLocale(), "Click here to filter by state. Loaded modules are currently running. Enabled ones are running or will run when needed. Disabled modules will never run."), 48); + stateFilter.longLore(ChatColor.WHITE, I.tl(getPlayerLocale(), + "Click here to filter by state. Loaded modules are currently running. Enabled ones are running or will run when needed. Disabled modules will never run."), + 48); action("switch_status", getSize() - 7, stateFilter); @@ -179,36 +191,28 @@ protected void onUpdate() // Displays the back button action("quit", getSize() - 3, MojangHead.ARROW_LEFT.asItemBuilder() - .title(ChatColor.GREEN, ChatColor.BOLD + (getParent() != null ? I.tl(getPlayerLocale(), "Go Back") : I.tl(getPlayerLocale(), "Close"))) - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click here to close this GUI and go back. You can also press “Escape”.")) + .title(ChatColor.GREEN, ChatColor.BOLD + + (getParent() != null ? I.tl(getPlayerLocale(), "Go Back") : I.tl(getPlayerLocale(), "Close"))) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "Click here to close this GUI and go back. You can also press “Escape”.")) ); } @Override - protected ItemStack getViewItem(final ModuleWrapper module) - { + protected ItemStack getViewItem(final ModuleWrapper module) { final ItemStackBuilder item = module.getFullIcon(false).loreSeparator(); final String prefix = ChatColor.DARK_GRAY + "» "; - if (!module.isEnabled()) - { - if (module.canBeEnabled()) - { + if (!module.isEnabled()) { + if (module.canBeEnabled()) { item.lore(prefix + I.t("{white}Click {gray}to enable this module")); - } - else - { + } else { item.lore(prefix + I.t("{red}This module can no longer be enabled.")); } - } - else - { - if (module.canBeDisabled()) - { + } else { + if (module.canBeDisabled()) { item.lore(prefix + I.t("{white}Click {gray}to disable this module")); - } - else - { + } else { item.lore(prefix + I.t("{red}This module cannot be disabled.")); } } @@ -221,26 +225,23 @@ protected ItemStack getViewItem(final ModuleWrapper module) /** * On left click + * * @param module Clicked module */ @Override - protected ItemStack getPickedUpItem(final ModuleWrapper module) - { - if (module.isEnabled() && !module.canBeEnabled()) - { + protected ItemStack getPickedUpItem(final ModuleWrapper module) { + if (module.isEnabled() && !module.canBeEnabled()) { Gui.open(getPlayer(), new ConfirmModuleDisableGUI(module), this); - } - else - { - if (module.setEnabled(!module.isEnabled())) - { - if (module.isEnabled()) - { - QSG.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {green}enabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); - } - else - { - QSG.log().broadcastAdministrativePrefixed(I.t("{yellow}{0} {red}disabled {yellow}the module {1}.", getPlayer().getName(), module.getName())); + } else { + if (module.setEnabled(!module.isEnabled())) { + if (module.isEnabled()) { + QSG.log().broadcastAdministrativePrefixed( + I.t("{yellow}{0} {green}enabled {yellow}the module {1}.", getPlayer().getName(), + module.getName())); + } else { + QSG.log().broadcastAdministrativePrefixed( + I.t("{yellow}{0} {red}disabled {yellow}the module {1}.", getPlayer().getName(), + module.getName())); } } @@ -251,46 +252,38 @@ protected ItemStack getPickedUpItem(final ModuleWrapper module) } @Override - protected void onRightClick(final ModuleWrapper module) - { + protected void onRightClick(final ModuleWrapper module) { // TODO open details-gui } @GuiAction - protected void switch_category(final InventoryClickEvent ev) - { + protected void switch_category(final InventoryClickEvent ev) { filterCategory = QSGUtils .getNextElement(filterCategory, ev.getClick() == ClickType.RIGHT ? -1 : 1, true, ModuleCategory.class); update(); } @GuiAction - protected void switch_status(final InventoryClickEvent ev) - { + protected void switch_status(final InventoryClickEvent ev) { filterState = QSGUtils.getNextElement(filterState, ev.getClick() == ClickType.RIGHT ? -1 : 1); update(); } @GuiAction - protected void quit() - { + protected void quit() { close(); } - private enum StateFilter - { + private enum StateFilter { ALL(DyeColor.PURPLE, I.t("All modules")), ENABLED(DyeColor.PINK, I.t("Enabled modules")), LOADED(DyeColor.LIME, I.t("Loaded modules")), - DISABLED(DyeColor.GRAY, I.t("Disabled modules")) - - ; + DISABLED(DyeColor.GRAY, I.t("Disabled modules")); private final DyeColor color; private final String displayName; - StateFilter(DyeColor color, String displayName) - { + StateFilter(DyeColor color, String displayName) { this.color = color; this.displayName = displayName; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java index d4b26ae..0c5148e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/start/StartGameGUI.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.modules.gui.start; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; @@ -48,13 +49,11 @@ import org.bukkit.ChatColor; import org.bukkit.Material; -public class StartGameGUI extends ActionGui -{ +public class StartGameGUI extends ActionGui { private TeleportationMode mode = TeleportationMode.NORMAL; @Override - protected void onUpdate() - { + protected void onUpdate() { setHeight(5); setTitle(I.tl(getPlayerLocale(), "{black}Ready to start the game?")); @@ -64,59 +63,65 @@ protected void onUpdate() action("fast", 11, new ItemStackBuilder(Material.MAGMA_CREAM) .title(ChatColor.DARK_GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Fast Start")) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Click here to start the game immediately. Players will be teleported at once (thus loading a lot of chunks in a few seconds) and the countdown will begin immediately after."), 52) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "Click here to start the game immediately. Players will be teleported at once (thus loading a lot of chunks in a few seconds) and the countdown will begin immediately after."), + 52) ); action("slow", 15, new ItemStackBuilder(Material.SLIME_BALL) .title(ChatColor.GREEN, ChatColor.BOLD + I.tl(getPlayerLocale(), "Slow Start")) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "If your server is a little bit small, use this option to teleport players slowly, loading the chunks one player at a time. You'll have to confirm the game start using a link in the chat."), 52) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "If your server is a little bit small, use this option to teleport players slowly, loading the chunks one player at a time. You'll have to confirm the game start using a link in the chat."), + 52) ); - if (QuartzTeams.get().countTeams() > 0) - { + if (QuartzTeams.get().countTeams() > 0) { action("teleportation_mode", 13, new ItemStackBuilder() .material(mode == TeleportationMode.NORMAL ? Material.SUGAR : Material.GLOWSTONE_DUST) .title(ChatColor.YELLOW, ChatColor.BOLD + I.tl(getPlayerLocale(), "Teleportation Mode")) .loreSeparator() - .loreLine(mode == TeleportationMode.NORMAL ? prefixActive : prefixInactive, I.tl(getPlayerLocale(), "Teams together")) - .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Teams are teleported to a shared spawn point. Teammates start together."), 38) + .loreLine(mode == TeleportationMode.NORMAL ? prefixActive : prefixInactive, + I.tl(getPlayerLocale(), "Teams together")) + .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, + I.tl(getPlayerLocale(), + "Teams are teleported to a shared spawn point. Teammates start together."), 38) .loreSeparator() - .loreLine(mode == TeleportationMode.IGNORE_TEAMS ? prefixActive : prefixInactive, I.tl(getPlayerLocale(), "Ignoring teams")) - .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, I.tl(getPlayerLocale(), "Players will be alone at the beginning, even if they are in a team."), 38) + .loreLine(mode == TeleportationMode.IGNORE_TEAMS ? prefixActive : prefixInactive, + I.tl(getPlayerLocale(), "Ignoring teams")) + .longLore(mode == TeleportationMode.NORMAL ? ChatColor.GRAY : ChatColor.DARK_GRAY, + I.tl(getPlayerLocale(), + "Players will be alone at the beginning, even if they are in a team."), 38) ); } action("back", 31, MojangHead.ARROW_LEFT.asItemBuilder() .title(ChatColor.RED, ChatColor.BOLD + I.tl(getPlayerLocale(), "Go Back")) .loreSeparator() - .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), "Changed your mind? No problem, click here to go back without starting the game."), 38) + .longLore(ChatColor.GRAY, I.tl(getPlayerLocale(), + "Changed your mind? No problem, click here to go back without starting the game."), 38) ); } @GuiAction - protected void teleportation_mode() - { + protected void teleportation_mode() { mode = QSGUtils.getNextElement(mode, 1); update(); } @GuiAction - protected void fast() - { + protected void fast() { start(false); close(); } @GuiAction - protected void slow() - { + protected void slow() { start(true); close(); } - private void start(final boolean slow) - { + private void start(final boolean slow) { QSG.game().setTeleportationMode(mode); QSG.game().setSlowMode(slow); @@ -124,8 +129,7 @@ private void start(final boolean slow) } @GuiAction - protected void back() - { + protected void back() { Gui.open(getPlayer(), new MainConfigGUI()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java index 81aa65c..052af15 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/GameSidebar.java @@ -29,31 +29,28 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; -import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; +import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleWrapper; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import fr.zcraft.quartzlib.components.scoreboard.Sidebar; import fr.zcraft.quartzlib.components.scoreboard.SidebarMode; -import org.bukkit.entity.Player; - import java.util.List; +import org.bukkit.entity.Player; -public class GameSidebar extends Sidebar -{ - public GameSidebar() - { +public class GameSidebar extends Sidebar { + public GameSidebar() { setAutoRefreshDelay(10); setTitleMode(SidebarMode.GLOBAL); setContentMode(SidebarMode.PER_PLAYER); } @Override - public void preRender() - { + public void preRender() { QuartzSurvivalGames.get().getModulesManager().getModules().stream() .filter(ModuleWrapper::isLoaded) .map(ModuleWrapper::get) @@ -61,8 +58,7 @@ public void preRender() } @Override - public List<String> getContent(Player player) - { + public List<String> getContent(Player player) { final SidebarInjector injector = new SidebarInjector(); QuartzSurvivalGames.get().getModulesManager().getModules().stream() @@ -74,8 +70,7 @@ public List<String> getContent(Player player) } @Override - public String getTitle(Player player) - { + public String getTitle(Player player) { return QSGConfig.TITLE.get(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java index 820381f..8e21a54 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarInjector.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; import java.util.Arrays; @@ -43,22 +44,20 @@ /** * An instance of this class will be passed to each modules to add for a given player lines to the sidebar. */ -public class SidebarInjector -{ +public class SidebarInjector { private final Set<LinesBucket> buckets = new TreeSet<>(new LinesBucketComparator()); /** * Injects lines into the sidebar. * - * @param priority The lines priority to order all injected lines. + * @param priority The lines priority to order all injected lines. * @param spacesAbove {@code true} to add a space above the given lines (if not first) * @param spacesBelow {@code true} to add a space below the given lines (if not last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, final boolean spacesBelow, final Collection<String> lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, + final boolean spacesBelow, final Collection<String> lines) { buckets.add(new LinesBucket(priority, spacesAbove, spacesBelow, new LinkedList<>(lines))); return this; } @@ -66,15 +65,14 @@ public SidebarInjector injectLines(final SidebarPriority priority, final boolean /** * Injects lines into the sidebar. * - * @param priority The lines priority to order all injected lines. + * @param priority The lines priority to order all injected lines. * @param spacesAbove {@code true} to add a space above the given lines (if not first) * @param spacesBelow {@code true} to add a space below the given lines (if not last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, final boolean spacesBelow, final String... lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAbove, + final boolean spacesBelow, final String... lines) { injectLines(priority, spacesAbove, spacesBelow, Arrays.asList(lines)); return this; } @@ -82,14 +80,13 @@ public SidebarInjector injectLines(final SidebarPriority priority, final boolean /** * Injects lines into the sidebar. * - * @param priority The lines priority to order all injected lines. + * @param priority The lines priority to order all injected lines. * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, final Collection<String> lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, + final Collection<String> lines) { injectLines(priority, spacesAround, spacesAround, lines); return this; } @@ -97,14 +94,13 @@ public SidebarInjector injectLines(final SidebarPriority priority, final boolean /** * Injects lines into the sidebar. * - * @param priority The lines priority to order all injected lines. + * @param priority The lines priority to order all injected lines. * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, final String... lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final boolean spacesAround, + final String... lines) { injectLines(priority, spacesAround, spacesAround, Arrays.asList(lines)); return this; } @@ -113,12 +109,10 @@ public SidebarInjector injectLines(final SidebarPriority priority, final boolean * Injects lines into the sidebar. No spaces are added before or after. * * @param priority The lines priority to order all injected lines. - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final Collection<String> lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final Collection<String> lines) { injectLines(priority, false, false, lines); return this; } @@ -127,12 +121,10 @@ public SidebarInjector injectLines(final SidebarPriority priority, final Collect * Injects lines into the sidebar. No spaces are added before or after. * * @param priority The lines priority to order all injected lines. - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final SidebarPriority priority, final String... lines) - { + public SidebarInjector injectLines(final SidebarPriority priority, final String... lines) { injectLines(priority, false, false, Arrays.asList(lines)); return this; } @@ -142,12 +134,11 @@ public SidebarInjector injectLines(final SidebarPriority priority, final String. * * @param spacesAbove {@code true} to add a space above the given lines (if not first) * @param spacesBelow {@code true} to add a space below the given lines (if not last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, final Collection<String> lines) - { + public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, + final Collection<String> lines) { injectLines(SidebarPriority.MIDDLE, spacesAbove, spacesBelow, lines); return this; } @@ -157,12 +148,10 @@ public SidebarInjector injectLines(final boolean spacesAbove, final boolean spac * * @param spacesAbove {@code true} to add a space above the given lines (if not first) * @param spacesBelow {@code true} to add a space below the given lines (if not last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, final String... lines) - { + public SidebarInjector injectLines(final boolean spacesAbove, final boolean spacesBelow, final String... lines) { injectLines(SidebarPriority.MIDDLE, spacesAbove, spacesBelow, Arrays.asList(lines)); return this; } @@ -171,12 +160,10 @@ public SidebarInjector injectLines(final boolean spacesAbove, final boolean spac * Injects lines into the sidebar without constrain on placement. * * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final boolean spacesAround, final Collection<String> lines) - { + public SidebarInjector injectLines(final boolean spacesAround, final Collection<String> lines) { injectLines(SidebarPriority.MIDDLE, spacesAround, spacesAround, lines); return this; } @@ -185,12 +172,10 @@ public SidebarInjector injectLines(final boolean spacesAround, final Collection< * Injects lines into the sidebar without constrain on placement. * * @param spacesAround {@code true} to add a space above and below the given lines (if not first/last) - * @param lines The lines (from top to bottom). - * + * @param lines The lines (from top to bottom). * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final boolean spacesAround, final String... lines) - { + public SidebarInjector injectLines(final boolean spacesAround, final String... lines) { injectLines(SidebarPriority.MIDDLE, spacesAround, spacesAround, Arrays.asList(lines)); return this; } @@ -199,11 +184,9 @@ public SidebarInjector injectLines(final boolean spacesAround, final String... l * Injects lines into the sidebar without constrain on placement. No spaces are added before or after. * * @param lines The lines (from top to bottom). - * * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final Collection<String> lines) - { + public SidebarInjector injectLines(final Collection<String> lines) { injectLines(SidebarPriority.MIDDLE, false, false, lines); return this; } @@ -212,92 +195,47 @@ public SidebarInjector injectLines(final Collection<String> lines) * Injects lines into the sidebar without constrain on placement. No spaces are added before or after. * * @param lines The lines (from top to bottom). - * * @return current instance, for methods chaining. */ - public SidebarInjector injectLines(final String... lines) - { + public SidebarInjector injectLines(final String... lines) { injectLines(SidebarPriority.MIDDLE, false, false, Arrays.asList(lines)); return this; } /** * Builds the lines for the sidebar according to the priorities and the spaces requirements. - * + * <p> * Does not adds multiple empty lines if one bucket requiring spaces below is followed by one * requiring spaces above. * * @return a list of lines ready to be used by the sidebar. */ - public List<String> buildLines() - { + public List<String> buildLines() { final LinkedList<String> lines = new LinkedList<>(); // Initially to true so for the first one, if there is a space above, it's not added. boolean lastInsertedASpace = true; - for (final LinesBucket bucket : buckets) - { - if (bucket.spaceAbove && !lastInsertedASpace) - { + for (final LinesBucket bucket : buckets) { + if (bucket.spaceAbove && !lastInsertedASpace) { lines.add(""); } lines.addAll(bucket.lines); - if (bucket.spaceBelow) - { + if (bucket.spaceBelow) { lines.add(""); lastInsertedASpace = true; - } - else - { + } else { lastInsertedASpace = false; } } - if (lines.getLast().equals("")) lines.removeLast(); - - return lines; - } - - /** - * Represents a packet of lines added to the scoreboard. - */ - private static class LinesBucket - { - private static int inserts = 0; - - private final int insertOrder; - private final SidebarPriority priority; - private final boolean spaceAbove; - private final boolean spaceBelow; - private final List<String> lines; - - private LinesBucket(final SidebarPriority priority, final boolean spaceAbove, final boolean spaceBelow, final List<String> lines) - { - this.insertOrder = ++inserts; - - this.priority = priority; - this.spaceAbove = spaceAbove; - this.spaceBelow = spaceBelow; - this.lines = lines; + if (lines.getLast().equals("")) { + lines.removeLast(); } - } - - /** - * Comparator for {@link LinesBucket}. - */ - protected class LinesBucketComparator implements Comparator<LinesBucket> - { - @Override - public int compare(final LinesBucket bucket1, final LinesBucket bucket2) - { - final int priorityComparison = Integer.compare(bucket1.priority.ordinal(), bucket2.priority.ordinal()); - if (priorityComparison != 0) return priorityComparison; - else return Integer.compare(bucket1.insertOrder, bucket2.insertOrder); - } + return lines; } /** @@ -305,8 +243,7 @@ public int compare(final LinesBucket bucket1, final LinesBucket bucket2) * sidebar. Lines in the same priority bucket will be displayed in an order * dependant on the modules's loading order. */ - public enum SidebarPriority - { + public enum SidebarPriority { /** * Places the lines at the very top of the scoreboard. */ @@ -342,4 +279,43 @@ public enum SidebarPriority */ VERY_BOTTOM } + + /** + * Represents a packet of lines added to the scoreboard. + */ + private static class LinesBucket { + private static int inserts = 0; + + private final int insertOrder; + private final SidebarPriority priority; + private final boolean spaceAbove; + private final boolean spaceBelow; + private final List<String> lines; + + private LinesBucket(final SidebarPriority priority, final boolean spaceAbove, final boolean spaceBelow, + final List<String> lines) { + this.insertOrder = ++inserts; + + this.priority = priority; + this.spaceAbove = spaceAbove; + this.spaceBelow = spaceBelow; + this.lines = lines; + } + } + + /** + * Comparator for {@link LinesBucket}. + */ + protected class LinesBucketComparator implements Comparator<LinesBucket> { + @Override + public int compare(final LinesBucket bucket1, final LinesBucket bucket2) { + final int priorityComparison = Integer.compare(bucket1.priority.ordinal(), bucket2.priority.ordinal()); + + if (priorityComparison != 0) { + return priorityComparison; + } else { + return Integer.compare(bucket1.insertOrder, bucket2.insertOrder); + } + } + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java index 56be4f5..12be0a2 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/sidebar/SidebarModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,7 +42,7 @@ import org.bukkit.event.player.PlayerJoinEvent; -@ModuleInfo ( +@ModuleInfo( name = "Sidebar", description = "Manages the sidebar and allows hooks for all modules into it.", category = ModuleCategory.CORE, @@ -49,22 +50,19 @@ internal = true, can_be_unloaded = false ) -public class SidebarModule extends QSGModule -{ +public class SidebarModule extends QSGModule { private GameSidebar sidebar; @Override - protected void onEnable() - { + protected void onEnable() { sidebar = new GameSidebar(); sidebar.runAutoRefresh(true); Bukkit.getOnlinePlayers().forEach(player -> sidebar.addRecipient(player)); } - @EventHandler (priority = EventPriority.LOWEST) - public void onPlayerJoin(final PlayerJoinEvent ev) - { + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerJoin(final PlayerJoinEvent ev) { sidebar.addRecipient(ev.getPlayer()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java index 4ea9d22..c6f09dd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Config.java @@ -29,26 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationList; -import org.bukkit.Location; - import java.io.File; - -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; +import org.bukkit.Location; -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Boolean> AVOID_WATER = item("avoid-water", true); public static final ConfigurationList<Location> SPAWN_POINTS = list("spawn-points", Location.class); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java index e6ea8e1..66c0f83 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/Generator.java @@ -39,13 +39,11 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators.SpawnPointsGenerator; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; - import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; -public enum Generator -{ +public enum Generator { /** * Spawn points generated randomly. */ @@ -64,13 +62,12 @@ public enum Generator CIRCULAR(CircularSpawnPointsGenerator.class); - private Class<? extends SpawnPointsGenerator> generatorClass; + private final Class<? extends SpawnPointsGenerator> generatorClass; /** * @param generatorClass The generator. */ - Generator(Class<? extends SpawnPointsGenerator> generatorClass) - { + Generator(Class<? extends SpawnPointsGenerator> generatorClass) { this.generatorClass = generatorClass; } @@ -82,14 +79,11 @@ public enum Generator * @param name The name. * @return The Generator, or null if not found. */ - public static Generator fromString(String name) - { - try - { + public static Generator fromString(String name) { + try { return Generator.valueOf(name.trim().toUpperCase()); } - catch (IllegalArgumentException e) - { + catch (IllegalArgumentException e) { return null; } } @@ -99,20 +93,19 @@ public static Generator fromString(String name) * * @return The instance. */ - public SpawnPointsGenerator getInstance() - { - try - { + public SpawnPointsGenerator getInstance() { + try { return Reflection.instantiate(generatorClass); } - catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) - { - PluginLogger.log(Level.SEVERE, "Cannot instantiate the spawn points generator: invalid class (missing constructor?): " + generatorClass.getName(), e.getCause()); + catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) { + PluginLogger.log(Level.SEVERE, + "Cannot instantiate the spawn points generator: invalid class (missing constructor?): " + + generatorClass.getName(), e.getCause()); return null; } - catch (InvocationTargetException e) - { - PluginLogger.log(Level.SEVERE, "Error during the spawn points generator instantiation: " + generatorClass.getName(), e.getCause()); + catch (InvocationTargetException e) { + PluginLogger.log(Level.SEVERE, + "Error during the spawn points generator instantiation: " + generatorClass.getName(), e.getCause()); return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java index d946055..abac9ca 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/SpawnsModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns; import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; @@ -46,6 +47,10 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzteams.QuartzTeams; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -53,11 +58,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.stream.Collectors; - @ModuleInfo( name = "Spawns", @@ -68,19 +68,16 @@ internal = true, can_be_unloaded = false ) -public class SpawnsModule extends QSGModule -{ - private List<Location> spawnPoints = new LinkedList<>(); +public class SpawnsModule extends QSGModule { + private final List<Location> spawnPoints = new LinkedList<>(); @Override - protected void onEnable() - { + protected void onEnable() { spawnPoints.addAll(Config.SPAWN_POINTS); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(SpawnsCommand.class); } @@ -89,8 +86,7 @@ public List<Class<? extends Command>> getCommands() * * @param vec The vector representing the X and Z coordinates. */ - public void addSpawnPoint(final Vector vec) - { + public void addSpawnPoint(final Vector vec) { addSpawnPoint(QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL), vec.getX(), vec.getZ()); } @@ -100,8 +96,7 @@ public void addSpawnPoint(final Vector vec) * @param x The X coordinate. * @param z The Z coordinate. */ - public void addSpawnPoint(final Double x, final Double z) - { + public void addSpawnPoint(final Double x, final Double z) { addSpawnPoint(QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL), x, z); } @@ -112,8 +107,7 @@ public void addSpawnPoint(final Double x, final Double z) * @param x The X coordinate. * @param z The Z coordinate. */ - public void addSpawnPoint(final World world, final Double x, final Double z) - { + public void addSpawnPoint(final World world, final Double x, final Double z) { addSpawnPoint(new Location(world, x, 0, z)); } @@ -126,28 +120,22 @@ public void addSpawnPoint(final World world, final Double x, final Double z) * found. * @throws IllegalArgumentException If the spawn point is out of the current border. */ - public void addSpawnPoint(final Location location) - { + public void addSpawnPoint(final Location location) { final Location spawnPoint = location.clone(); // Initial fall, except in the nether. - if (!(spawnPoint.getWorld().getEnvironment() == World.Environment.NETHER)) - { + if (!(spawnPoint.getWorld().getEnvironment() == World.Environment.NETHER)) { spawnPoint.setY(location.getWorld().getHighestBlockYAt(location.getBlockX(), location.getBlockZ()) + 120); - } - else - { + } else { final Location safeSpot = QSGUtils.searchSafeSpot(location); - if (safeSpot == null) - { + if (safeSpot == null) { throw new RuntimeException("Unable to find a safe spot to set the spawn point " + location.toString()); } spawnPoint.setY(safeSpot.getY()); } - if (!QSG.module(BorderModule.class).isInsideBorder(spawnPoint)) - { + if (!QSG.module(BorderModule.class).isInsideBorder(spawnPoint)) { throw new IllegalArgumentException("The given spawn location is outside the current border"); } @@ -159,8 +147,7 @@ public void addSpawnPoint(final Location location) * * @return The spawn points. */ - public List<Location> getSpawnPoints() - { + public List<Location> getSpawnPoints() { return spawnPoints; } @@ -173,8 +160,7 @@ public List<Location> getSpawnPoints() * Else, the points in the same block. * @return true if something were removed. */ - public boolean removeSpawnPoint(final Location location, final boolean precise) - { + public boolean removeSpawnPoint(final Location location, final boolean precise) { final List<Location> toRemove = getSpawnPoints().stream() .filter(spawn -> location.getWorld().equals(spawn.getWorld())) .filter(spawn -> precise @@ -184,11 +170,10 @@ public boolean removeSpawnPoint(final Location location, final boolean precise) && location.getBlockZ() == spawn.getBlockZ()) .collect(Collectors.toCollection(LinkedList::new)); - for (Location spawnToRemove : toRemove) - { + for (Location spawnToRemove : toRemove) { // Used to remove all occurrences of the spawn point - while (spawnPoints.remove(spawnToRemove)) - ; + while (spawnPoints.remove(spawnToRemove)) { + } } return toRemove.size() != 0; @@ -199,13 +184,11 @@ public boolean removeSpawnPoint(final Location location, final boolean precise) * <p> * CANNOT BE CANCELLED. */ - public void reset() - { + public void reset() { spawnPoints.clear(); } - /** * Generates spawn points with the given generator. * @@ -225,15 +208,15 @@ public void reset() * @throws CannotGenerateSpawnPointsException In case of fail. * @throws UnknownGeneratorException If no generator was found by the given name. */ - public void generateSpawnPoints(final String generatorName, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException, UnknownGeneratorException - { + public void generateSpawnPoints(final String generatorName, final World world, final int spawnCount, + final int regionDiameter, final int minimalDistanceBetweenTwoPoints, + final double xCenter, final double zCenter) + throws CannotGenerateSpawnPointsException, UnknownGeneratorException { Generator generator = Generator.fromString(generatorName); - if (generator != null) - { - generateSpawnPoints(generator, world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, xCenter, zCenter); - } - else - { + if (generator != null) { + generateSpawnPoints(generator, world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, xCenter, + zCenter); + } else { throw new UnknownGeneratorException("The generator '" + generatorName + "' does not exists."); } } @@ -256,9 +239,12 @@ public void generateSpawnPoints(final String generatorName, final World world, f * region where the points will be generated. * @throws CannotGenerateSpawnPointsException In case of fail. */ - public void generateSpawnPoints(final Generator generator, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException - { - generateSpawnPoints(generator.getInstance(), world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, xCenter, zCenter); + public void generateSpawnPoints(final Generator generator, final World world, final int spawnCount, + final int regionDiameter, final int minimalDistanceBetweenTwoPoints, + final double xCenter, final double zCenter) + throws CannotGenerateSpawnPointsException { + generateSpawnPoints(generator.getInstance(), world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, + xCenter, zCenter); } /** @@ -279,8 +265,10 @@ public void generateSpawnPoints(final Generator generator, final World world, fi * region where the points will be generated. * @throws CannotGenerateSpawnPointsException In case of fail. */ - public void generateSpawnPoints(final SpawnPointsGenerator generator, final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter) throws CannotGenerateSpawnPointsException - { + public void generateSpawnPoints(final SpawnPointsGenerator generator, final World world, final int spawnCount, + final int regionDiameter, final int minimalDistanceBetweenTwoPoints, + final double xCenter, final double zCenter) + throws CannotGenerateSpawnPointsException { generator.generate( world, spawnCount, regionDiameter, minimalDistanceBetweenTwoPoints, @@ -293,8 +281,7 @@ public void generateSpawnPoints(final SpawnPointsGenerator generator, final Worl * Generates on the fly missing spawn points when the game starts. */ @EventHandler - public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) - { + public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) { final GameModule game = QSG.module(GameModule.class); final World normalWorld = QSG.get().getWorld(World.Environment.NORMAL); @@ -306,8 +293,7 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) int spawnsNeeded = 0; - switch (game.getTeleportationMode()) - { + switch (game.getTeleportationMode()) { case NORMAL: spawnsNeeded = QuartzTeams.get().countTeams() + playersWithoutTeam; break; @@ -320,14 +306,14 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) spawnsNeeded -= spawnPoints.size(); // We don't need what we already have. - if (spawnsNeeded <= 0) return; + if (spawnsNeeded <= 0) { + return; + } Exception error = null; - for (int i = 0; i < 6; i++) - { - try - { + for (int i = 0; i < 6; i++) { + try { generateSpawnPoints( Generator.RANDOM, normalWorld, @@ -340,8 +326,7 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) error = null; } - catch (final CannotGenerateSpawnPointsException e) - { + catch (final CannotGenerateSpawnPointsException e) { error = e; continue; } @@ -349,13 +334,13 @@ public void beforeTeleportationPhase(final BeforeTeleportationPhaseEvent ev) break; } - if (error == null) - { - log().info("Randomly generated {0} missing spawn points on the fly. See /uh spawn for details.", spawnsNeeded); - } - else - { - log().error("There where {0} missing spawn points but we weren''t able to generate them automatically, even after 6 tries. Try to generate them yourself using /uh spawns generate, or to add them manually with /uh spawns add.", error, spawnsNeeded); + if (error == null) { + log().info("Randomly generated {0} missing spawn points on the fly. See /uh spawn for details.", + spawnsNeeded); + } else { + log().error( + "There where {0} missing spawn points but we weren''t able to generate them automatically, even after 6 tries. Try to generate them yourself using /uh spawns generate, or to add them manually with /uh spawns add.", + error, spawnsNeeded); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java index 2dcd607..5926bcc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/commands/SpawnsCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -45,6 +46,11 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzteams.QuartzTeam; import fr.zcraft.quartzteams.QuartzTeams; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -52,31 +58,21 @@ import org.bukkit.command.BlockCommandSender; import org.bukkit.entity.Player; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @CommandInfo( name = "spawns", usageParameters = "[generate | add [<x> <z>] | remove [<x> <z>] | dump | help]", aliases = {"spawn", "s"} ) -public class SpawnsCommand extends Command -{ +public class SpawnsCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length == 0) - { + protected void run() throws CommandException { + if (args.length == 0) { list(); return; } - switch (args[0].toLowerCase()) - { + switch (args[0].toLowerCase()) { case "list": list(); return; @@ -105,35 +101,37 @@ protected void run() throws CommandException } } - protected void help() - { + protected void help() { info(I.t("{blue}{bold}Command help for {cc}{bold}/uh spawns")); info(I.t("{cc}/uh spawns list {ci}: lists the registered spawn points.")); - info(I.t("{cc}/uh spawns dump {ci}: displays the registered spawn points in an exportable format. {gray}Use this to plot the spawn points, as example.")); - info(I.t("{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the current location of the sender or at the provided coordinates.")); - info(I.t("{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the specified coordinates, or at the current location if the sender without coordinates.")); - info(I.t("{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh spawns generate for details.")); + info(I.t( + "{cc}/uh spawns dump {ci}: displays the registered spawn points in an exportable format. {gray}Use this to plot the spawn points, as example.")); + info(I.t( + "{cc}/uh spawns add {ci}: adds a spawn point for a team or a player, at the current location of the sender or at the provided coordinates.")); + info(I.t( + "{cc}/uh spawns remove [<x> <z>] {ci}: removes the spawn points at the specified coordinates, or at the current location if the sender without coordinates.")); + info(I.t( + "{cc}/uh spawns generate {ci}: automagically generates spawn points. See /uh spawns generate for details.")); info(I.t("{cc}/uh spawns reset {ci}: removes all registered spawn points.")); } - protected void list() - { + protected void list() { final List<Location> spawnPoints = QSG.module(SpawnsModule.class).getSpawnPoints(); - if (spawnPoints.size() == 0) - { - if (sender instanceof Player) info(""); + if (spawnPoints.size() == 0) { + if (sender instanceof Player) { + info(""); + } info(I.t("{ce}There isn't any registered spawn point.")); - if (args.length == 0) - { + if (args.length == 0) { info(""); help(); } - } - else - { - if (sender instanceof Player) info(""); + } else { + if (sender instanceof Player) { + info(""); + } info(I.t("{ci}There are {0} registered spawn points.", String.valueOf(spawnPoints.size()))); // We want one list per world @@ -143,10 +141,8 @@ protected void list() spawnsInWorlds.get(spawn.getWorld()).add(spawn); }); - for (Map.Entry<World, List<Location>> spanwsInWorld : spawnsInWorlds.entrySet()) - { - if (spanwsInWorld.getValue().size() == 0) - { + for (Map.Entry<World, List<Location>> spanwsInWorld : spawnsInWorlds.entrySet()) { + if (spanwsInWorld.getValue().size() == 0) { continue; } @@ -157,14 +153,11 @@ protected void list() // Displaying this number of spawn points per line final int spawnsPerLine = 5; - for (int j = 0; j < Math.ceil((double) spanwsInWorld.getValue().size() / spawnsPerLine); j++) - { + for (int j = 0; j < Math.ceil((double) spanwsInWorld.getValue().size() / spawnsPerLine); j++) { final StringBuilder line = new StringBuilder(); - for (int k = 0; k < spawnsPerLine; k++) - { - if (spanwsInWorld.getValue().size() > j * spawnsPerLine + k) - { + for (int k = 0; k < spawnsPerLine; k++) { + if (spanwsInWorld.getValue().size() > j * spawnsPerLine + k) { line.append( getSpawnItem( spanwsInWorld.getValue().get(j * spawnsPerLine + k).getBlockX(), @@ -181,8 +174,7 @@ protected void list() } } - protected void dump() - { + protected void dump() { // We want one list per world final Map<World, List<Location>> spawnsInWorlds = new HashMap<>(); @@ -195,17 +187,14 @@ protected void dump() StringBuilder dump = new StringBuilder(); - for (Map.Entry<World, List<Location>> spawnsInWorld : spawnsInWorlds.entrySet()) - { - if (spawnsInWorld.getValue().size() == 0) - { + for (Map.Entry<World, List<Location>> spawnsInWorld : spawnsInWorlds.entrySet()) { + if (spawnsInWorld.getValue().size() == 0) { continue; } dump.append("\n* ").append(spawnsInWorld.getKey().getName()).append("\n"); - for (Location spawn : spawnsInWorld.getValue()) - { + for (Location spawn : spawnsInWorld.getValue()) { dump.append(spawn.getBlockX()).append(",").append(spawn.getBlockZ()).append("\n"); } } @@ -213,109 +202,90 @@ protected void dump() sender.sendMessage(dump.toString()); } - protected void add() throws CommandException - { + protected void add() throws CommandException { // World? final World world; - if (sender instanceof Player) - { + if (sender instanceof Player) { world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { + } else if (sender instanceof BlockCommandSender) { world = ((BlockCommandSender) sender).getBlock().getWorld(); - } - else if (args.length >= 4) - { + } else if (args.length >= 4) { world = Bukkit.getWorld(args[3]); - if (world == null) throwInvalidArgument(I.t("There is no world named {0}.", args[3])); - } - else - { + if (world == null) { + throwInvalidArgument(I.t("There is no world named {0}.", args[3])); + } + } else { world = QSG.get().getWorld(Environment.NORMAL); } // /uh spawns add - if (args.length == 1) - { - try - { + if (args.length == 1) { + try { QSG.module(SpawnsModule.class).addSpawnPoint(playerSender().getLocation()); - success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), String.valueOf(playerSender().getLocation().getBlockX()), String.valueOf(playerSender().getLocation().getBlockZ()))); + success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), + String.valueOf(playerSender().getLocation().getBlockX()), + String.valueOf(playerSender().getLocation().getBlockZ()))); } - catch (IllegalArgumentException e) - { + catch (IllegalArgumentException e) { error(I.t("{ce}You cannot add a spawn point out of the borders.")); } - catch (RuntimeException e) - { + catch (RuntimeException e) { error(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); } } // /uh spawns add <x>: Two coordinates needed! - else if (args.length == 2) - { + else if (args.length == 2) { throwInvalidArgument(I.t("{ce}You need to specify two coordinates.")); } // /uh spawns add <x> <z> [world] - else - { - try - { - QSG.module(SpawnsModule.class).addSpawnPoint(world, Double.parseDouble(args[1]), Double.parseDouble(args[2])); + else { + try { + QSG.module(SpawnsModule.class) + .addSpawnPoint(world, Double.parseDouble(args[1]), Double.parseDouble(args[2])); success(I.t("{cs}Spawn added in the world {0}: {1};{2}", world.getName(), args[1], args[2])); } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { throwInvalidArgument(I.t("{ce}This is not a number!")); } - catch (IllegalArgumentException e) - { + catch (IllegalArgumentException e) { error(I.t("{ce}You cannot add a spawn point out of the borders.")); } - catch (RuntimeException e) - { + catch (RuntimeException e) { error(I.t("{ce}Unable to add this spawn point: no safe spot found in the Nether.")); } } } - protected void remove() throws CommandException - { + protected void remove() throws CommandException { // /uh spawns remove - if (args.length == 1) - { + if (args.length == 1) { QSG.module(SpawnsModule.class).removeSpawnPoint(playerSender().getLocation(), false); - success(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", playerSender().getWorld().getName(), playerSender().getLocation().getBlockX(), playerSender().getLocation().getBlockZ())); + success(I + .t("{cs}The spawn point {1};{2} in the world {0} was removed.", playerSender().getWorld().getName(), + playerSender().getLocation().getBlockX(), playerSender().getLocation().getBlockZ())); } // /uh spawns add <x>: Two coordinates needed! - else if (args.length == 2) - { + else if (args.length == 2) { throwInvalidArgument(I.t("{ce}You need to specify two coordinates.")); } // /uh spawns remove <x> <z> - else - { - try - { + else { + try { final World world; - if (sender instanceof Player) - { + if (sender instanceof Player) { world = ((Player) sender).getWorld(); - } - else if (args.length >= 4) - { + } else if (args.length >= 4) { world = Bukkit.getWorld(args[3]); - if (world == null) throwInvalidArgument(I.t("There is no world named {0}.", args[3])); - } - else - { + if (world == null) { + throwInvalidArgument(I.t("There is no world named {0}.", args[3])); + } + } else { world = QSG.get().getWorld(Environment.NORMAL); } @@ -327,39 +297,44 @@ else if (args.length >= 4) ); success(I.t("{cs}The spawn point {1};{2} in the world {0} was removed.", world, args[1], args[2])); } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { throwInvalidArgument(I.t("{ce}This is not a number!")); } } } - protected void reset() - { + protected void reset() { QSG.module(SpawnsModule.class).reset(); success(I.t("{cs}All the spawn points were removed.")); } - protected void generate() throws CommandException - { + protected void generate() throws CommandException { // /uh spawns generate - if (args.length == 1) - { - if (sender instanceof Player) info(""); + if (args.length == 1) { + if (sender instanceof Player) { + info(""); + } info(I.t("{aqua}Command")); - info(I.t("{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); + info(I.t( + "{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); info(""); info(I.t("{aqua}Shapes")); - info(I.t(" - {cc}random{ci}: generates random spawn points on the map, with a minimal distance between them.")); - info(I.t(" - {cc}grid{ci}: generates the spawn points on concentric squares, with a constant distance between two generated points.")); - info(I.t(" - {cc}circular{ci}: generates the spawn points on concentric circles, with a minimal distance between two generated points. In each circle, the angle (and the distance) between two spawn points is constant.")); + info(I.t( + " - {cc}random{ci}: generates random spawn points on the map, with a minimal distance between them.")); + info(I.t( + " - {cc}grid{ci}: generates the spawn points on concentric squares, with a constant distance between two generated points.")); + info(I.t( + " - {cc}circular{ci}: generates the spawn points on concentric circles, with a minimal distance between two generated points. In each circle, the angle (and the distance) between two spawn points is constant.")); info(""); info(I.t("{aqua} Arguments ")); - info(I.t(" - {cc}size{ci}: the size of the region where the spawn points will be generated. Squared or circular, following the shape of the map. Default: map' size.")); + info(I.t( + " - {cc}size{ci}: the size of the region where the spawn points will be generated. Squared or circular, following the shape of the map. Default: map' size.")); info(I.t(" - {cc}distanceMin{ci}: the minimal distance between two spawn points. Default: 250 blocks.")); - info(I.t(" - {cc}count{ci}: the number of spawn points to generate. Default: the number of players or teams.")); - info(I.t(" - {cc}xCenter{ci}, {cc}zCenter{ci}: the center of the region where the points are generated. Default: world' spawn point.")); + info(I.t( + " - {cc}count{ci}: the number of spawn points to generate. Default: the number of players or teams.")); + info(I.t( + " - {cc}xCenter{ci}, {cc}zCenter{ci}: the center of the region where the points are generated. Default: world' spawn point.")); info(I.t(" - {cc}world{ci}: the world where the spawn points will be generated.")); return; @@ -368,26 +343,24 @@ protected void generate() throws CommandException final String generationMethod = args[1]; // Default values - int size = QSG.module(BorderModule.class).getCurrentBorderDiameter() - 25; // Avoid spawn points being too close to the border + int size = QSG.module(BorderModule.class).getCurrentBorderDiameter() - + 25; // Avoid spawn points being too close to the border int distanceMinBetweenTwoPoints = 250; World world = QSG.get().getWorld(Environment.NORMAL); double xCenter = world.getSpawnLocation().getX(); double zCenter = world.getSpawnLocation().getZ(); int spawnsCount = 0; - for (final QuartzTeam team : QuartzTeams.get().getTeams()) - { - if (!team.isEmpty()) spawnsCount++; + for (final QuartzTeam team : QuartzTeams.get().getTeams()) { + if (!team.isEmpty()) { + spawnsCount++; + } } - if (args.length < 8) - { - if (sender instanceof Player) - { + if (args.length < 8) { + if (sender instanceof Player) { world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { + } else if (sender instanceof BlockCommandSender) { world = ((BlockCommandSender) sender).getBlock().getWorld(); } @@ -398,72 +371,56 @@ else if (sender instanceof BlockCommandSender) // What if the game is in solo, or some players are out of all team? // Only if the spawn count is not provided of course. Else, we don't care, this count // will be overwritten. - if (args.length < 6) - { + if (args.length < 6) { // Solo mode? - if (spawnsCount == 0) - { - spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - QSG.module(SpectatorsModule.class).getSpectators().size(); + if (spawnsCount == 0) { + spawnsCount = Bukkit.getServer().getOnlinePlayers().size() - + QSG.module(SpectatorsModule.class).getSpectators().size(); info(I.t("{ci}No team found: assuming the game is a solo game.")); - } - else - { + } else { // Trying to find players without team int playersWithoutTeam = 0; - for (Player player : Bukkit.getServer().getOnlinePlayers()) - { - if (QuartzTeams.get().getTeamForPlayer(player) == null) - { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + if (QuartzTeams.get().getTeamForPlayer(player) == null) { playersWithoutTeam++; } } - if (playersWithoutTeam != 0) - { + if (playersWithoutTeam != 0) { spawnsCount += playersWithoutTeam; info(I.t("{ci}Some players are not in a team; their number was added to the spawn count.")); } } } - try - { + try { // size included - if (args.length >= 3) - { + if (args.length >= 3) { size = Integer.parseInt(args[2]); // distance minimal included - if (args.length >= 4) - { + if (args.length >= 4) { distanceMinBetweenTwoPoints = Integer.parseInt(args[3]); // spawn count included - if (args.length >= 5) - { + if (args.length >= 5) { spawnsCount = Integer.parseInt(args[4]); // xCenter included - if (args.length >= 6) - { + if (args.length >= 6) { xCenter = Double.parseDouble(args[5]); // zCenter included - if (args.length >= 7) - { + if (args.length >= 7) { zCenter = Double.parseDouble(args[6]); // world included - if (args.length >= 8) - { + if (args.length >= 8) { final World inputWorld = Bukkit.getServer().getWorld(args[7]); - if (inputWorld != null) - { + if (inputWorld != null) { world = inputWorld; - } - else - { + } else { error(I.t("{ce}The world {0} doesn't exists.", args[7])); } } @@ -473,34 +430,32 @@ else if (sender instanceof BlockCommandSender) } } } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { info(I.t("{ce}This is not a number!")); - info(I.t("{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); + info(I.t( + "{cc}/uh spawns generate <circular|grid|random> [size] [distanceMin] [count] [xCenter] [zCenter] [world]")); return; } - if (spawnsCount <= 0) - { + if (spawnsCount <= 0) { sender.sendMessage(I.t("{ci}You asked for a void generation. Thus, the generation is empty.")); return; } - try - { + try { QSG.module(SpawnsModule.class) - .generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, xCenter, zCenter); + .generateSpawnPoints(generationMethod, world, spawnsCount, size, distanceMinBetweenTwoPoints, + xCenter, zCenter); } - catch (UnknownGeneratorException e) - { + catch (UnknownGeneratorException e) { throwInvalidArgument(I.t("{ce}The generation method “{0}” is not (yet?) supported.", generationMethod)); } - catch (CannotGenerateSpawnPointsException e) - { - error(I.t("{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); + catch (CannotGenerateSpawnPointsException e) { + error(I.t( + "{ce}You asked for the impossible: there are too many spawn points on a too small surface. Decrease the spawn count or the minimal distance between two points.")); } @@ -508,36 +463,25 @@ else if (sender instanceof BlockCommandSender) } @Override - protected List<String> complete() throws CommandException - { - if (args.length == 1) - { + protected List<String> complete() throws CommandException { + if (args.length == 1) { return getMatchingSubset(args[0], "add", "remove", "generate", "list", "dump", "reset"); - } - - else if (args.length == 2 && args[0].equalsIgnoreCase("generate")) - { + } else if (args.length == 2 && args[0].equalsIgnoreCase("generate")) { return getMatchingSubset(args[1], "circular", "grid", "random"); + } else if (args.length == 4 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) { + return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), + args[3]); + } else if (args.length == 8 && args[0].equalsIgnoreCase("generate")) { + return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), + args[7]); + } else { + return null; } - - else if (args.length == 4 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) - { - return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), args[3]); - } - - else if (args.length == 8 && args[0].equalsIgnoreCase("generate")) - { - return getMatchingSubset(Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), args[7]); - } - - else return null; } - private String getSpawnItem(int x, int z, Environment environment) - { - switch (environment) - { + private String getSpawnItem(int x, int z, Environment environment) { + switch (environment) { case NORMAL: /// A spawn point in the /uh spawns list command (in the overworld) return I.t("{green}{0}{darkgreen};{green}{1}", x, z); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java index a87b947..761600b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/CannotGenerateSpawnPointsException.java @@ -33,11 +33,9 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions; -public class CannotGenerateSpawnPointsException extends Exception -{ +public class CannotGenerateSpawnPointsException extends Exception { - public CannotGenerateSpawnPointsException(String message) - { + public CannotGenerateSpawnPointsException(String message) { super(message); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java index bf2a109..763e31e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/exceptions/UnknownGeneratorException.java @@ -29,13 +29,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions; -public class UnknownGeneratorException extends Exception -{ +public class UnknownGeneratorException extends Exception { - public UnknownGeneratorException(String message) - { + public UnknownGeneratorException(String message) { super(message); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java index 3237a90..4775803 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/CircularSpawnPointsGenerator.java @@ -36,19 +36,17 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import java.util.HashSet; +import java.util.Random; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; - -public class CircularSpawnPointsGenerator implements SpawnPointsGenerator -{ +public class CircularSpawnPointsGenerator implements SpawnPointsGenerator { private final BorderModule borderModule = QSG.module(BorderModule.class); /** @@ -63,14 +61,13 @@ public class CircularSpawnPointsGenerator implements SpawnPointsGenerator * @param xCenter The x coordinate of the point in the center of the region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the region where the points will be generated. * @param avoidWater True if the generation have to avoid the water. - * * @return The spawn points generated. - * * @throws CannotGenerateSpawnPointsException In case of fail. */ @Override - public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, final boolean avoidWater) throws CannotGenerateSpawnPointsException - { + public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, + final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, + final boolean avoidWater) throws CannotGenerateSpawnPointsException { // We starts the generation on a smaller grid, to avoid false outside tests if the point is on the edge final int usedRegionDiameter = regionDiameter - 1; @@ -81,8 +78,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // The generation loop. Each step generates a circle. generationLoop: - while (currentCircleDiameter >= minimalDistanceBetweenTwoPoints) - { + while (currentCircleDiameter >= minimalDistanceBetweenTwoPoints) { // First step. We want to know if all the points left can be in one circle. // We calculates the maximal number of points in a circle, taking into account the // minimal distance between two points. @@ -92,21 +88,20 @@ public Set<Location> generate(final World world, final int spawnCount, final int // a = 2 Arcsin((d/2)/R) // (Just draw the situation, you'll see.) - final double denseCircleAngle = 2 * Math.asin(((double) minimalDistanceBetweenTwoPoints / 2) / ((double) currentCircleDiameter / 2)); + final double denseCircleAngle = 2 * + Math.asin(((double) minimalDistanceBetweenTwoPoints / 2) / ((double) currentCircleDiameter / 2)); final int pointsPerDenseCircles = (int) Math.floor(2 * Math.PI / denseCircleAngle); final double angleBetweenTwoPoints; // Not all the points can be in this circle. We generate the densest circle. - if (pointsPerDenseCircles < spawnCount - countGeneratedPoints) - { + if (pointsPerDenseCircles < spawnCount - countGeneratedPoints) { angleBetweenTwoPoints = 2 * Math.PI / ((double) pointsPerDenseCircles); } // All the remaining points can be in this circle. We generates the less dense circle with // these points. - else - { + else { angleBetweenTwoPoints = 2 * Math.PI / ((double) (spawnCount - countGeneratedPoints)); } @@ -114,8 +109,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int final double startAngle = (new Random()).nextDouble() * 2 * Math.PI; double currentAngle = startAngle; - while (currentAngle <= 2 * Math.PI - angleBetweenTwoPoints + startAngle) - { + while (currentAngle <= 2 * Math.PI - angleBetweenTwoPoints + startAngle) { // The coordinates of a point in the circle. // Cf. your trigonometry! ;) Location point = new Location( @@ -128,8 +122,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int currentAngle += angleBetweenTwoPoints; // Just in case - if (!borderModule.isInsideBorder(point, regionDiameter)) - { + if (!borderModule.isInsideBorder(point, regionDiameter)) { continue; } @@ -137,18 +130,16 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + if ((world.getEnvironment() == World.Environment.NORMAL || + world.getEnvironment() == World.Environment.THE_END) && !QSGUtils .isSafeSpot(surfaceAirBlock.getLocation()) - || QSGUtils.searchSafeSpot(point) == null) - { + || QSGUtils.searchSafeSpot(point) == null) { continue; // not safe: nope } // Not above the water? - if (avoidWater) - { - if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) - { + if (avoidWater) { + if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) { continue; } } @@ -156,8 +147,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int generatedPoints.add(point); countGeneratedPoints++; - if (countGeneratedPoints >= spawnCount) - { + if (countGeneratedPoints >= spawnCount) { break generationLoop; } } @@ -169,13 +159,11 @@ public Set<Location> generate(final World world, final int spawnCount, final int // Generation done or failed (not enough space)? - if (generatedPoints.size() < spawnCount) - { + if (generatedPoints.size() < spawnCount) { // Failed! - throw new CannotGenerateSpawnPointsException("Cannot generate the spawn point in circles: not enough space"); - } - else - { + throw new CannotGenerateSpawnPointsException( + "Cannot generate the spawn point in circles: not enough space"); + } else { return generatedPoints; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java index a5c2d27..475eef6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/GridSpawnPointsGenerator.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -36,18 +37,16 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import java.util.HashSet; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import java.util.HashSet; -import java.util.Set; - -public class GridSpawnPointsGenerator implements SpawnPointsGenerator -{ +public class GridSpawnPointsGenerator implements SpawnPointsGenerator { private final BorderModule borderModule = QSG.module(BorderModule.class); /** @@ -66,13 +65,13 @@ public class GridSpawnPointsGenerator implements SpawnPointsGenerator * @param zCenter The z coordinate of the point in the center of the * region where the points will be generated. * @param avoidWater True if the generation have to avoid the water. - * * @return The spawn points generated. * @throws CannotGenerateSpawnPointsException In case of fail. */ @Override - public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, final boolean avoidWater) throws CannotGenerateSpawnPointsException - { + public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, + final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, + final boolean avoidWater) throws CannotGenerateSpawnPointsException { // We starts the generation on a smaller grid, to avoid false outside tests if the point is on the edge final int usedRegionDiameter = regionDiameter - 1; @@ -82,8 +81,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int // The points are on a grid int neededColumnsCount = (int) Math.ceil(Math.sqrt(spawnCount)); - if (borderModule.getMapShape() == MapShape.CIRCULAR) - { + if (borderModule.getMapShape() == MapShape.CIRCULAR) { // If the border is circular, the distance between two points needs to be decreased. // The space available is divided by PI/4, so the column count is multiplied by // this number. @@ -91,8 +89,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int } // IS impossible. - if (neededColumnsCount > maxColumnsCount) - { + if (neededColumnsCount > maxColumnsCount) { throw new CannotGenerateSpawnPointsException("Cannot generate spawn points on a grid: not enough space."); } @@ -105,8 +102,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int final int distanceBetweenTwoPoints = (int) ((double) usedRegionDiameter / ((double) (neededColumnsCount))); // Check related to the case the column count was increased. - if (distanceBetweenTwoPoints < minimalDistanceBetweenTwoPoints) - { + if (distanceBetweenTwoPoints < minimalDistanceBetweenTwoPoints) { throw new CannotGenerateSpawnPointsException("Cannot generate spawn points on a grid: not enough space."); } @@ -130,35 +126,30 @@ public Set<Location> generate(final World world, final int spawnCount, final int // We generates the points until there isn't any point left to place. The loop will be broken. // On each step of this loop, a square is generated. generationLoop: - while (true) - { + while (true) { currentPoint = currentSquareStartPoint.clone(); // First point - if (borderModule.isInsideBorder(currentPoint, regionDiameter) && QSGUtils.searchSafeSpot(currentPoint) != null) - { + if (borderModule.isInsideBorder(currentPoint, regionDiameter) + && QSGUtils.searchSafeSpot(currentPoint) != null) { generatedPoints.add(currentPoint.clone()); countGeneratedPoints++; - if (countGeneratedPoints >= spawnCount) - { + if (countGeneratedPoints >= spawnCount) { break; } } // A step for each side, j is the side (see addOnSide). - for (int j = 0; j < 4; j++) - { + for (int j = 0; j < 4; j++) { int plottedSize = 0; - while (plottedSize < currentSquareSize) - { + while (plottedSize < currentSquareSize) { currentPoint.add(addOnSide[j]); plottedSize += distanceBetweenTwoPoints; // Inside the border? - if (!borderModule.isInsideBorder(currentPoint, regionDiameter)) - { + if (!borderModule.isInsideBorder(currentPoint, regionDiameter)) { continue; } @@ -166,18 +157,16 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + if ((world.getEnvironment() == World.Environment.NORMAL + || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils .isSafeSpot(surfaceAirBlock.getLocation()) - || QSGUtils.searchSafeSpot(currentPoint) == null) - { + || (QSGUtils.searchSafeSpot(currentPoint) == null)) { continue; // not safe: nope } // Not above the water? - if (avoidWater) - { - if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) - { + if (avoidWater) { + if (surfaceBlock.getType() == Material.WATER || surfaceBlock.getType() == Material.WATER) { continue; } } @@ -185,8 +174,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int generatedPoints.add(currentPoint.clone()); countGeneratedPoints++; - if (countGeneratedPoints >= spawnCount) - { + if (countGeneratedPoints >= spawnCount) { break generationLoop; } } @@ -196,8 +184,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int currentSquareSize -= 2 * distanceBetweenTwoPoints; currentSquareStartPoint.add(new Location(world, -distanceBetweenTwoPoints, 0, distanceBetweenTwoPoints)); - if (currentSquareSize < distanceBetweenTwoPoints) - { + if (currentSquareSize < distanceBetweenTwoPoints) { // This may happens if we generates the points for a circular world break; } @@ -205,13 +192,10 @@ public Set<Location> generate(final World world, final int spawnCount, final int // If the generation was broken (circular world, not enough positions), // the generation was incomplete. - if (countGeneratedPoints >= spawnCount) - { + if (countGeneratedPoints >= spawnCount) { // Generation OK return generatedPoints; - } - else - { + } else { throw new CannotGenerateSpawnPointsException("Cannot generate the spawn points: not enough space."); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java index a8d712a..8a00a08 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/RandomSpawnPointsGenerator.java @@ -37,22 +37,20 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; +import java.util.HashSet; +import java.util.Random; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; - /** * Generates the spawn points randomly. */ -public class RandomSpawnPointsGenerator implements SpawnPointsGenerator -{ +public class RandomSpawnPointsGenerator implements SpawnPointsGenerator { private final Random random = new Random(); private final BorderModule borderModule = QSG.module(BorderModule.class); @@ -68,14 +66,13 @@ public class RandomSpawnPointsGenerator implements SpawnPointsGenerator * @param xCenter The x coordinate of the point in the center of the region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the region where the points will be generated. * @param avoidWater True if the generation have to avoid the water. - * * @return The spawn points generated. - * * @throws CannotGenerateSpawnPointsException In case of fail */ @Override - public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, final boolean avoidWater) throws CannotGenerateSpawnPointsException - { + public Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, + final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, + final boolean avoidWater) throws CannotGenerateSpawnPointsException { final double minimalDistanceBetweenTwoPointsSquared = Math.pow(minimalDistanceBetweenTwoPoints, 2); @@ -85,15 +82,13 @@ public Set<Location> generate(final World world, final int spawnCount, final int // around each spawn point (a circle with, as radius, the minimal distance between two spawn // points), the generation will fail. - final double surfacePrivatePartsAroundSpawnPoints = (int) (spawnCount * (Math.PI * minimalDistanceBetweenTwoPointsSquared)); + final double surfacePrivatePartsAroundSpawnPoints = + (int) (spawnCount * (Math.PI * minimalDistanceBetweenTwoPointsSquared)); final double surfaceRegion; - if (borderModule.getMapShape() == MapShape.CIRCULAR) - { + if (borderModule.getMapShape() == MapShape.CIRCULAR) { surfaceRegion = (Math.PI * Math.pow(regionDiameter, 2)) / 4; - } - else - { + } else { surfaceRegion = Math.pow(regionDiameter, 2); } @@ -103,9 +98,9 @@ public Set<Location> generate(final World world, final int spawnCount, final int // approximately 0.9069 (with an hexagonal arrangement of the circles). // Even with a packaging density very close to this limit, the generation time is correct. // So we uses this as a limit. - if (packingDensity >= 0.9069) - { - throw new CannotGenerateSpawnPointsException("Unable to generate spawn points randomly: packing density of " + packingDensity + " too high"); + if (packingDensity >= 0.9069) { + throw new CannotGenerateSpawnPointsException( + "Unable to generate spawn points randomly: packing density of " + packingDensity + " too high"); } /* *** Generation *** */ @@ -125,8 +120,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int int pointsAboveWater = 0; generationLoop: - while (generatedSpawnPoints != spawnCount) - { + while (generatedSpawnPoints != spawnCount) { // "Too many fails" test if (currentErrorCount >= 16) // restart { @@ -136,8 +130,7 @@ public Set<Location> generate(final World world, final int spawnCount, final int } // "Too many points above the water" test - if (pointsAboveWater >= 2 * spawnCount) - { + if (pointsAboveWater >= 2 * spawnCount) { throw new CannotGenerateSpawnPointsException("Too many spawn points above the water."); } @@ -147,13 +140,14 @@ public Set<Location> generate(final World world, final int spawnCount, final int // excluded when his presence inside the region will be checked. Location randomPoint = new Location(world, - random((int) (xCenter - Math.floor(regionDiameter / 2)), (int) (xCenter + (int) Math.floor(regionDiameter / 2))), + random((int) (xCenter - Math.floor(regionDiameter / 2)), + (int) (xCenter + (int) Math.floor(regionDiameter / 2))), 0, - random((int) (zCenter - Math.floor(regionDiameter / 2)), (int) (zCenter + (int) Math.floor(regionDiameter / 2)))); + random((int) (zCenter - Math.floor(regionDiameter / 2)), + (int) (zCenter + (int) Math.floor(regionDiameter / 2)))); // Inside the region? - if (!borderModule.isInsideBorder(randomPoint, regionDiameter)) - { + if (!borderModule.isInsideBorder(randomPoint, regionDiameter)) { continue; // outside: nope } @@ -161,28 +155,24 @@ public Set<Location> generate(final World world, final int spawnCount, final int final Block surfaceBlock = surfaceAirBlock.getRelative(BlockFace.DOWN); // Safe spot available? - if ((world.getEnvironment() == World.Environment.NORMAL || world.getEnvironment() == World.Environment.THE_END) && !QSGUtils + if ((world.getEnvironment() == World.Environment.NORMAL || + world.getEnvironment() == World.Environment.THE_END) && !QSGUtils .isSafeSpot(surfaceAirBlock.getLocation()) - || QSGUtils.searchSafeSpot(randomPoint) == null) - { + || QSGUtils.searchSafeSpot(randomPoint) == null) { continue; // not safe: nope } // Not above the water? - if (avoidWater) - { - if (surfaceBlock.getType() == Material.WATER) - { + if (avoidWater) { + if (surfaceBlock.getType() == Material.WATER) { pointsAboveWater++; continue; } } // Is that point at a correct distance of the other ones? - for (Location spawn : randomSpawnPoints) - { - if (spawn.distanceSquared(randomPoint) < minimalDistanceBetweenTwoPointsSquared) - { + for (Location spawn : randomSpawnPoints) { + if (spawn.distanceSquared(randomPoint) < minimalDistanceBetweenTwoPointsSquared) { currentErrorCount++; continue generationLoop; // too close: nope } @@ -207,10 +197,8 @@ public Set<Location> generate(final World world, final int spawnCount, final int * @param max The maximum value. May be negative. Inclusive. * @return A random number between these two points. */ - public Integer random(int min, int max) - { - if (min == max) - { + public Integer random(int min, int max) { + if (min == max) { return min; } @@ -221,15 +209,11 @@ public Integer random(int min, int max) min = min - max; } - if (min >= 0 && max >= 0) - { + if (min >= 0 && max >= 0) { return random.nextInt(max - min + 1) + min; - } - else if (min <= 0 && max <= 0) - { + } else if (min <= 0 && max <= 0) { return -1 * (random.nextInt(Math.abs(min - max)) + Math.abs(max)); - } - else // min <= 0 && max >= 0 + } else // min <= 0 && max >= 0 { return random.nextInt(Math.abs(min) + Math.abs(max)) - Math.abs(min); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java index 1a6d204..94d2ce4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spawns/generators/SpawnPointsGenerator.java @@ -29,24 +29,23 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.generators; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spawns.exceptions.CannotGenerateSpawnPointsException; +import java.util.Set; import org.bukkit.Location; import org.bukkit.World; -import java.util.Set; - /** * Represents a spawn points generator. * * <p> - * A zero-arguments constructor is needed. + * A zero-arguments constructor is needed. * </p> */ -public interface SpawnPointsGenerator -{ +public interface SpawnPointsGenerator { /** * Generates the spawn points. * @@ -59,10 +58,10 @@ public interface SpawnPointsGenerator * @param xCenter The x coordinate of the point in the center of the region where the points will be generated. * @param zCenter The z coordinate of the point in the center of the region where the points will be generated. * @param avoidWater True if the generation have to avoid the water. - * * @return The spawn points generated. - * * @throws CannotGenerateSpawnPointsException In case of fail. */ - Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, final boolean avoidWater) throws CannotGenerateSpawnPointsException; + Set<Location> generate(final World world, final int spawnCount, final int regionDiameter, + final int minimalDistanceBetweenTwoPoints, final double xCenter, final double zCenter, + final boolean avoidWater) throws CannotGenerateSpawnPointsException; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java index ccb75ec..e5c019b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/Config.java @@ -31,23 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { +public class Config extends ConfigurationInstance { + static public final ConfigurationItem<Boolean> SPECTATORS_CAN_JOIN = item("spectators-can-join", true); + static public final ConfigurationItem<Boolean> UNKNOWN_SPECTATORS_CAN_JOIN = + item("unknown-spectators-can-join", true); + static public final ConfigurationItem<Boolean> NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN = + item("notify-on-unknown-spectators-trying-to-join", true); + public Config(File file) { super(file); } - - static public final ConfigurationItem<Boolean> SPECTATORS_CAN_JOIN = item("spectators-can-join", true); - static public final ConfigurationItem<Boolean> UNKNOWN_SPECTATORS_CAN_JOIN = item("unknown-spectators-can-join", true); - static public final ConfigurationItem<Boolean> NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN = item("notify-on-unknown-spectators-trying-to-join", true); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java index 6f56544..fcd6efb 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorPlusDependency.java @@ -38,32 +38,27 @@ import fr.zcraft.quartzlib.tools.PluginLogger; -public class SpectatorPlusDependency extends ExternalPluginComponent<SpectatorPlus> -{ +public class SpectatorPlusDependency extends ExternalPluginComponent<SpectatorPlus> { private SpectateAPI spAPI = null; - public SpectatorPlusDependency() - { + public SpectatorPlusDependency() { super("SpectatorPlus"); } @Override - public void onLoad() - { - try - { + public void onLoad() { + try { Class.forName("com.pgcraft.spectatorplus.SpectateAPI"); - if (get().getDescription().getVersion().equals("1.9.1")) - { + if (get().getDescription().getVersion().equals("1.9.1")) { // The API of SpectatorPlus 1.9.1 was not working. throw new ClassNotFoundException(); } } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { PluginLogger.warning("SpectatorPlus is available, but the version you are using is too old."); - PluginLogger.warning("This plugin is tested and works with SpectatorPlus 1.9.2 or later. The SpectateAPI is needed."); + PluginLogger.warning( + "This plugin is tested and works with SpectatorPlus 1.9.2 or later. The SpectateAPI is needed."); setEnabled(false); return; @@ -71,8 +66,7 @@ public void onLoad() // All is OK, let's integrate. - try - { + try { spAPI = get().getAPI(); PluginLogger.info("Successfully hooked into SpectatorPlus."); @@ -80,20 +74,17 @@ public void onLoad() // Generic catch block to catch any kind of exception (logged, anyway), including e.g. // NoSuchMethodError, if the API change, so the plugin is not broken. - catch (Throwable e) - { + catch (Throwable e) { PluginLogger.error("Cannot hook into SpectatorPlus, is this version compatible?", e); setEnabled(false); } } - public SpectatorPlus getSP() - { + public SpectatorPlus getSP() { return get(); } - public SpectateAPI getSPAPI() - { + public SpectateAPI getSPAPI() { return this.spAPI; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java index abb0702..616ad8d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/SpectatorsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -50,6 +51,11 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.rawtext.RawText; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -58,10 +64,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; -import java.util.*; - -@ModuleInfo ( +@ModuleInfo( name = "Spectators Manager", description = "Handles non-playing players.", when = ModuleLoadTime.POST_WORLD, @@ -70,58 +74,49 @@ settings = Config.class, can_be_unloaded = false ) -public class SpectatorsModule extends QSGModule -{ - private SpectatorsManager manager; - private SpectatorPlusDependency spectatorPlusDependency; - +public class SpectatorsModule extends QSGModule { /** * Lists players allowed to spectate. Also used for initial spectators: players who will * never play, only spectate. */ private final Set<UUID> spectators = new HashSet<>(); - /** * When external spectators are disallowed, a message is sent once to inform administrators * how to accept them if they wish to. */ private final Set<UUID> broadcastedUnknownSpectators = new HashSet<>(); + private SpectatorsManager manager; + private SpectatorPlusDependency spectatorPlusDependency; @Override - protected void onEnable() - { + protected void onEnable() { manager = SpectatorsManager.getInstance(); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(SpectatorsCommand.class); } /** * @return The manager instance to use to handle spectators. */ - public SpectatorsManager getManager() - { + public SpectatorsManager getManager() { return manager; } /** * @return The allowed spectators. */ - public Set<UUID> getSpectators() - { + public Set<UUID> getSpectators() { return spectators; } - public boolean isSpectator(final UUID playerID) - { + public boolean isSpectator(final UUID playerID) { return spectators.contains(playerID); } - public boolean isSpectator(final OfflinePlayer player) - { + public boolean isSpectator(final OfflinePlayer player) { return spectators.contains(player.getUniqueId()); } @@ -130,12 +125,12 @@ public boolean isSpectator(final OfflinePlayer player) * * @param playerID The spectator's ID. */ - public void addSpectator(final UUID playerID) - { + public void addSpectator(final UUID playerID) { spectators.add(playerID); - if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) + if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) { RunTask.nextTick(() -> manager.setSpectating(playerID, true)); + } } /** @@ -143,8 +138,7 @@ public void addSpectator(final UUID playerID) * * @param player The spectator. */ - public void addSpectator(final OfflinePlayer player) - { + public void addSpectator(final OfflinePlayer player) { addSpectator(player.getUniqueId()); } @@ -153,12 +147,12 @@ public void addSpectator(final OfflinePlayer player) * * @param playerID The spectator's ID. */ - public void removeSpectator(final UUID playerID) - { + public void removeSpectator(final UUID playerID) { spectators.remove(playerID); - if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) + if (QSG.module(GameModule.class).getPhase() != GamePhase.WAIT) { RunTask.nextTick(() -> manager.setSpectating(playerID, false)); + } } /** @@ -166,8 +160,7 @@ public void removeSpectator(final UUID playerID) * * @param player The spectator. */ - public void removeSpectator(final OfflinePlayer player) - { + public void removeSpectator(final OfflinePlayer player) { removeSpectator(player.getUniqueId()); } @@ -177,69 +170,65 @@ public void removeSpectator(final OfflinePlayer player) * @param strict If true, all spectating players not in our list are removed from the spectator mode. * Else, only players in our list are placed into spectator mode. */ - private void ensureSpectatorMode(final boolean strict) - { - if (strict) - { + private void ensureSpectatorMode(final boolean strict) { + if (strict) { Bukkit.getOnlinePlayers().forEach(player -> manager.setSpectating(player, isSpectator(player))); - } - else - { + } else { spectators.forEach(spectator -> manager.setSpectating(spectator, true)); } } @EventHandler - public void onGameStart(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; + public void onGameStart(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME) { + return; + } ensureSpectatorMode(true); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { addSpectator(ev.getPlayer()); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerResurrects(final PlayerResurrectedEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerResurrects(final PlayerResurrectedEvent ev) { removeSpectator(ev.getPlayer()); } @EventHandler - public void onPlayerLogin(final PlayerLoginEvent ev) - { + public void onPlayerLogin(final PlayerLoginEvent ev) { final GameModule game = QSG.module(GameModule.class); - if (game.currentPhaseBefore(GamePhase.IN_GAME)) return; + if (game.currentPhaseBefore(GamePhase.IN_GAME)) { + return; + } // TODO Permissions - if (ev.getPlayer().isOp()) - { + if (ev.getPlayer().isOp()) { ev.allow(); return; } - if (!Config.SPECTATORS_CAN_JOIN.get() && !game.isAlive(ev.getPlayer())) - { + if (!Config.SPECTATORS_CAN_JOIN.get() && !game.isAlive(ev.getPlayer())) { ev.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, I.t("Spectators are not allowed for this game.")); return; - } - - else if (!Config.UNKNOWN_SPECTATORS_CAN_JOIN.get() && !(game.isAlive(ev.getPlayer()) || isSpectator(ev.getPlayer()))) - { - ev.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, I.t("External spectators are not allowed for this game.")); + } else if (!Config.UNKNOWN_SPECTATORS_CAN_JOIN.get() && + !(game.isAlive(ev.getPlayer()) || isSpectator(ev.getPlayer()))) { + ev.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, + I.t("External spectators are not allowed for this game.")); - if (Config.NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN.get() && broadcastedUnknownSpectators.add(ev.getPlayer().getUniqueId())) - { - final String command = Commands.getCommandInfo(SpectatorsCommand.class).build("add", ev.getPlayer().getName()); + if (Config.NOTIFY_ON_UNKNOWN_SPECTATORS_TRYING_TO_JOIN.get() && + broadcastedUnknownSpectators.add(ev.getPlayer().getUniqueId())) { + final String command = + Commands.getCommandInfo(SpectatorsCommand.class).build("add", ev.getPlayer().getName()); log().broadcastAdministrative( - new RawText(I.t("{gray}The unknown player {0} just tried to join. To allow him to spectate, execute {cc}{1} or click here.", ev.getPlayer().getName(), command)) + new RawText( + I.t("{gray}The unknown player {0} just tried to join. To allow him to spectate, execute {cc}{1} or click here.", + ev.getPlayer().getName(), command)) .hover(I.t("Click here to execute\n{0}", command)) .command(command) ); @@ -249,17 +238,14 @@ else if (!Config.UNKNOWN_SPECTATORS_CAN_JOIN.get() && !(game.isAlive(ev.getPlaye } // Here the spectator is allowed. If it's new, we add it to the list. - if (!game.isAlive(ev.getPlayer()) && !isSpectator(ev.getPlayer())) - { + if (!game.isAlive(ev.getPlayer()) && !isSpectator(ev.getPlayer())) { addSpectator(ev.getPlayer()); } } @EventHandler - public void onPlayerJoin(final PlayerJoinEvent ev) - { - if (QSG.module(GameModule.class).getPhase().ordinal() >= GamePhase.IN_GAME.ordinal()) - { + public void onPlayerJoin(final PlayerJoinEvent ev) { + if (QSG.module(GameModule.class).getPhase().ordinal() >= GamePhase.IN_GAME.ordinal()) { manager.setSpectating(ev.getPlayer(), isSpectator(ev.getPlayer())); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java index 7c2f91d..19d17b7 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/commands/SpectatorsCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; @@ -40,68 +41,57 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; - import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; -@CommandInfo (name = "spectators", usageParameters = "[add <player>] [remove <player>]", aliases = {"spec", "sp"}) -public class SpectatorsCommand extends Command -{ +@CommandInfo(name = "spectators", usageParameters = "[add <player>] [remove <player>]", aliases = {"spec", "sp"}) +public class SpectatorsCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { // /uh spec - if (args.length == 0) - { + if (args.length == 0) { final Set<String> spectators = QSG.module(SpectatorsModule.class) .getSpectators().stream() .map(uuid -> Bukkit.getOfflinePlayer(uuid).getName()) .collect(Collectors.toSet()); - if (spectators.size() == 0) - { + if (spectators.size() == 0) { error(I.t("{ce}There isn't any spectator to list.")); - } - else - { + } else { info(""); info(I.tn("{ci}{0} registered spectator.", "{ci}{0} registered spectators.", spectators.size())); /// A list item in the startup spectators list - spectators.stream().map(spectator -> I.tc("startup_specs", "{lightpurple} - {0}", spectator)).forEach(this::info); + spectators.stream().map(spectator -> I.tc("startup_specs", "{lightpurple} - {0}", spectator)) + .forEach(this::info); } - } - - else - { - switch (args[0].toLowerCase()) - { + } else { + switch (args[0].toLowerCase()) { case "add": case "a": // /uh spec add - if (args.length == 1) - { + if (args.length == 1) { throwInvalidArgument(I.t("Please add the player you want to register as spectator.")); } // /uh spec add <player> - else - { + else { final CommandSender finalSender = sender; OfflinePlayersLoader.loadPlayer(args[1], player -> { - if (player == null) - { + if (player == null) { finalSender.sendMessage(I.t("{ce}Unable to retrieve the player {0}.")); - if (!Bukkit.getOnlineMode()) - finalSender.sendMessage(I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); + if (!Bukkit.getOnlineMode()) { + finalSender.sendMessage( + I.t("{ce}In offline mode, you cannot add players if they never came to this server.")); + } return; } @@ -116,21 +106,16 @@ protected void run() throws CommandException case "remove": case "r": // /uh spec remove - if (args.length == 1) - { + if (args.length == 1) { throwInvalidArgument(I.t("Please add the player you want to unregister from spectators.")); } // /uh spec remove <player> - else - { + else { final OfflinePlayer oldSpectator = OfflinePlayersLoader.getOfflinePlayer(args[1]); - if (oldSpectator == null) - { + if (oldSpectator == null) { error(I.t("{ce}The player {0} was not found.", args[1])); - } - else - { + } else { QSG.module(SpectatorsModule.class).removeSpectator(oldSpectator); success(I.t("{cs}The player {0} is now a player.", args[1])); } @@ -142,13 +127,11 @@ protected void run() throws CommandException } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingSubset(args[0], "add", "remove"); - else if (args.length == 2) - { - switch (args[0].toLowerCase()) - { + protected List<String> complete() { + if (args.length == 1) { + return getMatchingSubset(args[0], "add", "remove"); + } else if (args.length == 2) { + switch (args[0].toLowerCase()) { case "add": case "a": return getMatchingSubset( @@ -172,7 +155,8 @@ else if (args.length == 2) default: return null; } + } else { + return null; } - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java index 3bd5995..98f3880 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SPlusSpectatorsManager.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; import com.pgcraft.spectatorplus.SpectateAPI; @@ -38,25 +39,23 @@ /** * Spectators managed through the SpectatorsPlus Bukkit plugin by PGMann and AmauryPi. */ -public class SPlusSpectatorsManager extends SpectatorsManager -{ +public class SPlusSpectatorsManager extends SpectatorsManager { private final SpectateAPI api; - public SPlusSpectatorsManager(final SpectateAPI api) - { + public SPlusSpectatorsManager(final SpectateAPI api) { this.api = api; } @Override - public void setSpectating(final Player player, final boolean spectating) - { - if (player != null) api.setSpectating(player, spectating); + public void setSpectating(final Player player, final boolean spectating) { + if (player != null) { + api.setSpectating(player, spectating); + } } @Override - public boolean isSpectating(final Player player) - { + public boolean isSpectating(final Player player) { return player != null && api.isSpectator(player); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java index d809f33..61d8e1a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/SpectatorsManager.java @@ -29,28 +29,38 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorPlusDependency; import fr.zcraft.quartzlib.core.QuartzLib; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.UUID; - /** * Represents a spectator manager, able to put players in or remove players from spectator mode. */ -public abstract class SpectatorsManager -{ +public abstract class SpectatorsManager { private final static SpectatorPlusDependency spectatorPlusDependency; - static - { + static { spectatorPlusDependency = QuartzLib.loadComponent(SpectatorPlusDependency.class); } + /** + * @return an instance of a {@link SpectatorsManager}: {@link SPlusSpectatorsManager} if the + * SpectatorPlus plugin is available; {@link VanillaSpectatorsManager} else. + */ + public static SpectatorsManager getInstance() { + if (spectatorPlusDependency.isEnabled()) { + return new SPlusSpectatorsManager(spectatorPlusDependency.getSPAPI()); + } else { + return new VanillaSpectatorsManager(); + } + } + /** * Changes the spectating mode of a player. * @@ -63,7 +73,6 @@ public abstract class SpectatorsManager * Checks if the given player is currently spectating. * * @param player The player. - * * @return {@code true} if spectating. */ public abstract boolean isSpectating(final Player player); @@ -74,8 +83,7 @@ public abstract class SpectatorsManager * @param playerID The player's UUID. * @param spectating {@code true} to enable the spectator mode; {@code false} to disable it. */ - public void setSpectating(final UUID playerID, final boolean spectating) - { + public void setSpectating(final UUID playerID, final boolean spectating) { setSpectating(Bukkit.getPlayer(playerID), spectating); } @@ -83,24 +91,9 @@ public void setSpectating(final UUID playerID, final boolean spectating) * Checks if the given player is currently spectating. * * @param playerID The player's UUID. - * * @return {@code true} if spectating. */ - public boolean isSpectating(final UUID playerID) - { + public boolean isSpectating(final UUID playerID) { return isSpectating(Bukkit.getPlayer(playerID)); } - - - /** - * @return an instance of a {@link SpectatorsManager}: {@link SPlusSpectatorsManager} if the - * SpectatorPlus plugin is available; {@link VanillaSpectatorsManager} else. - */ - public static SpectatorsManager getInstance() - { - if (spectatorPlusDependency.isEnabled()) - return new SPlusSpectatorsManager(spectatorPlusDependency.getSPAPI()); - else - return new VanillaSpectatorsManager(); - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java index ce3f560..a9e7c4b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/spectators/managers/VanillaSpectatorsManager.java @@ -29,53 +29,47 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ -package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; +package eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.managers; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.entity.Player; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.entity.Player; /** * Vanilla spectator mode */ -public class VanillaSpectatorsManager extends SpectatorsManager -{ +public class VanillaSpectatorsManager extends SpectatorsManager { /** * Stores the previous gamemodes of the players. */ - private Map<UUID, GameMode> oldGameModes = new HashMap<>(); + private final Map<UUID, GameMode> oldGameModes = new HashMap<>(); @Override - public void setSpectating(final Player player, final boolean spectating) - { - if (player == null) + public void setSpectating(final Player player, final boolean spectating) { + if (player == null) { return; + } - if (spectating) - { - if (player.getGameMode() != GameMode.SPECTATOR) - { + if (spectating) { + if (player.getGameMode() != GameMode.SPECTATOR) { oldGameModes.put(player.getUniqueId(), player.getGameMode()); player.setGameMode(GameMode.SPECTATOR); } - } - else - { + } else { player.setGameMode(oldGameModes.getOrDefault(player.getUniqueId(), Bukkit.getDefaultGameMode())); oldGameModes.remove(player.getUniqueId()); } } @Override - public boolean isSpectating(Player player) - { + public boolean isSpectating(Player player) { return player != null && player.getGameMode() == GameMode.SPECTATOR; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java index 0f89c3f..0735828 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/teams/Config.java @@ -38,7 +38,7 @@ import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; -import fr.zcraft.quartzteams.guis.TeamsGUIItemType; +import fr.zcraft.quartzlib.tools.items.ColorableMaterial; import java.io.File; @@ -82,7 +82,7 @@ static public class ChestGuiSection extends ConfigurationSection { public final DisplaySection DISPLAY = section("display", DisplaySection.class); static public class DisplaySection extends ConfigurationSection { - public final ConfigurationItem<TeamsGUIItemType> TEAM_ITEM = item("team-item", TeamsGUIItemType.BANNER); + public final ConfigurationItem<ColorableMaterial> TEAM_ITEM = item("team-item", ColorableMaterial.BANNER); public final ConfigurationItem<Boolean> GLOW_ON_SELECTED_TEAM = item("glow-on-selected-team", true); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java index 144f93d..173fbfc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimeDelta.java @@ -29,47 +29,43 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers; import fr.zcraft.quartzlib.components.configuration.ConfigurationParseException; import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandler; import fr.zcraft.quartzlib.components.configuration.ConfigurationValueHandlers; - import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Objects; -public class TimeDelta -{ +public class TimeDelta { private static final NumberFormat formatter = new DecimalFormat("00"); - private final long seconds; - - static - { + static { ConfigurationValueHandlers.registerHandlers(TimeDelta.class); } + private final long seconds; + /** * Constructs a time delta. * * @param seconds The number of seconds in this delta. */ - public TimeDelta(long seconds) - { + public TimeDelta(long seconds) { this.seconds = seconds; } /** * Constructs a time delta. * - * @param hours The number of hours. + * @param hours The number of hours. * @param minutes The number of minutes. * @param seconds The number of seconds. */ - public TimeDelta(long hours, long minutes, long seconds) - { + public TimeDelta(long hours, long minutes, long seconds) { this(seconds + minutes * 60 + hours * 3600); } @@ -85,39 +81,45 @@ public TimeDelta(long hours, long minutes, long seconds) * </ul> * * @param rawTime The raw time text. - * * @throws IllegalArgumentException if the text is not formatted as above. - * @throws NumberFormatException if the text between the colons cannot be - * converted in integers. + * @throws NumberFormatException if the text between the colons cannot be + * converted in integers. */ - public TimeDelta(final String rawTime) throws IllegalArgumentException, NumberFormatException - { + public TimeDelta(final String rawTime) throws IllegalArgumentException, NumberFormatException { final String[] split = rawTime.split(":"); - if (rawTime.isEmpty() || split.length > 3) - { - throw new IllegalArgumentException("Badly formatted string in TimeDelta(String); formats allowed are mm, mm:ss or hh:mm:ss."); + if (rawTime.isEmpty() || split.length > 3) { + throw new IllegalArgumentException( + "Badly formatted string in TimeDelta(String); formats allowed are mm, mm:ss or hh:mm:ss."); } if (split.length == 1) // "mm" { this.seconds = Integer.valueOf(split[0]) * 60; - } - else if (split.length == 2) // "mm:ss" + } else if (split.length == 2) // "mm:ss" { this.seconds = Integer.valueOf(split[0]) * 60 + Integer.valueOf(split[1]); - } - else // "hh:mm:ss" + } else // "hh:mm:ss" { - this.seconds = Integer.valueOf(split[0]) * 3600 + Integer.valueOf(split[1]) * 60 + Integer.valueOf(split[2]); + this.seconds = + Integer.valueOf(split[0]) * 3600 + Integer.valueOf(split[1]) * 60 + Integer.valueOf(split[2]); + } + } + + @ConfigurationValueHandler + public static TimeDelta handleTimeDelta(String rawDelta) throws ConfigurationParseException { + try { + return new TimeDelta(rawDelta); + } + catch (IllegalArgumentException e) { + throw new ConfigurationParseException("Invalid time delta format", rawDelta); } } /** * @return The total number of seconds in this time delta. */ - public long getSeconds() - { + public long getSeconds() { return seconds; } @@ -126,8 +128,7 @@ public long getSeconds() * @return {@code true} if the duration in this {@link TimeDelta} is less than * (or equal to) the duration in the other one. */ - public boolean lessThan(final TimeDelta other) - { + public boolean lessThan(final TimeDelta other) { return this.getSeconds() <= other.getSeconds(); } @@ -136,8 +137,7 @@ public boolean lessThan(final TimeDelta other) * @return {@code true} if the duration in this {@link TimeDelta} is greater * than (or equal to) the duration in the other one. */ - public boolean greaterThan(final TimeDelta other) - { + public boolean greaterThan(final TimeDelta other) { return this.getSeconds() >= other.getSeconds(); } @@ -146,8 +146,7 @@ public boolean greaterThan(final TimeDelta other) * @return A new {@link TimeDelta} instance representing the sum of the two * {@link TimeDelta deltas}. */ - public TimeDelta add(final TimeDelta other) - { + public TimeDelta add(final TimeDelta other) { return new TimeDelta(this.getSeconds() + other.getSeconds()); } @@ -156,8 +155,7 @@ public TimeDelta add(final TimeDelta other) * @return A new {@link TimeDelta} instance representing the subtraction of * the two {@link TimeDelta deltas}. */ - public TimeDelta subtract(final TimeDelta other) - { + public TimeDelta subtract(final TimeDelta other) { return new TimeDelta(this.getSeconds() - other.getSeconds()); } @@ -166,8 +164,7 @@ public TimeDelta subtract(final TimeDelta other) * @return A new {@link TimeDelta} instance representing the duration of this * {@link TimeDelta delta} multiplied by the given factor. */ - public TimeDelta multiply(final long factor) - { + public TimeDelta multiply(final long factor) { return new TimeDelta(this.getSeconds() * factor); } @@ -176,8 +173,7 @@ public TimeDelta multiply(final long factor) * @return A new {@link TimeDelta} instance representing the duration of this * {@link TimeDelta delta} divided by the given factor. */ - public TimeDelta divide(final long factor) - { + public TimeDelta divide(final long factor) { return new TimeDelta(this.getSeconds() / factor); } @@ -186,45 +182,26 @@ public TimeDelta divide(final long factor) * longer than one hour. */ @Override - public String toString() - { + public String toString() { final long secondsLeft = seconds % 60; final long minutesLeft = (seconds % 3600) / 60; final long hoursLeft = (long) Math.floor(seconds / 3600.0); - if (hoursLeft != 0) - { - return formatter.format(hoursLeft) + ":" + formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft); - } - else - { + if (hoursLeft != 0) { + return formatter.format(hoursLeft) + ":" + formatter.format(minutesLeft) + ":" + + formatter.format(secondsLeft); + } else { return formatter.format(minutesLeft) + ":" + formatter.format(secondsLeft); } } @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { return this == o || o != null && getClass() == o.getClass() && seconds == ((TimeDelta) o).seconds; } @Override - public int hashCode() - { + public int hashCode() { return Objects.hash(seconds); } - - - @ConfigurationValueHandler - public static TimeDelta handleTimeDelta(String rawDelta) throws ConfigurationParseException - { - try - { - return new TimeDelta(rawDelta); - } - catch (IllegalArgumentException e) - { - throw new ConfigurationParseException("Invalid time delta format", rawDelta); - } - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java index 00e3dfd..d378cf5 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/Timer.java @@ -35,13 +35,12 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerEndsEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerStartsEvent; import fr.zcraft.quartzlib.components.i18n.I; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; - import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.UUID; +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; /** @@ -49,12 +48,11 @@ * * @author Amaury Carrade */ -public class Timer -{ +public class Timer { private static final NumberFormat formatter = new DecimalFormat("00"); - private UUID id; - private String name; + private final UUID id; + private final String name; private Boolean registered = false; private Boolean running = false; private Boolean displayed = false; @@ -71,52 +69,50 @@ public class Timer private Boolean system = false; - public Timer(String name) - { + public Timer(String name) { Validate.notNull(name, "The name cannot be null"); this.id = UUID.randomUUID(); // only used as a hashCode. this.name = name; } - public Timer(final String name, final int seconds) - { + public Timer(final String name, final int seconds) { this(name); setDuration(seconds); } - public Timer(final String name, final TimeDelta duration) - { + public Timer(final String name, final TimeDelta duration) { this(name, Math.toIntExact(duration.getSeconds())); } /** - * Sets the duration of the timer, in seconds. + * Formats a given number of seconds into [hh:]mm:ss. * - * @param seconds The duration. + * @param seconds The number of seconds. + * @return The formatted time (includes color codes). */ - public void setDuration(int seconds) - { - this.duration = seconds; - } + public static String formatTime(final int seconds) { + final int secondsLeft = seconds % 60; + final int minutesLeft = (seconds % 3600) / 60; + final int hoursLeft = (int) Math.floor(seconds / 3600); - /** - * Sets the duration of the timer. - * - * @param duration The duration. - */ - public void setDuration(TimeDelta duration) - { - this.duration = Math.toIntExact(duration.getSeconds()); + if (hoursLeft != 0) { + /// Timer. {0} = hours; {1} = minutes; {2} = seconds. + return ChatColor.WHITE + I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), + formatter.format(minutesLeft), formatter.format(secondsLeft)); + } else { + /// Timer. {0} = minutes; {1} = seconds. + return ChatColor.WHITE + + I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft)); + } } /** * Starts this timer. - * + * <p> * If this is called while the timer is running, the timer is restarted. */ - public void start() - { + public void start() { this.running = true; this.startTime = System.currentTimeMillis(); @@ -126,8 +122,7 @@ public void start() /** * Stops this timer. */ - public void stop() - { + public void stop() { stop(false); } @@ -136,19 +131,14 @@ public void stop() * * @param wasUp If true, the timer was stopped because the timer was up. */ - private void stop(boolean wasUp) - { + private void stop(boolean wasUp) { final TimerEndsEvent event = new TimerEndsEvent(this, wasUp); Bukkit.getServer().getPluginManager().callEvent(event); - if (isRegistered()) - { - if (event.getRestart()) - { + if (isRegistered()) { + if (event.getRestart()) { start(); - } - else - { + } else { running = false; startTime = 0L; } @@ -158,10 +148,8 @@ private void stop(boolean wasUp) /** * Updates the timer to check if it is up and terminate it. */ - public void update() - { - if (running && !paused && getElapsed() >= getDuration()) - { + public void update() { + if (running && !paused && getElapsed() >= getDuration()) { stop(true); } } @@ -173,23 +161,16 @@ public void update() * * @param pause If true the timer will be paused. */ - public void setPaused(boolean pause) - { - if (running) - { + public void setPaused(boolean pause) { + if (running) { // The pause is only set once (as example if the user executes /uh freeze all twice). - if (pause != paused) - { - if (pause) - { + if (pause != paused) { + if (pause) { elapsedWhenPaused = getElapsed(); paused = true; pauseTime = System.currentTimeMillis(); - } - - else - { + } else { // We have to add to the time of the start of the episode the elapsed time // during the pause. startTime += (System.currentTimeMillis() - pauseTime); @@ -207,8 +188,7 @@ public void setPaused(boolean pause) * * @return true if the timer is registered. */ - public Boolean isRegistered() - { + public Boolean isRegistered() { return registered; } @@ -217,8 +197,7 @@ public Boolean isRegistered() * * @param registered true if the timer is now registered. */ - protected void setRegistered(Boolean registered) - { + protected void setRegistered(Boolean registered) { this.registered = registered; } @@ -227,8 +206,7 @@ protected void setRegistered(Boolean registered) * * @return The name. */ - public String getName() - { + public String getName() { return name; } @@ -239,19 +217,16 @@ public String getName() * * @return The name. */ - public String getDisplayName() - { + public String getDisplayName() { return ChatColor.translateAlternateColorCodes('&', name); } - /** * Checks if the timer is currently running. * * @return true if the timer is running. */ - public Boolean isRunning() - { + public Boolean isRunning() { return running; } @@ -260,8 +235,7 @@ public Boolean isRunning() * * @return {@code true} if displayed. */ - public Boolean isDisplayed() - { + public Boolean isDisplayed() { return displayed; } @@ -270,8 +244,7 @@ public Boolean isDisplayed() * * @param displayed {@code true} to display, and {@code false} to hide. */ - public void setDisplayed(Boolean displayed) - { + public void setDisplayed(Boolean displayed) { this.displayed = displayed; } @@ -280,8 +253,7 @@ public void setDisplayed(Boolean displayed) * * @return {@code true} if name displayed. */ - public Boolean isNameDisplayed() - { + public Boolean isNameDisplayed() { return nameDisplayed; } @@ -290,16 +262,14 @@ public Boolean isNameDisplayed() * * @param nameDisplayed {@code true} to display, and {@code false} to hide. */ - public void setNameDisplayed(Boolean nameDisplayed) - { + public void setNameDisplayed(Boolean nameDisplayed) { this.nameDisplayed = nameDisplayed; } /** * @return {@code true} if this is a system timer that cannot be altered by the user. */ - public Boolean isSystem() - { + public Boolean isSystem() { return system; } @@ -308,8 +278,7 @@ public Boolean isSystem() * * @param system {@code true} if this timer is an internal system timer. */ - public void setSystem(Boolean system) - { + public void setSystem(Boolean system) { this.system = system; } @@ -318,32 +287,47 @@ public void setSystem(Boolean system) * * @return The duration. */ - public Integer getDuration() - { + public Integer getDuration() { return duration; } + /** + * Sets the duration of the timer, in seconds. + * + * @param seconds The duration. + */ + public void setDuration(int seconds) { + this.duration = seconds; + } + + /** + * Sets the duration of the timer. + * + * @param duration The duration. + */ + public void setDuration(TimeDelta duration) { + this.duration = Math.toIntExact(duration.getSeconds()); + } + /** * @return The elapsed time since the beginning of the timer (not including pauses), in seconds. */ - public int getElapsed() - { - if (isRunning()) - { - if (isPaused()) + public int getElapsed() { + if (isRunning()) { + if (isPaused()) { return elapsedWhenPaused; - else + } else { return (int) Math.floor((System.currentTimeMillis() - startTime) / 1000); + } + } else { + return 0; } - - else return 0; } /** * @return The number of seconds left before this timer is up. */ - public int getTimeLeft() - { + public int getTimeLeft() { return getDuration() - getElapsed(); } @@ -352,50 +336,22 @@ public int getTimeLeft() * * @return true if the timer is paused. */ - public Boolean isPaused() - { + public Boolean isPaused() { return paused; } @Override - public String toString() - { + public String toString() { return formatTime(getTimeLeft()); } @Override - public boolean equals(Object other) - { + public boolean equals(Object other) { return other instanceof Timer && ((Timer) other).getName().equals(this.getName()); } @Override - public int hashCode() - { + public int hashCode() { return id.hashCode(); } - - /** - * Formats a given number of seconds into [hh:]mm:ss. - * - * @param seconds The number of seconds. - * @return The formatted time (includes color codes). - */ - public static String formatTime(final int seconds) - { - final int secondsLeft = seconds % 60; - final int minutesLeft = (seconds % 3600) / 60; - final int hoursLeft = (int) Math.floor(seconds / 3600); - - if (hoursLeft != 0) - { - /// Timer. {0} = hours; {1} = minutes; {2} = seconds. - return ChatColor.WHITE + I.t("{0}{gray}:{white}{1}{gray}:{white}{2}", formatter.format(hoursLeft), formatter.format(minutesLeft), formatter.format(secondsLeft)); - } - else - { - /// Timer. {0} = minutes; {1} = seconds. - return ChatColor.WHITE +I.t("{white}{0}{gray}:{white}{1}", formatter.format(minutesLeft), formatter.format(secondsLeft)); - } - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java index 811c2f4..55a8b38 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java @@ -39,16 +39,20 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.commands.TimersCommand; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Material; import org.bukkit.entity.Player; -import java.util.*; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.stream.Collectors; - -@ModuleInfo ( +@ModuleInfo( name = "Timers", description = "The timekeeper of the whole UHCReloaded plugin & companions.", category = ModuleCategory.CORE, @@ -56,9 +60,8 @@ internal = true, can_be_unloaded = false ) -public class TimersModule extends QSGModule -{ - private Set<Timer> timers = new CopyOnWriteArraySet<>(); +public class TimersModule extends QSGModule { + private final Set<Timer> timers = new CopyOnWriteArraySet<>(); /** * Cached list of the running timers @@ -70,7 +73,7 @@ public class TimersModule extends QSGModule * * @see #pauseAllRunning(boolean) */ - private Set<Timer> timersToResume = new CopyOnWriteArraySet<>(); + private final Set<Timer> timersToResume = new CopyOnWriteArraySet<>(); /** * Sidebar cache. @@ -79,22 +82,19 @@ public class TimersModule extends QSGModule @Override - protected void onEnable() - { + protected void onEnable() { RunTask.timer(() -> timers.forEach(Timer::update), 1L, 20L); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(TimersCommand.class); } @Override - public void prepareInjectionIntoSidebar() - { + public void prepareInjectionIntoSidebar() { sidebarInjection.clear(); sidebarInjection = timers.stream() .filter(Timer::isDisplayed) @@ -103,13 +103,15 @@ public void prepareInjectionIntoSidebar() } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { + public void injectIntoSidebar(Player player, SidebarInjector injector) { sidebarInjection.forEach(timer -> { final List<String> lines; - if (timer.getLeft() == null) lines = Collections.singletonList(timer.getRight()); - else lines = Arrays.asList(timer.getLeft(), timer.getRight()); + if (timer.getLeft() == null) { + lines = Collections.singletonList(timer.getRight()); + } else { + lines = Arrays.asList(timer.getLeft(), timer.getRight()); + } injector.injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, true, lines); }); @@ -121,10 +123,8 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) * @param timer The timer to register. * @throws IllegalArgumentException if a timer with the same name is already registered. */ - public void registerTimer(final Timer timer) - { - if (timers.contains(timer)) - { + public void registerTimer(final Timer timer) { + if (timers.contains(timer)) { throw new IllegalArgumentException("The timer " + timer.getName() + " is already registered."); } @@ -140,8 +140,7 @@ public void registerTimer(final Timer timer) * * @param timer The timer to unregister. */ - public void unregisterTimer(final Timer timer) - { + public void unregisterTimer(final Timer timer) { timers.remove(timer); runningTimers.remove(timer); @@ -151,8 +150,7 @@ public void unregisterTimer(final Timer timer) /** * Updates the internal list of started timers. */ - public void updateStartedTimersList() - { + public void updateStartedTimersList() { runningTimers = timers.stream().filter(Timer::isRunning).collect(Collectors.toSet()); } @@ -160,11 +158,9 @@ public void updateStartedTimersList() * Returns a timer by his name. * * @param name The name of the timer. - * * @return The first timer with this name, or null if there isn't any timer with this name. */ - public Timer getTimer(final String name) - { + public Timer getTimer(final String name) { return timers.stream().filter(timer -> timer.getName().equals(name)).findFirst().orElse(null); } @@ -173,8 +169,7 @@ public Timer getTimer(final String name) * * @return The collection. */ - public Collection<Timer> getTimers() - { + public Collection<Timer> getTimers() { return Collections.unmodifiableSet(timers); } @@ -183,8 +178,7 @@ public Collection<Timer> getTimers() * * @return The collection. */ - public Collection<Timer> getRunningTimers() - { + public Collection<Timer> getRunningTimers() { return Collections.unmodifiableSet(runningTimers); } @@ -193,12 +187,10 @@ public Collection<Timer> getRunningTimers() * * @param paused If true, all the timers will be paused. Else, resumed. */ - public void pauseAll(boolean paused) - { + public void pauseAll(boolean paused) { getRunningTimers().forEach(timer -> timer.setPaused(paused)); - if (!paused) - { + if (!paused) { // If we restart all the timers regardless to their previous state, // this data is meaningless. timersToResume.clear(); @@ -212,17 +204,13 @@ public void pauseAll(boolean paused) * * @param paused If true, all the timers will be paused. Else, resumed. */ - public void pauseAllRunning(boolean paused) - { - if (paused) - { + public void pauseAllRunning(boolean paused) { + if (paused) { getRunningTimers().stream().filter(timer -> !timer.isPaused()).forEach(timer -> { timer.setPaused(true); timersToResume.add(timer); }); - } - else - { + } else { timersToResume.forEach(timer -> timer.setPaused(false)); timersToResume.clear(); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java index 1cca676..5949714 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/commands/TimersCommand.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; @@ -44,58 +45,64 @@ import fr.zcraft.quartzlib.components.rawtext.RawText; import fr.zcraft.quartzlib.components.rawtext.RawTextPart; import fr.zcraft.quartzlib.tools.text.MessageSender; +import java.util.Collection; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import java.util.Collection; - -@CommandInfo (name = "timers", usageParameters = "[add|display|hide|list|pause|resume|remove|set|start|stop|help]", aliases = {"timer"}) +@CommandInfo(name = "timers", usageParameters = "[add|display|hide|list|pause|resume|remove|set|start|stop|help]", aliases = { + "timer"}) @WithFlags -public class TimersCommand extends Command -{ +public class TimersCommand extends Command { private final TimersModule timersModule = QSG.module(TimersModule.class); @Override - protected void run() throws CommandException - { - if (args.length == 0) - { + protected void run() throws CommandException { + if (args.length == 0) { list(); return; } - switch (args[0].toLowerCase()) - { + switch (args[0].toLowerCase()) { case "add": - add(); break; + add(); + break; case "display": - display(); break; + display(); + break; case "hide": - hide(); break; + hide(); + break; case "list": - list(); break; + list(); + break; case "pause": - pause(); break; + pause(); + break; case "resume": - resume(); break; + resume(); + break; case "remove": - remove(); break; + remove(); + break; case "set": - set(); break; + set(); + break; case "start": - start(); break; + start(); + break; case "stop": - stop(); break; + stop(); + break; case "help": default: @@ -103,11 +110,11 @@ protected void run() throws CommandException } } - private void help() - { + private void help() { info(I.t("{blue}{bold}Command help for {cc}{bold}/uh timers")); info(I.t("{cc}/uh timers add <duration> <title ...> {ci}: adds a timer.")); - info(I.t("{cc}/uh timers display <title ...> [--without-name] {ci}: displays a timer in the scoreboard. Automatic when a timer is started.")); + info(I.t( + "{cc}/uh timers display <title ...> [--without-name] {ci}: displays a timer in the scoreboard. Automatic when a timer is started.")); info(I.t("{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. Don't stops the timer.")); info(I.t("{cc}/uh timers list {ci}: lists the registered timers.")); info(I.t("{cc}/uh timers pause <title ...> {ci}: pauses a timer.")); @@ -115,17 +122,20 @@ private void help() info(I.t("{cc}/uh timers remove <title ...> {ci}: deletes a timer.")); info(I.t("{cc}/uh timers set <duration> <title ...> {ci}: sets the duration of a timer.")); info(I.t("{cc}/uh timers start <title ...> {ci}: starts a timer.")); - info(I.t("{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be removed from the scoreboard.")); + info(I.t( + "{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be removed from the scoreboard.")); } - private void add() throws CommandException - { - if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name.")); + private void add() throws CommandException { + if (args.length < 3) { + throwInvalidArgument(I.t("You must specify both a duration and a name.")); + } final String name = QSGUtils.getStringFromCommandArguments(args, 2); - if (timersModule.getTimer(name) != null) + if (timersModule.getTimer(name) != null) { throwInvalidArgument(I.t("{ce}A timer called {0}{ce} already exists; please choose another name.", name)); + } final Timer timer = new Timer(name, getTimeDeltaParameter(1)); timersModule.registerTimer(timer); @@ -133,8 +143,7 @@ private void add() throws CommandException success(I.t("{cs}The timer {0}{cs} (duration {1}) has been registered.", timer.getDisplayName(), args[1])); } - private void display() throws CommandException - { + private void display() throws CommandException { final Timer timer = getTimerParameter(1); timer.setDisplayed(true); @@ -143,8 +152,7 @@ private void display() throws CommandException reply(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName())); } - private void hide() throws CommandException - { + private void hide() throws CommandException { final Timer timer = getTimerParameter(1); timer.setDisplayed(false); @@ -152,89 +160,93 @@ private void hide() throws CommandException reply(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName())); } - private void list() - { + private void list() { final Collection<Timer> timers = timersModule.getTimers(); info(""); info(I.tn("{ci}{0} timer is registered.", "{ci}{0} timers are registered.", timers.size())); - for (final Timer timer : timers) - { + for (final Timer timer : timers) { final RawTextPart timerText = new RawText() - .then(" • ").color(timer.isRunning() ? (timer.isPaused() ? ChatColor.YELLOW : ChatColor.GREEN) : ChatColor.RED) - .then(timer.getDisplayName()) + .then(" • ") + .color(timer.isRunning() ? (timer.isPaused() ? ChatColor.YELLOW : ChatColor.GREEN) : ChatColor.RED) + .then(timer.getDisplayName()) .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n") - .then(timer.isRunning() ? (timer.isPaused() ? I.t("Paused") : I.t("Running")) : I.t("Not started")) - .then("\n\n") - .then(timer.toString() + (timer.isRunning() ? " " + I.t("{gray}(total: {0}{gray})", Timer.formatTime(timer.getDuration())) : "")) - .then(timer.isSystem() ? "\n\n" + I.t("{gray}{bold}System timer") : "") - .then(timer.isSystem() ? "\n" + I.t("{gray}This timer is a system timer, it cannot be modified (you can still display or hide it to/from the sidebar).") : "") + new RawText() + .then(timer.getDisplayName()) + .then("\n") + .then(timer.isRunning() ? (timer.isPaused() ? I.t("Paused") : I.t("Running")) : + I.t("Not started")) + .then("\n\n") + .then(timer.toString() + (timer.isRunning() ? " " + + I.t("{gray}(total: {0}{gray})", Timer.formatTime(timer.getDuration())) : + "")) + .then(timer.isSystem() ? "\n\n" + I.t("{gray}{bold}System timer") : "") + .then(timer.isSystem() ? "\n" + + I.t("{gray}This timer is a system timer, it cannot be modified (you can still display or hide it to/from the sidebar).") : + "") ) - .then(" ") - .then("[ \u272F ]") + .then(" ") + .then("[ \u272F ]") .color(timer.isDisplayed() ? ChatColor.DARK_PURPLE : ChatColor.LIGHT_PURPLE) .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n").then(timer.isDisplayed() ? I.t("{white}Hide this timer from the sidebar") : I.t("{white}Show this timer in the sidebar")) + new RawText() + .then(timer.getDisplayName()) + .then("\n") + .then(timer.isDisplayed() ? I.t("{white}Hide this timer from the sidebar") : + I.t("{white}Show this timer in the sidebar")) ) - .command(TimersCommand.class, timer.isDisplayed() ? "hide" : "display", timer.getName(), "--from-list-command") - .then(" "); + .command(TimersCommand.class, timer.isDisplayed() ? "hide" : "display", timer.getName(), + "--from-list-command") + .then(" "); - if (!timer.isSystem()) - { - if (!timer.isRunning()) - { + if (!timer.isSystem()) { + if (!timer.isRunning()) { timerText - .then("[ \u25B6 ]") - .style(ChatColor.GREEN) - .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n").then(I.t("{white}Start this timer")) - ) - .command(TimersCommand.class, "start", timer.getName(), "--from-list-command"); - } - else - { + .then("[ \u25B6 ]") + .style(ChatColor.GREEN) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Start this timer")) + ) + .command(TimersCommand.class, "start", timer.getName(), "--from-list-command"); + } else { timerText - .then("[ \u2B1B ]") - .style(ChatColor.RED) - .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n").then(I.t("{white}Stop this timer")) - ) - .command(TimersCommand.class, "stop", timer.getName(), "--from-list-command"); + .then("[ \u2B1B ]") + .style(ChatColor.RED) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Stop this timer")) + ) + .command(TimersCommand.class, "stop", timer.getName(), "--from-list-command"); } timerText.then(" "); - if (timer.isRunning()) - { + if (timer.isRunning()) { timerText - .then("[ \u2759 \u2759 ]") - .style(timer.isPaused() ? ChatColor.GOLD : ChatColor.YELLOW) - .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n").then(timer.isPaused() ? I.t("{white}Resume this timer") : I.t("{white}Pause this timer")) - ) - .command(TimersCommand.class, timer.isPaused() ? "resume" : "pause", timer.getName(), "--from-list-command") - .then(" "); + .then("[ \u2759 \u2759 ]") + .style(timer.isPaused() ? ChatColor.GOLD : ChatColor.YELLOW) + .hover( + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(timer.isPaused() ? I.t("{white}Resume this timer") : + I.t("{white}Pause this timer")) + ) + .command(TimersCommand.class, timer.isPaused() ? "resume" : "pause", timer.getName(), + "--from-list-command") + .then(" "); } timerText - .then("[ × ]") + .then("[ × ]") .style(ChatColor.DARK_RED) .hover( - new RawText() - .then(timer.getDisplayName()) - .then("\n").then(I.t("{white}Delete this timer")) + new RawText() + .then(timer.getDisplayName()) + .then("\n").then(I.t("{white}Delete this timer")) ) .command(TimersCommand.class, "remove", timer.getName(), "--from-list-command"); } @@ -242,52 +254,54 @@ private void list() send(timerText.build()); } - if (sender instanceof Player) - { + if (sender instanceof Player) { send( - /// Button in /uh timers - new RawText(I.t("[ Create a new timer ]")) - .color(ChatColor.GREEN) - .hover(I.t("{white}Click here to create a timer\n{gray}/uh timers add mm:ss <name>")) - .suggest(TimersCommand.class, "add", "") - - /// Button in /uh timers - .then(" ").then(I.t("[ Display Help ]")) - .color(ChatColor.YELLOW) - .hover(I.t("{white}Get some help about the commands\n{gray}/uh timers help")) - .command(TimersCommand.class, "help") - .build() + /// Button in /uh timers + new RawText(I.t("[ Create a new timer ]")) + .color(ChatColor.GREEN) + .hover(I.t("{white}Click here to create a timer\n{gray}/uh timers add mm:ss <name>")) + .suggest(TimersCommand.class, "add", "") + + /// Button in /uh timers + .then(" ").then(I.t("[ Display Help ]")) + .color(ChatColor.YELLOW) + .hover(I.t("{white}Get some help about the commands\n{gray}/uh timers help")) + .command(TimersCommand.class, "help") + .build() ); } } - private void pause() throws CommandException - { + private void pause() throws CommandException { final Timer timer = getTimerParameter(1); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } timer.setPaused(true); reply(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName())); } - private void resume() throws CommandException - { + private void resume() throws CommandException { final Timer timer = getTimerParameter(1); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } timer.setPaused(false); reply(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName())); } - private void remove() throws CommandException - { + private void remove() throws CommandException { final Timer timer = getTimerParameter(1); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } timer.stop(); timersModule.unregisterTimer(timer); @@ -295,41 +309,47 @@ private void remove() throws CommandException reply(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName())); } - private void set() throws CommandException - { - if (args.length < 3) throwInvalidArgument(I.t("You must specify both a duration and a name.")); + private void set() throws CommandException { + if (args.length < 3) { + throwInvalidArgument(I.t("You must specify both a duration and a name.")); + } final Timer timer = getTimerParameter(2); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } timer.setDuration(getTimeDeltaParameter(1)); success(I.t("{cs}The duration of the timer {0}{cs} is now {1}.", timer.getDisplayName(), args[1])); } - private void start() throws CommandException - { + private void start() throws CommandException { final Timer timer = getTimerParameter(1); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } - if (!hasFlag("--hidden")) - { + if (!hasFlag("--hidden")) { timer.setDisplayed(true); timer.setNameDisplayed(!hasFlag("without-name")); } - if (timer.isRunning()) timer.stop(); + if (timer.isRunning()) { + timer.stop(); + } timer.start(); reply(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName())); } - private void stop() throws CommandException - { + private void stop() throws CommandException { final Timer timer = getTimerParameter(1); - if (timer.isSystem()) throwNotAuthorized(); + if (timer.isSystem()) { + throwNotAuthorized(); + } timer.stop(); @@ -337,51 +357,46 @@ private void stop() throws CommandException } - private void reply(final String reply) throws CommandException - { - if (hasFlag("from-list-command") && sender instanceof Player) - { + private void reply(final String reply) throws CommandException { + if (hasFlag("from-list-command") && sender instanceof Player) { MessageSender.sendActionBarMessage(playerSender(), reply); list(); + } else { + success(reply); } - - else success(reply); } - private Timer getTimerParameter(int index) throws CommandException - { - try - { + private Timer getTimerParameter(int index) throws CommandException { + try { final String timerName = QSGUtils.getStringFromCommandArguments(args, index); final Timer timer = timersModule.getTimer(timerName); - if (timer == null) + if (timer == null) { throwInvalidArgument(I.t("{ce}This timer is not registered.", timerName)); + } return timer; } - catch (IllegalArgumentException e) - { + catch (IllegalArgumentException e) { throwInvalidArgument(I.t("A timer name is required as argument #{0}", index + 1)); return null; } } - private TimeDelta getTimeDeltaParameter(final int index) throws CommandException - { - try - { + private TimeDelta getTimeDeltaParameter(final int index) throws CommandException { + try { return new TimeDelta(args[index]); } - catch (final ArrayIndexOutOfBoundsException e) - { - throwInvalidArgument(I.t("A duration is required as argument #{0}. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1)); + catch (final ArrayIndexOutOfBoundsException e) { + throwInvalidArgument( + I.t("A duration is required as argument #{0}. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1)); return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings } - catch (final IllegalArgumentException e) - { - throwInvalidArgument(I.t("The duration provided as argument #{0} is invalid. Format: “mm”, “mm:ss” or “hh:mm:ss”.", index + 1)); + catch (final IllegalArgumentException e) { + throwInvalidArgument( + I.t("The duration provided as argument #{0} is invalid. Format: “mm”, “mm:ss” or “hh:mm:ss”.", + index + 1)); return new TimeDelta(0); // Dummy value never reached to avoid “can be null” lint warnings } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java index 31b9d7e..8bfe3d6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerEndsEvent.java @@ -42,27 +42,28 @@ * <p> * It is fired before all the values of the timer are reset. */ -public final class TimerEndsEvent extends Event -{ - private Timer timer; +public final class TimerEndsEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private final Timer timer; private Boolean timerWasUp = false; private Boolean restart = false; - - public TimerEndsEvent(Timer timer, Boolean timerUp) - { + public TimerEndsEvent(Timer timer, Boolean timerUp) { this.timer = timer; this.timerWasUp = timerUp; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the timer. * * @return the timer. */ - public Timer getTimer() - { + public Timer getTimer() { return timer; } @@ -71,43 +72,30 @@ public Timer getTimer() * * @return true if the timer was stopped because it was up. */ - public boolean wasTimerUp() - { + public boolean wasTimerUp() { return timerWasUp; } /** - * If true, the timer will be restarted. + * Return true if the timer will be restarted. * - * @param restart true if the timer needs to be restarted. + * @return {@code true} if the timer needs to be restarted. */ - public void setRestart(boolean restart) - { - this.restart = restart; + public boolean getRestart() { + return this.restart; } /** - * Return true if the timer will be restarted. + * If true, the timer will be restarted. * - * @return {@code true} if the timer needs to be restarted. + * @param restart true if the timer needs to be restarted. */ - public boolean getRestart() - { - return this.restart; + public void setRestart(boolean restart) { + this.restart = restart; } - - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java index bea7770..9be07ff 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/events/TimerStartsEvent.java @@ -42,36 +42,29 @@ * * @author Amaury Carrade */ -public final class TimerStartsEvent extends Event -{ - private Timer timer; +public final class TimerStartsEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private final Timer timer; - public TimerStartsEvent(Timer timer) - { + public TimerStartsEvent(Timer timer) { this.timer = timer; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the timer. * * @return */ - public Timer getTimer() - { + public Timer getTimer() { return timer; } - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java index 433b7ff..2a104ff 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/KillsCountModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,50 +42,48 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import java.util.*; - -@ModuleInfo ( +@ModuleInfo( name = "Kills Count", description = "Displays the player's kills count in the sidebar.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.COSMETICS, icon = Material.DIAMOND_SWORD ) -public class KillsCountModule extends QSGModule -{ +public class KillsCountModule extends QSGModule { private final Map<UUID, Set<UUID>> kills = new HashMap<>(); @Override - public void injectIntoSidebar(final Player player, final SidebarInjector injector) - { + public void injectIntoSidebar(final Player player, final SidebarInjector injector) { injector.injectLines( SidebarInjector.SidebarPriority.BOTTOM, true, - I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", getKillsFor(player.getUniqueId()).size()) + I.tn("{white}{0}{gray} player killed", "{white}{0}{gray} players killed", + getKillsFor(player.getUniqueId()).size()) ); } - private Set<UUID> getKillsFor(final UUID playerID) - { + private Set<UUID> getKillsFor(final UUID playerID) { return kills.computeIfAbsent(playerID, uuid -> new HashSet<>()); } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (ev.getPlayer().isOnline() && ev.getPlayer().getPlayer().getKiller() != null) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (ev.getPlayer().isOnline() && ev.getPlayer().getPlayer().getKiller() != null) { getKillsFor(ev.getPlayer().getPlayer().getKiller().getUniqueId()).add(ev.getPlayer().getUniqueId()); } } @EventHandler - public void onPlayerResurrect(final PlayerResurrectedEvent ev) - { + public void onPlayerResurrect(final PlayerResurrectedEvent ev) { kills.values().forEach(playerKills -> playerKills.remove(ev.getPlayer().getUniqueId())); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java index 0d4d5d7..d9fbd1a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/ListHealthModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -39,6 +40,7 @@ import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -46,23 +48,19 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; -import java.util.UUID; - -@ModuleInfo ( +@ModuleInfo( name = "Health in Players List", description = "Displays the health of players in the overlay list displayed with <TAB>.", when = ModuleLoadTime.ON_GAME_STARTING, category = ModuleCategory.COSMETICS, icon = Material.DETECTOR_RAIL ) -public class ListHealthModule extends QSGModule -{ - private String objectiveID = UUID.randomUUID().toString().substring(0, 16); +public class ListHealthModule extends QSGModule { + private final String objectiveID = UUID.randomUUID().toString().substring(0, 16); @Override - protected void onEnable() - { + protected void onEnable() { // Initialization of the scoreboard (health in players' list) final Objective healthObjective = QSG.get().getScoreboard().registerNewObjective(objectiveID, Criterias.HEALTH); healthObjective.setDisplayName("Health"); @@ -73,8 +71,7 @@ protected void onEnable() } @Override - protected void onDisable() - { + protected void onDisable() { QSG.get().getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST); QSG.get().getScoreboard().getObjective(objectiveID).unregister(); } @@ -82,8 +79,7 @@ protected void onDisable() /** * Updates the health score for all players. */ - public void updateHealthScore() - { + public void updateHealthScore() { Bukkit.getOnlinePlayers().forEach(this::updateHealthScore); } @@ -92,8 +88,7 @@ public void updateHealthScore() * * @param player The player to update. */ - public void updateHealthScore(final Player player) - { + public void updateHealthScore(final Player player) { if (player.getHealth() != 1d) // Prevents killing the player { player.setHealth(player.getHealth() - 1d); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java index fd758a9..43bdd8f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/Config.java @@ -31,25 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } +public class Config extends ConfigurationInstance { static public final ConfigurationItem<TimeDelta> LENGTH = item("length", new TimeDelta(0, 20, 0)); static public final ConfigurationItem<Boolean> DISPLAY_TITLE = item("display-title", true); static public final ConfigurationItem<Boolean> DISPLAY_IN_SIDEBAR = item("display-in-sidebar", true); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java index 6f7603b..862807b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -44,14 +45,16 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.Timer; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimersModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.events.TimerEndsEvent; -import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.commands.ShiftCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events.EpisodeChangedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.events.EpisodeChangedEvent.EpisodeChangedCause; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter.PlayerListHeaderFooterModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.text.Titles; +import java.util.Collections; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.CommandSender; @@ -59,11 +62,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import java.util.Collections; -import java.util.List; - -@ModuleInfo ( +@ModuleInfo( name = "Episodes", description = "Displays time marks every 20 minutes (by default), e.g. to divide a recording for diffusion.", when = ModuleLoadTime.ON_GAME_START, @@ -72,8 +72,7 @@ settings = Config.class, can_be_loaded_late = false ) -public class EpisodesModule extends QSGModule -{ +public class EpisodesModule extends QSGModule { private final GameModule game = QSG.game(); private final TimersModule timers = QSG.module(TimersModule.class); @@ -81,8 +80,7 @@ public class EpisodesModule extends QSGModule private int episode = 1; @Override - protected void onEnable() - { + protected void onEnable() { episodesTimer = new Timer("Episodes"); episodesTimer.setDuration(Config.LENGTH.get()); episodesTimer.setSystem(true); @@ -101,30 +99,30 @@ protected void onEnable() } @Override - protected void onDisable() - { + protected void onDisable() { episodesTimer.setDisplayed(false); timers.unregisterTimer(episodesTimer); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(ShiftCommand.class); } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { - if (!Config.DISPLAY_IN_SIDEBAR.get() || game.currentPhaseBefore(GamePhase.IN_GAME)) return; + public void injectIntoSidebar(Player player, SidebarInjector injector) { + if (!Config.DISPLAY_IN_SIDEBAR.get() || game.currentPhaseBefore(GamePhase.IN_GAME)) { + return; + } injector.injectLines(SidebarPriority.VERY_TOP, true, I.t("{gray}Episode {white}{0}", episode)); } @EventHandler - public void onTimerEnds(final TimerEndsEvent ev) - { - if (!ev.getTimer().equals(episodesTimer)) return; + public void onTimerEnds(final TimerEndsEvent ev) { + if (!ev.getTimer().equals(episodesTimer)) { + return; + } ev.setRestart(true); shift(false, null, episode + 1); @@ -134,17 +132,15 @@ public void onTimerEnds(final TimerEndsEvent ev) * Used to broadcast the episode change. */ @EventHandler - public void onEpisodeChange(final EpisodeChangedEvent ev) - { + public void onEpisodeChange(final EpisodeChangedEvent ev) { final String message; - if (ev.getCause() == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) - { - final String shifterName = ev.getShifter() instanceof ConsoleCommandSender ? I.t("the console") : ev.getShifter().getName(); - message = I.t("{aqua}-------- End of episode {0} [forced by {1}] --------", ev.getOldEpisode(), shifterName); - } - else - { + if (ev.getCause() == EpisodeChangedEvent.EpisodeChangedCause.SHIFTED) { + final String shifterName = + ev.getShifter() instanceof ConsoleCommandSender ? I.t("the console") : ev.getShifter().getName(); + message = + I.t("{aqua}-------- End of episode {0} [forced by {1}] --------", ev.getOldEpisode(), shifterName); + } else { message = I.t("{aqua}-------- End of episode {0} --------", String.valueOf(ev.getOldEpisode())); } @@ -152,8 +148,7 @@ public void onEpisodeChange(final EpisodeChangedEvent ev) // Broadcasts title - if (Config.DISPLAY_TITLE.get()) - { + if (Config.DISPLAY_TITLE.get()) { Titles.broadcastTitle( 5, 32, 8, "", @@ -167,30 +162,25 @@ public void onEpisodeChange(final EpisodeChangedEvent ev) QSG.ifLoaded(PlayerListHeaderFooterModule.class, PlayerListHeaderFooterModule::update); } - public int getEpisode() - { + public int getEpisode() { return episode; } - public void shift(final CommandSender shifter, final int newEpisode) - { + public void shift(final CommandSender shifter, final int newEpisode) { shift(true, shifter != null ? shifter : Bukkit.getConsoleSender(), newEpisode); } - public void shift(final CommandSender shifter) - { + public void shift(final CommandSender shifter) { shift(shifter, episode + 1); } - private void shift(final boolean forced, final CommandSender shifter, final int newEpisode) - { + private void shift(final boolean forced, final CommandSender shifter, final int newEpisode) { final int oldEpisode = episode; episode = newEpisode; // If not forced, the timer is restarted in the event, else we have to restart // it manually. - if (forced) - { + if (forced) { episodesTimer.start(); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java index 788380e..04d2daa 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/commands/ShiftCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -43,23 +44,18 @@ import fr.zcraft.quartzlib.components.i18n.I; -@CommandInfo (name = "shift", usageParameters = "[next episode number]", aliases = {"shift-episode"}) -public class ShiftCommand extends Command -{ +@CommandInfo(name = "shift", usageParameters = "[next episode number]", aliases = {"shift-episode"}) +public class ShiftCommand extends Command { @Override - protected void run() throws CommandException - { - if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) - { + protected void run() throws CommandException { + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { error(I.t("{ce}You can't shift the current episode because the game is not started.")); } - try - { + try { QSG.module(EpisodesModule.class).shift(sender, Integer.parseInt(args[0])); } - catch (ArrayIndexOutOfBoundsException | NumberFormatException e) - { + catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { QSG.module(EpisodesModule.class).shift(sender); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java index 246efb1..c551035 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/events/EpisodeChangedEvent.java @@ -40,15 +40,14 @@ /** * Called when an episode changes. */ -public class EpisodeChangedEvent extends Event -{ - private int newEpisode; - private int oldEpisode; - private EpisodeChangedCause cause; - private CommandSender shifter; +public class EpisodeChangedEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private final int newEpisode; + private final int oldEpisode; + private final EpisodeChangedCause cause; + private final CommandSender shifter; - public EpisodeChangedEvent(int newEpisode, int oldEpisode, EpisodeChangedCause cause, CommandSender shifter) - { + public EpisodeChangedEvent(int newEpisode, int oldEpisode, EpisodeChangedCause cause, CommandSender shifter) { this.newEpisode = newEpisode; this.oldEpisode = oldEpisode; @@ -56,13 +55,16 @@ public EpisodeChangedEvent(int newEpisode, int oldEpisode, EpisodeChangedCause c this.shifter = shifter; } + public static HandlerList getHandlerList() { + return handlers; + } + /** * Returns the new episode. * * @return The new episode. */ - public int getNewEpisode() - { + public int getNewEpisode() { return newEpisode; } @@ -71,8 +73,7 @@ public int getNewEpisode() * * @return The old episode. */ - public int getOldEpisode() - { + public int getOldEpisode() { return oldEpisode; } @@ -80,11 +81,9 @@ public int getOldEpisode() * Why the episode changed? * * @return The cause. - * * @see EpisodeChangedCause */ - public EpisodeChangedCause getCause() - { + public EpisodeChangedCause getCause() { return cause; } @@ -94,29 +93,17 @@ public EpisodeChangedCause getCause() * * @return The shifter. */ - public CommandSender getShifter() - { + public CommandSender getShifter() { return shifter; } - - - private static final HandlerList handlers = new HandlerList(); - @Override - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { + public HandlerList getHandlers() { return handlers; } - public enum EpisodeChangedCause - { + public enum EpisodeChangedCause { /** * The episode changed because the previous episode was finished. */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java index d22968c..0c193fe 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/Config.java @@ -31,30 +31,26 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.hardcoreHearts; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; +public class Config extends ConfigurationInstance { + static public final ConfigurationItem<Boolean> HARDCORE_HEARTS = item("hardcore-hearts", true); + static public final AutoRespawnSection AUTO_RESPAWN = section("auto-respawn", AutoRespawnSection.class); -public class Config extends ConfigurationInstance -{ - public Config(File file) - { + public Config(File file) { super(file); } - static public final ConfigurationItem<Boolean> HARDCORE_HEARTS = item("hardcore-hearts", true); - - static public final AutoRespawnSection AUTO_RESPAWN = section("auto-respawn", AutoRespawnSection.class); - - static public class AutoRespawnSection extends ConfigurationSection - { + static public class AutoRespawnSection extends ConfigurationSection { public final ConfigurationItem<Boolean> DO = item("do", true); public final ConfigurationItem<Integer> DELAY = item("delay", 6); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java index 61af776..af3b04f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/HardcoreHeartsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.hardcoreHearts; import com.comphenix.protocol.ProtocolLibrary; @@ -41,7 +42,7 @@ import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Hardcore Hearts", description = "Replaces hearts with hardcore hearts.", depends = "ProtocolLib", @@ -49,20 +50,16 @@ icon = Material.WITHER_ROSE, settings = Config.class ) -public class HardcoreHeartsModule extends QSGModule -{ +public class HardcoreHeartsModule extends QSGModule { @Override - protected void onEnable() - { + protected void onEnable() { final PacketsListener packetsListener = new PacketsListener(); - if (Config.HARDCORE_HEARTS.get()) - { + if (Config.HARDCORE_HEARTS.get()) { ProtocolLibrary.getProtocolManager().addPacketListener(packetsListener); } - if (Config.AUTO_RESPAWN.DO.get()) - { + if (Config.AUTO_RESPAWN.DO.get()) { QuartzLib.registerEvents(packetsListener); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java index 8c9de07..99fe407 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/hardcoreHearts/PacketsListener.java @@ -42,20 +42,17 @@ import com.comphenix.protocol.wrappers.EnumWrappers; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.lang.reflect.InvocationTargetException; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; -import java.lang.reflect.InvocationTargetException; - -public class PacketsListener extends PacketAdapter implements Listener -{ +public class PacketsListener extends PacketAdapter implements Listener { private final ProtocolManager pm = ProtocolLibrary.getProtocolManager(); private final PacketContainer respawnPacket; - public PacketsListener() - { + public PacketsListener() { // This listener needs to listen on login packets only. super(QSG.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); @@ -68,11 +65,9 @@ public PacketsListener() * Used to present the server as an hardcore server, for the clients to display hardcore hearts. */ @Override - public void onPacketSending(final PacketEvent ev) - { + public void onPacketSending(final PacketEvent ev) { // If its a login packet, write the hardcore flag (first boolean) to true. - if (ev.getPacketType().equals(PacketType.Play.Server.LOGIN)) - { + if (ev.getPacketType().equals(PacketType.Play.Server.LOGIN)) { ev.getPacket().getBooleans().write(0, true); } } @@ -81,19 +76,16 @@ public void onPacketSending(final PacketEvent ev) * Used to automatically respawn the dead players. */ @EventHandler - public void onPlayerDeath(final PlayerDeathEvent ev) - { - if (Config.AUTO_RESPAWN.DO.get()) - { + public void onPlayerDeath(final PlayerDeathEvent ev) { + if (Config.AUTO_RESPAWN.DO.get()) { RunTask.later(() -> { - try - { + try { pm.recieveClientPacket(ev.getEntity(), respawnPacket); } - catch (final IllegalAccessException | InvocationTargetException e) - { - QSG.log(HardcoreHeartsModule.class).error("Unable to respawn player {0}", e, ev.getEntity().getName()); + catch (final IllegalAccessException | InvocationTargetException e) { + QSG.log(HardcoreHeartsModule.class) + .error("Unable to respawn player {0}", e, ev.getEntity().getName()); } }, Config.AUTO_RESPAWN.DELAY.get() * 20L); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java index 746438b..7ec30db 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/Config.java @@ -31,22 +31,21 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationMap; - import java.io.File; -public class Config extends ConfigurationInstance -{ - public Config(File file) - { +public class Config extends ConfigurationInstance { + public static final ConfigurationMap<GamePhase, String> HEADERS = + ConfigurationItem.map("headers", GamePhase.class, String.class); + public static final ConfigurationMap<GamePhase, String> FOOTERS = + ConfigurationItem.map("footers", GamePhase.class, String.class); + public Config(File file) { super(file); } - - public static final ConfigurationMap<GamePhase, String> HEADERS = ConfigurationItem.map("headers", GamePhase.class, String.class); - public static final ConfigurationMap<GamePhase, String> FOOTERS = ConfigurationItem.map("footers", GamePhase.class, String.class); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java index 2f0f3ad..84ea0ac 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/ListPlaceholdersCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; @@ -40,45 +41,41 @@ import fr.zcraft.quartzlib.components.commands.WithFlags; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.commands.PaginatedTextView; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - import java.util.Map; import java.util.function.Supplier; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; -@CommandInfo (name = "list-hf-placeholders") +@CommandInfo(name = "list-hf-placeholders") @WithFlags("page") -public class ListPlaceholdersCommand extends Command -{ +public class ListPlaceholdersCommand extends Command { @Override - protected void run() throws CommandException - { - final Map<String, Supplier<String>> placeholders = QSG.module(PlayerListHeaderFooterModule.class).getPlaceholderSuppliers(); + protected void run() throws CommandException { + final Map<String, Supplier<String>> placeholders = + QSG.module(PlayerListHeaderFooterModule.class).getPlaceholderSuppliers(); final int page = args.length > 0 ? getIntegerParameter(0) : 1; new PlaceholdersList() - .setData(placeholders.entrySet().toArray(new Map.Entry[placeholders.entrySet().size()])) - .setCurrentPage(page) - .display(sender); + .setData(placeholders.entrySet().toArray(new Map.Entry[placeholders.entrySet().size()])) + .setCurrentPage(page) + .display(sender); } - private final class PlaceholdersList extends PaginatedTextView<Map.Entry<String, Supplier<String>>> - { + private final class PlaceholdersList extends PaginatedTextView<Map.Entry<String, Supplier<String>>> { @Override - protected void displayHeader(final CommandSender receiver) - { - receiver.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + I.tn("{0} registered placeholder", "{0} registered placeholders", data().length)); + protected void displayHeader(final CommandSender receiver) { + receiver.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + + I.tn("{0} registered placeholder", "{0} registered placeholders", data().length)); } @Override - protected void displayItem(final CommandSender receiver, final Map.Entry<String, Supplier<String>> item) - { - receiver.sendMessage(String.format("%s{%s}%s\t« %s%s »", ChatColor.WHITE, item.getKey(), ChatColor.GRAY, item.getValue().get(), ChatColor.GRAY)); + protected void displayItem(final CommandSender receiver, final Map.Entry<String, Supplier<String>> item) { + receiver.sendMessage(String.format("%s{%s}%s\t« %s%s »", ChatColor.WHITE, item.getKey(), ChatColor.GRAY, + item.getValue().get(), ChatColor.GRAY)); } @Override - protected String getCommandToPage(final int page) - { + protected String getCommandToPage(final int page) { return build(String.valueOf(page)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java index 167f2ea..3e93e50 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.playerListHeaderFooter; import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; @@ -46,7 +47,18 @@ import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.ListHeaderFooter; -import fr.zcraft.quartzteams.events.*; +import fr.zcraft.quartzteams.events.PlayerJoinedTeamEvent; +import fr.zcraft.quartzteams.events.PlayerLeftTeamEvent; +import fr.zcraft.quartzteams.events.TeamRegisteredEvent; +import fr.zcraft.quartzteams.events.TeamUnregisteredEvent; +import fr.zcraft.quartzteams.events.TeamUpdatedEvent; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Supplier; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -55,12 +67,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; -import java.util.*; -import java.util.function.Supplier; -import java.util.stream.Stream; - -@ModuleInfo ( +@ModuleInfo( name = "Players List Header & Footer", description = "Fills the players list header & footer with any text, that may contains infos related " + "to the current game through placeholders. Other modules can add placeholders.", @@ -70,13 +78,11 @@ settings = Config.class, can_be_loaded_late = false ) -public class PlayerListHeaderFooterModule extends QSGModule -{ +public class PlayerListHeaderFooterModule extends QSGModule { private final Map<String, Supplier<String>> placeholderSuppliers = new HashMap<>(); @Override - protected void onEnable() - { + protected void onEnable() { registerPlaceholder("title", QSGConfig.TITLE::get); registerPlaceholder("playersText", () -> I.tn("{0} player", "{0} players", QSG.game().countAlivePlayers())); registerPlaceholder("playersCount", () -> String.valueOf(QSG.game().countAlivePlayers())); @@ -87,8 +93,7 @@ protected void onEnable() } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(ListPlaceholdersCommand.class); } @@ -97,20 +102,17 @@ public List<Class<? extends Command>> getCommands() * * @param placeholderName The name of the placeholder. The module will lookup for {givenName} * in the patterns. - * @param supplier The supplier returning the value to use for this placeholder. + * @param supplier The supplier returning the value to use for this placeholder. */ - public void registerPlaceholder(final String placeholderName, final Supplier<String> supplier) - { + public void registerPlaceholder(final String placeholderName, final Supplier<String> supplier) { placeholderSuppliers.put(placeholderName, supplier); } - public Map<String, Supplier<String>> getPlaceholderSuppliers() - { + public Map<String, Supplier<String>> getPlaceholderSuppliers() { return Collections.unmodifiableMap(placeholderSuppliers); } - private String computeText(String pattern) - { + private String computeText(String pattern) { return pattern.isEmpty() ? "" : ChatColor.translateAlternateColorCodes('&', replaceTags(pattern)); } @@ -118,39 +120,36 @@ private String computeText(String pattern) * @param raw The raw text. * @return The text, with tags replaced using the registered placeholders. */ - private String replaceTags(String raw) - { - for (Map.Entry<String, Supplier<String>> entry : placeholderSuppliers.entrySet()) - { + private String replaceTags(String raw) { + for (Map.Entry<String, Supplier<String>> entry : placeholderSuppliers.entrySet()) { raw = raw.replace("{" + entry.getKey() + "}", entry.getValue().get()); } return raw; } - public void update() - { - if (!isEnabled()) return; // Other modules may keep a reference if the module is disabled. + public void update() { + if (!isEnabled()) { + return; // Other modules may keep a reference if the module is disabled. + } final String headerPattern = Config.HEADERS.get(QSG.game().getPhase()); final String footerPattern = Config.FOOTERS.get(QSG.game().getPhase()); - if ((headerPattern != null && !headerPattern.isEmpty()) || (footerPattern != null && !footerPattern.isEmpty())) - { + if ((headerPattern != null && !headerPattern.isEmpty()) || + (footerPattern != null && !footerPattern.isEmpty())) { final String header = headerPattern != null ? computeText(headerPattern) : ""; final String footer = footerPattern != null ? computeText(footerPattern) : ""; final Stream<? extends Player> receivers; - if (QSG.game().currentPhaseAfter(GamePhase.STARTING)) - { + if (QSG.game().currentPhaseAfter(GamePhase.STARTING)) { receivers = Stream.concat( QSG.game().getAliveConnectedPlayers().stream(), - QSG.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer).filter(Objects::nonNull) + QSG.module(SpectatorsModule.class).getSpectators().stream().map(Bukkit::getPlayer) + .filter(Objects::nonNull) ); - } - else - { + } else { receivers = Bukkit.getOnlinePlayers().stream(); } @@ -158,14 +157,48 @@ public void update() } } - @EventHandler (priority = EventPriority.MONITOR) protected void onGamePhaseChange(final GamePhaseChangedEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerDeath(final AlivePlayerDeathEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerResurrect(final PlayerResurrectedEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onPlayerJoin(final PlayerJoinEvent ev) { update(); } + @EventHandler(priority = EventPriority.MONITOR) + protected void onGamePhaseChange(final GamePhaseChangedEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onPlayerDeath(final AlivePlayerDeathEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onPlayerResurrect(final PlayerResurrectedEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onPlayerJoin(final PlayerJoinEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onTeamsChange(final TeamUpdatedEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onTeamsChange(final TeamRegisteredEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onTeamsChange(final TeamUnregisteredEvent ev) { + update(); + } - @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamUpdatedEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamRegisteredEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final TeamUnregisteredEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final PlayerJoinedTeamEvent ev) { update(); } - @EventHandler (priority = EventPriority.MONITOR) protected void onTeamsChange(final PlayerLeftTeamEvent ev) { update(); } + @EventHandler(priority = EventPriority.MONITOR) + protected void onTeamsChange(final PlayerJoinedTeamEvent ev) { + update(); + } + + @EventHandler(priority = EventPriority.MONITOR) + protected void onTeamsChange(final PlayerLeftTeamEvent ev) { + update(); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java index 4e0182e..5313cda 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/deathAnnouncement/Config.java @@ -48,6 +48,7 @@ public class Config extends ConfigurationInstance { public static final ConfigurationItem<Boolean> LIGHTNING_STRIKE = item("lightning-strike", false); public static final ConfigurationItem<Boolean> PLAY_SOUND = item("play-sound", true); public static final ConfigurationItem<QSGSound> SOUND = item("sound", new QSGSound("ENTITY_WITHER_SPAWN")); + public Config(File file) { super(file); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java index fa332b4..8e555f9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/kick/Config.java @@ -45,6 +45,7 @@ public class Config extends ConfigurationInstance { static public final ConfigurationItem<TimeDelta> DELAY = item("delay", new TimeDelta(30)); static public final ConfigurationItem<String> MESSAGE = item("message", I.t("jayjay")); + public Config(File file) { super(file); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java index 2b0e5ea..3beb655 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/end/xpToKillers/Config.java @@ -43,6 +43,7 @@ public class Config extends ConfigurationInstance { public static final ConfigurationItem<Integer> LEVELS = item("levels", 2); public static final ConfigurationItem<Boolean> ONLY_OTHER_TEAM = item("only-other-team", true); + public Config(File file) { super(file); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java index 3d6bd5c..4fa81cd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/Config.java @@ -31,22 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.dynmap; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<Boolean> SHOW_SPAWN_LOCATIONS = item("show-spawn-locations", true); static public final ConfigurationItem<Boolean> SHOW_DEATH_LOCATIONS = item("show-death-locations", true); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java index 9f113a5..f30b29a 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/dynmap/DynmapModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.dynmap; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -61,7 +62,7 @@ import org.dynmap.markers.MarkerSet; -@ModuleInfo ( +@ModuleInfo( name = "Dynmap", description = "Displays the spawn & death points on the dynmap.", when = ModuleLoadTime.ON_GAME_STARTING, @@ -73,18 +74,15 @@ /* * TODO: add the world border to the map. */ -public class DynmapModule extends QSGModule -{ +public class DynmapModule extends QSGModule { private final DynmapAPI dynmapAPI = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"); private final MarkerAPI markerAPI = dynmapAPI.getMarkerAPI(); private MarkerSet markerSet = null; @Override - protected void onEnable() - { - if (markerAPI == null) - { + protected void onEnable() { + if (markerAPI == null) { log().warning("Dynmap is available, but the markers API is not. The integration was disabled."); QuartzLib.unregisterEvents(this); return; @@ -92,21 +90,16 @@ protected void onEnable() markerSet = markerAPI.getMarkerSet("uhplugin.markerset"); - if (markerSet == null) - { + if (markerSet == null) { markerSet = markerAPI.createMarkerSet("uhplugin.markerset", "UHCReloaded", null, false); - } - else - { + } else { markerSet.setMarkerSetLabel("UHCReloaded"); } } @Override - protected void onDisable() - { - if (markerSet != null) - { + protected void onDisable() { + if (markerSet != null) { markerSet.deleteMarkerSet(); } } @@ -121,10 +114,8 @@ protected void onDisable() * * @param player The player. */ - public void showDeathLocation(final Player player) - { - if (!Config.SHOW_DEATH_LOCATIONS.get()) - { + public void showDeathLocation(final Player player) { + if (!Config.SHOW_DEATH_LOCATIONS.get()) { return; } @@ -142,8 +133,7 @@ public void showDeathLocation(final Player player) icon, false ); - if (marker == null) - { + if (marker == null) { log().warning("Unable to create marker " + markerID); } } @@ -153,15 +143,15 @@ public void showDeathLocation(final Player player) * * @param player The player. */ - public void hideDeathLocation(final OfflinePlayer player) - { - if (!Config.SHOW_DEATH_LOCATIONS.get()) - { + public void hideDeathLocation(final OfflinePlayer player) { + if (!Config.SHOW_DEATH_LOCATIONS.get()) { return; } final Marker marker = markerSet.findMarker(getDeathMarkerName(player)); - if (marker != null) marker.deleteMarker(); + if (marker != null) { + marker.deleteMarker(); + } } /** @@ -170,8 +160,7 @@ public void hideDeathLocation(final OfflinePlayer player) * @param player The player. * @return The ID. */ - private String getDeathMarkerName(final OfflinePlayer player) - { + private String getDeathMarkerName(final OfflinePlayer player) { return "uhplugin.death." + player.getName(); } @@ -184,28 +173,30 @@ private String getDeathMarkerName(final OfflinePlayer player) * Displays the spawn point of the given player. * * <p> - * Used when the teleportation ignores the teams. + * Used when the teleportation ignores the teams. * </p> * - * @param player The player. + * @param player The player. * @param spawnPoint The location of the spawn point. */ - public void showSpawnLocation(final OfflinePlayer player, final Location spawnPoint) - { - if (!Config.SHOW_SPAWN_LOCATIONS.get()) return; - if (player == null) return; + public void showSpawnLocation(final OfflinePlayer player, final Location spawnPoint) { + if (!Config.SHOW_SPAWN_LOCATIONS.get()) { + return; + } + if (player == null) { + return; + } final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); - if (team == null) return; + if (team == null) { + return; + } final String markerLabel; - if (QSG.module(GameModule.class).isTeamsGame() && team.size() > 1) - { + if (QSG.module(GameModule.class).isTeamsGame() && team.size() > 1) { /// Dynmap marker label of a spawn point of a team. markerLabel = I.t("Spawn point of the team {0}", team.getName()); - } - else - { + } else { /// Dynmap marker label of a spawn point of a player, in solo. markerLabel = I.t("Spawn point of {0}", team.getName()); } @@ -222,12 +213,12 @@ public void showSpawnLocation(final OfflinePlayer player, final Location spawnPo * Displays a spawn-point marker. * * @param spawnPoint The location of the spawn. - * @param color The color of the team (for the flag). - * @param label The label of the marker. - * @param markerID The ID of the marker. + * @param color The color of the team (for the flag). + * @param label The label of the marker. + * @param markerID The ID of the marker. */ - private void showSpawnLocation(final Location spawnPoint, final TeamColor color, final String label, final String markerID) - { + private void showSpawnLocation(final Location spawnPoint, final TeamColor color, final String label, + final String markerID) { /* *** Icon *** */ final MarkerIcon icon; @@ -237,8 +228,7 @@ private void showSpawnLocation(final Location spawnPoint, final TeamColor color, // redflag, orangeflag, yellowflag, greenflag, blueflag, purpleflag, pinkflag, pirateflag (black) // Ref. https://github.com/webbukkit/dynmap/wiki/Using-markers - switch (color) - { + switch (color) { case BLUE: case DARK_BLUE: case AQUA: @@ -296,8 +286,7 @@ private void showSpawnLocation(final Location spawnPoint, final TeamColor color, && similarMarker.getMarkerIcon().equals(icon) && similarMarker.getX() == spawnPoint.getX() && similarMarker.getY() == spawnPoint.getY() - && similarMarker.getZ() == spawnPoint.getZ()) - { + && similarMarker.getZ() == spawnPoint.getZ()) { return; } @@ -314,8 +303,7 @@ private void showSpawnLocation(final Location spawnPoint, final TeamColor color, false ); - if (marker == null) - { + if (marker == null) { log().warning("Unable to create marker {0}", markerID); } } @@ -326,8 +314,7 @@ private void showSpawnLocation(final Location spawnPoint, final TeamColor color, * @param player The player. * @return The ID. */ - private String getSpawnMarkerName(final OfflinePlayer player) - { + private String getSpawnMarkerName(final OfflinePlayer player) { return "uhplugin.spawn." + player.getName(); } @@ -336,24 +323,20 @@ private String getSpawnMarkerName(final OfflinePlayer player) /* *** EVENTS INTEGRATION *** */ - @EventHandler (priority = EventPriority.MONITOR) - public void onSpawnPointSelected(final PlayerSpawnPointSelectedEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR) + public void onSpawnPointSelected(final PlayerSpawnPointSelectedEvent ev) { showSpawnLocation(ev.getPlayer(), ev.getSpawnPoint()); } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (ev.getPlayer().isOnline()) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (ev.getPlayer().isOnline()) { showDeathLocation(ev.getPlayer().getPlayer()); } } @EventHandler - public void onPlayerResurrected(final PlayerResurrectedEvent ev) - { + public void onPlayerResurrected(final PlayerResurrectedEvent ev) { hideDeathLocation(ev.getPlayer()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java index 14739d4..0e85f65 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk; import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; @@ -47,68 +48,24 @@ import org.bukkit.Statistic; @SuppressWarnings("CheckStyle") -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<String> REPORTS_API_BASE_URL = item("reports-api-base-url", ""); - public static final ConfigurationItem<Boolean> PUBLISH_REPORT = item("publish-report", true); - public static final ConfigurationItem<ReportBroadcastedTo> BROADCAST_REPORT_TO = item("broadcast-report-to", ReportBroadcastedTo.ALL); - + public static final ConfigurationItem<ReportBroadcastedTo> BROADCAST_REPORT_TO = + item("broadcast-report-to", ReportBroadcastedTo.ALL); static public final ConfigurationItem<Boolean> DATE = item("date", true); static public final ConfigurationItem<Boolean> PLAYERS_COUNT = item("players-count", true); static public final ConfigurationItem<Boolean> WINNERS = item("winners", true); - static public final SummarySection SUMMARY = section("summary", SummarySection.class); - static public class SummarySection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Boolean> HISTORY = item("history", true); - public final ConfigurationItem<Boolean> PLAYERS = item("players", true); - public final ConfigurationItem<Boolean> TEAMS = item("teams", true); - } - - static public final DamagesSection DAMAGES = section("damages", DamagesSection.class); - static public class DamagesSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Boolean> DAMAGES_PER_PLAYERS = item("damages-per-players", true); - public final ConfigurationItem<Boolean> DAMAGES_PER_TEAMS = item("damages-per-teams", true); - public final ConfigurationItem<Boolean> DAMAGES_FROM_ENVIRONMENT = item("damages-from-environment", true); - public final ConfigurationItem<Boolean> DISPLAY_KILLER = item("display-killer", true); - } - - static public final PlayersSection PLAYERS = section("players", PlayersSection.class); - static public class PlayersSection extends ConfigurationSection - { - public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); - public final ConfigurationItem<Boolean> PLAY_TIME = item("play-time", true); - - public final ConfigurationItem<Boolean> GLOBAL_STATISTICS = item("global-statistics", true); - public final ConfigurationList<Statistic> STATISTICS_WHITELIST = list("statistics-whitelist", Statistic.class); - public final ConfigurationList<Statistic> STATISTICS_HIGHLIGHT = list("statistics-highlight", Statistic.class); - public final ConfigurationItem<Boolean> USED = item("used", false); - public final ConfigurationList<Material> USED_WHITELIST = list("used-whitelist", Material.class); - public final ConfigurationList<Material> USED_HIGHLIGHT = list("used-highlight", Material.class); - public final ConfigurationItem<Boolean> MINED = item("mined", true); - public final ConfigurationList<Material> MINED_WHITELIST = list("mined-whitelist", Material.class); - public final ConfigurationList<Material> MINED_HIGHLIGHT = list("mined-highlight", Material.class); - - public final ConfigurationItem<Boolean> PICKED_UP = item("picked-up", true); - public final ConfigurationList<Material> PICKED_UP_WHITELIST = list("picked-up-whitelist", Material.class); - public final ConfigurationList<Material> PICKED_UP_HIGHLIGHT = list("picked-up-highlight", Material.class); + public Config(File file) { + super(file); } - static public List<Statistic> defaultStatsHighlight() - { + static public List<Statistic> defaultStatsHighlight() { return Arrays.asList( Statistic.DAMAGE_DEALT, Statistic.CRAFT_ITEM, @@ -118,20 +75,19 @@ static public List<Statistic> defaultStatsHighlight() ); } - static public List<Material> defaultUsedHighlight() - { + static public List<Material> defaultUsedHighlight() { return Arrays.asList( Material.DIAMOND_SWORD, Material.DIAMOND_AXE, Material.DIAMOND_PICKAXE, Material.DIAMOND_HOE, Material.IRON_SWORD, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_HOE, Material.CAKE, Material.SADDLE, Material.GOLDEN_APPLE, Material.POTION, Material.MUSIC_DISC_11, Material.MUSIC_DISC_13, Material.MUSIC_DISC_BLOCKS, Material.MUSIC_DISC_CAT, - Material.MUSIC_DISC_CHIRP, Material.MUSIC_DISC_FAR, Material.MUSIC_DISC_MALL, Material.MUSIC_DISC_MELLOHI, + Material.MUSIC_DISC_CHIRP, Material.MUSIC_DISC_FAR, Material.MUSIC_DISC_MALL, + Material.MUSIC_DISC_MELLOHI, Material.MUSIC_DISC_STAL, Material.MUSIC_DISC_STRAD, Material.MUSIC_DISC_WAIT, Material.MUSIC_DISC_WARD ); } - static public List<Material> defaultMinedHighlight() - { + static public List<Material> defaultMinedHighlight() { return Arrays.asList( Material.DIAMOND, Material.DIAMOND_ORE, Material.GOLD_INGOT, Material.GOLD_ORE, @@ -142,8 +98,7 @@ static public List<Material> defaultMinedHighlight() ); } - static public List<Material> defaultPickedUpHighlight() - { + static public List<Material> defaultPickedUpHighlight() { return Arrays.asList( Material.APPLE, Material.BOW, Material.ENDER_PEARL, Material.GOLD_INGOT, @@ -152,10 +107,45 @@ static public List<Material> defaultPickedUpHighlight() ); } - public enum ReportBroadcastedTo - { + public enum ReportBroadcastedTo { ALL, ADMINISTRATORS, CONSOLE } + + static public class SummarySection extends ConfigurationSection { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> HISTORY = item("history", true); + public final ConfigurationItem<Boolean> PLAYERS = item("players", true); + public final ConfigurationItem<Boolean> TEAMS = item("teams", true); + } + + static public class DamagesSection extends ConfigurationSection { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> DAMAGES_PER_PLAYERS = item("damages-per-players", true); + public final ConfigurationItem<Boolean> DAMAGES_PER_TEAMS = item("damages-per-teams", true); + public final ConfigurationItem<Boolean> DAMAGES_FROM_ENVIRONMENT = item("damages-from-environment", true); + public final ConfigurationItem<Boolean> DISPLAY_KILLER = item("display-killer", true); + } + + static public class PlayersSection extends ConfigurationSection { + public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); + public final ConfigurationItem<Boolean> PLAY_TIME = item("play-time", true); + + public final ConfigurationItem<Boolean> GLOBAL_STATISTICS = item("global-statistics", true); + public final ConfigurationList<Statistic> STATISTICS_WHITELIST = list("statistics-whitelist", Statistic.class); + public final ConfigurationList<Statistic> STATISTICS_HIGHLIGHT = list("statistics-highlight", Statistic.class); + + public final ConfigurationItem<Boolean> USED = item("used", false); + public final ConfigurationList<Material> USED_WHITELIST = list("used-whitelist", Material.class); + public final ConfigurationList<Material> USED_HIGHLIGHT = list("used-highlight", Material.class); + + public final ConfigurationItem<Boolean> MINED = item("mined", true); + public final ConfigurationList<Material> MINED_WHITELIST = list("mined-whitelist", Material.class); + public final ConfigurationList<Material> MINED_HIGHLIGHT = list("mined-highlight", Material.class); + + public final ConfigurationItem<Boolean> PICKED_UP = item("picked-up", true); + public final ConfigurationList<Material> PICKED_UP_WHITELIST = list("picked-up-whitelist", Material.class); + public final ConfigurationList<Material> PICKED_UP_HIGHLIGHT = list("picked-up-highlight", Material.class); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java index 45d9378..9d5191d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.hawk; import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; @@ -45,8 +46,8 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.players.PlayerResurrectedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads.GoldenHeadsModule; -import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; import fr.zcraft.quartzlib.components.events.FutureEventHandler; import fr.zcraft.quartzlib.components.events.WrappedEvent; import fr.zcraft.quartzlib.components.gui.GuiUtils; @@ -58,13 +59,28 @@ import fr.zcraft.quartzlib.tools.text.RawMessage; import fr.zcraft.quartzteams.QuartzTeam; import fr.zcraft.quartzteams.QuartzTeams; -import fr.zcraft.quartzteams.events.*; +import fr.zcraft.quartzteams.events.PlayerJoinedTeamEvent; +import fr.zcraft.quartzteams.events.PlayerLeftTeamEvent; +import fr.zcraft.quartzteams.events.TeamRegisteredEvent; +import fr.zcraft.quartzteams.events.TeamUnregisteredEvent; +import fr.zcraft.quartzteams.events.TeamUpdatedEvent; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import me.cassayre.florian.hawk.ReportsManager; import me.cassayre.florian.hawk.report.InvalidReportException; import me.cassayre.florian.hawk.report.Report; import me.cassayre.florian.hawk.report.ReportEvent; import me.cassayre.florian.hawk.report.ReportTeam; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.SkullType; +import org.bukkit.World; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -79,14 +95,8 @@ import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.scheduler.BukkitTask; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -@ModuleInfo ( +@ModuleInfo( name = "Hawk Reports", description = "Generates reports of the game, including history, damages, " + "heals, statistics, etc., displayed on a web page, and gives the URL " + @@ -98,8 +108,7 @@ settings = Config.class, can_be_unloaded = false ) -public class HawkModule extends QSGModule -{ +public class HawkModule extends QSGModule { private GameModule game; private Report report; @@ -128,38 +137,36 @@ public class HawkModule extends QSGModule * (like final cross-kill, or fire-kill from fire aspect…). */ private BukkitTask waitAfterEndTask = null; - private TimeDelta waitAfterEndDelay = new TimeDelta(30); + private final TimeDelta waitAfterEndDelay = new TimeDelta(30); private boolean waitingAfterEnd = false; @Override - protected void onEnable() - { + protected void onEnable() { game = QSG.module(GameModule.class); ReportsManager.init(QSG.get()); - if (!Config.REPORTS_API_BASE_URL.get().isEmpty()) - { + if (!Config.REPORTS_API_BASE_URL.get().isEmpty()) { ReportsManager.get().setRemoteInstanceURL(Config.REPORTS_API_BASE_URL.get()); } report = new Report() - .selfRegister() - .autoTrack(true) - .stopTrackOnDisconnection(false) + .selfRegister() + .autoTrack(true) + .stopTrackOnDisconnection(false) - // We'll manage theses ourselves. - .stopTrackOnDeath(false) - .autoTrackNewPlayers(false) - .addDefaultEvents(false) + // We'll manage theses ourselves. + .stopTrackOnDeath(false) + .autoTrackNewPlayers(false) + .addDefaultEvents(false) - .autoCollectPreviousStatistics(true) - .registerPlayers(game.getAlivePlayers()) + .autoCollectPreviousStatistics(true) + .registerPlayers(game.getAlivePlayers()) - .title(QSGConfig.TITLE.get()) + .title(QSGConfig.TITLE.get()) - .settings() + .settings() .displayDate(Config.DATE.get()) .displayPlayersCount(Config.PLAYERS_COUNT.get()) .displayWinners(Config.WINNERS.get()) @@ -209,41 +216,45 @@ protected void onEnable() "UHC Reloaded", "https://www.spigotmc.org/resources/ultrahardcore-reloaded.1622/" ) - .done(); + .done(); - if (!Config.SUMMARY.ENABLED.get()) report.settings().disableSummary(); - if (!Config.DAMAGES.ENABLED.get()) report.settings().disableDamages(); - if (!Config.PLAYERS.ENABLED.get()) report.settings().disablePlayers(); + if (!Config.SUMMARY.ENABLED.get()) { + report.settings().disableSummary(); + } + if (!Config.DAMAGES.ENABLED.get()) { + report.settings().disableDamages(); + } + if (!Config.PLAYERS.ENABLED.get()) { + report.settings().disablePlayers(); + } updateReportTeams(); RunTask.nextTick(() -> log().info("The reports tracker started successfully.")); } - public Report getReport() - { + public Report getReport() { return report; } - private void updateReportTeams() - { + private void updateReportTeams() { report.resetTeams(); - if (game.isTeamsGame()) - { + if (game.isTeamsGame()) { QuartzTeams.get().getTeams().stream() - .map(team -> new ReportTeam(team.getName(), team.getColor() != null ? team.getColor().toChatColor() : null, team.getPlayers())) + .map(team -> new ReportTeam(team.getName(), + team.getColor() != null ? team.getColor().toChatColor() : null, team.getPlayers())) .forEach(report::registerTeam); } } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onGamePhaseChanged(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.END) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onGamePhaseChanged(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.END) { final QuartzTeam winner = game.getWinner(); - if (winner != null) report.setWinners(winner.getPlayers()); + if (winner != null) { + report.setWinners(winner.getPlayers()); + } waitingAfterEnd = true; @@ -254,127 +265,130 @@ public void onGamePhaseChanged(final GamePhaseChangedEvent ev) report.autoTrack(false).title(QSGConfig.TITLE.get()); report.save( - saved -> - PluginLogger.info("The JSON report for this game has been written to {0}.", saved.getAbsolutePath()), - error -> - PluginLogger.error("Unable to save the JSON report for this game to the disk. There were backups, you may be lucky and find something there. If configured to do so, the report will still be published.", error) + saved -> + PluginLogger.info("The JSON report for this game has been written to {0}.", + saved.getAbsolutePath()), + error -> + PluginLogger + .error("Unable to save the JSON report for this game to the disk. There were backups, you may be lucky and find something there. If configured to do so, the report will still be published.", + error) ); - if (!Config.PUBLISH_REPORT.get()) return; + if (!Config.PUBLISH_REPORT.get()) { + return; + } report.publish( - uri -> { - switch (Config.BROADCAST_REPORT_TO.get()) - { - case ALL: - Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); - - Bukkit.broadcastMessage("\n " + GuiUtils.generatePrefixedFixedLengthString( - " ", - I.t("{aqua}{bold}Want a summary?") + ChatColor.RESET + "\n" + - I.t("{darkaqua}Click the link below to see (and share, if you want) the game timeline, events, damages summary, and other statistics!") - )); - - Bukkit.broadcastMessage(""); - - RawMessage.broadcast( - new RawText(" ").hover(I.t("Open {aqua}{0}", uri.toString())) - .then("»").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) - .then(" ").uri(uri) - .then(uri.toString()).style(ChatColor.AQUA).uri(uri) - .then(" ").uri(uri) - .then("«").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) - .build() - ); - - Bukkit.broadcastMessage(""); - Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); - - break; - - case ADMINISTRATORS: - log().broadcastAdministrative(""); - log().broadcastAdministrative(I.t("{darkaqua}{bold}A game report was generated")); - log().broadcastAdministrative(I.t("{darkaqua}You can share it using the following URL. It was not broadcast to other players.")); - log().broadcastAdministrative(""); - - log().broadcastAdministrative( - new RawText().uri(uri).hover(I.t("Open {aqua}{0}", uri.toString())) - .then("» ").style(ChatColor.DARK_AQUA, ChatColor.BOLD) - .then(uri.toString()).style(ChatColor.AQUA) - .build() - ); - - log().broadcastAdministrative(""); - break; - - case CONSOLE: - log().info("A game report was generated. You can share it using the following URL: {0} .", uri); - break; - } - }, - error -> { - final String message; - - if (error instanceof IOException) - { - message = I.t("I/O Error: {0}", error.getLocalizedMessage()); + uri -> { + switch (Config.BROADCAST_REPORT_TO.get()) { + case ALL: + Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); + + Bukkit.broadcastMessage("\n " + GuiUtils.generatePrefixedFixedLengthString( + " ", + I.t("{aqua}{bold}Want a summary?") + ChatColor.RESET + "\n" + + I.t("{darkaqua}Click the link below to see (and share, if you want) the game timeline, events, damages summary, and other statistics!") + )); + + Bukkit.broadcastMessage(""); + + RawMessage.broadcast( + new RawText(" ").hover(I.t("Open {aqua}{0}", uri.toString())) + .then("»").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) + .then(" ").uri(uri) + .then(uri.toString()).style(ChatColor.AQUA).uri(uri) + .then(" ").uri(uri) + .then("«").style(ChatColor.DARK_AQUA, ChatColor.BOLD).uri(uri) + .build() + ); + + Bukkit.broadcastMessage(""); + Bukkit.getOnlinePlayers().forEach(CommandUtils::displaySeparator); + + break; + + case ADMINISTRATORS: + log().broadcastAdministrative(""); + log().broadcastAdministrative(I.t("{darkaqua}{bold}A game report was generated")); + log().broadcastAdministrative( + I.t("{darkaqua}You can share it using the following URL. It was not broadcast to other players.")); + log().broadcastAdministrative(""); + + log().broadcastAdministrative( + new RawText().uri(uri).hover(I.t("Open {aqua}{0}", uri.toString())) + .then("» ").style(ChatColor.DARK_AQUA, ChatColor.BOLD) + .then(uri.toString()).style(ChatColor.AQUA) + .build() + ); + + log().broadcastAdministrative(""); + break; + + case CONSOLE: + log().info( + "A game report was generated. You can share it using the following URL: {0} .", + uri); + break; + } + }, + error -> { + final String message; + + if (error instanceof IOException) { + message = I.t("I/O Error: {0}", error.getLocalizedMessage()); + } else if (error instanceof InvalidReportException) { + message = I.t("Invalid Report: {0} ({1})", error.getMessage(), + ((InvalidReportException) error).getCode()); + } else { + message = error.getMessage(); + } + + log().broadcastAdministrative(""); + log().broadcastAdministrative(I.t("{red}{bold}Unable to publish the game report")); + log().broadcastAdministrative(ChatColor.RED + message); + log().broadcastAdministrative(""); } - else if (error instanceof InvalidReportException) - { - message = I.t("Invalid Report: {0} ({1})", error.getMessage(), ((InvalidReportException) error).getCode()); - } - else message = error.getMessage(); - - log().broadcastAdministrative(""); - log().broadcastAdministrative(I.t("{red}{bold}Unable to publish the game report")); - log().broadcastAdministrative(ChatColor.RED + message); - log().broadcastAdministrative(""); - } ); }, waitAfterEndDelay.getSeconds() * 20L); - } - else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) - { + } else if (ev.getNewPhase() == GamePhase.IN_GAME && !ev.isRunningForward()) { report.resetWinners(); report.autoTrack(true); waitingAfterEnd = false; - if (waitAfterEndTask != null) - { + if (waitAfterEndTask != null) { waitAfterEndTask.cancel(); waitAfterEndTask = null; } } } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { report - .untrack(ev.getPlayer()) - .record(ReportEvent.withPlayer( - ReportEvent.EventType.GOLD, - /// Title of the death event on the game report's timeline. - I.t("Death of {0}", ev.getPlayer().getName()), - ev.getPlayerDeathEvent() != null - && ev.getPlayerDeathEvent().getDeathMessage() != null - && !ev.getPlayerDeathEvent().getDeathMessage().isEmpty() - ? ev.getPlayerDeathEvent().getDeathMessage() - : null, - ev.getPlayer() - )); + .untrack(ev.getPlayer()) + .record(ReportEvent.withPlayer( + ReportEvent.EventType.GOLD, + /// Title of the death event on the game report's timeline. + I.t("Death of {0}", ev.getPlayer().getName()), + ev.getPlayerDeathEvent() != null + && ev.getPlayerDeathEvent().getDeathMessage() != null + && !ev.getPlayerDeathEvent().getDeathMessage().isEmpty() + ? ev.getPlayerDeathEvent().getDeathMessage() + : null, + ev.getPlayer() + )); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerDeath(final PlayerDeathEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(final PlayerDeathEvent ev) { // Recording cross-kills and other deaths after the game end (e.g. from fire) // during a 30-seconds period. - if (!waitingAfterEnd) return; + if (!waitingAfterEnd) { + return; + } report .untrack(ev.getEntity()) @@ -387,61 +401,81 @@ public void onPlayerDeath(final PlayerDeathEvent ev) )); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerResurrected(final PlayerResurrectedEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerResurrected(final PlayerResurrectedEvent ev) { report - .track(ev.getPlayer()) - .record(ReportEvent.withPlayer( - ReportEvent.EventType.GREEN, - /// Title of the resurrection event on the game report's timeline. - I.t("{0} was resurrected", ev.getPlayer().getName()), - ev.getPlayer() - )); + .track(ev.getPlayer()) + .record(ReportEvent.withPlayer( + ReportEvent.EventType.GREEN, + /// Title of the resurrection event on the game report's timeline. + I.t("{0} was resurrected", ev.getPlayer().getName()), + ev.getPlayer() + )); updateReportTeams(); } - @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamUpdatedEvent ev) { updateReportTeams(); } - @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamRegisteredEvent ev) { updateReportTeams(); } - @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final TeamUnregisteredEvent ev) { updateReportTeams(); } - @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final PlayerJoinedTeamEvent ev) { updateReportTeams(); } - @EventHandler (priority = EventPriority.MONITOR) public void onTeamsChange(final PlayerLeftTeamEvent ev) { updateReportTeams(); } + @EventHandler(priority = EventPriority.MONITOR) + public void onTeamsChange(final TeamUpdatedEvent ev) { + updateReportTeams(); + } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onFirstEnchant(final EnchantItemEvent ev) - { - if (firstEnchant || !game.isAlive(ev.getEnchanter())) return; + @EventHandler(priority = EventPriority.MONITOR) + public void onTeamsChange(final TeamRegisteredEvent ev) { + updateReportTeams(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTeamsChange(final TeamUnregisteredEvent ev) { + updateReportTeams(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTeamsChange(final PlayerJoinedTeamEvent ev) { + updateReportTeams(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTeamsChange(final PlayerLeftTeamEvent ev) { + updateReportTeams(); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFirstEnchant(final EnchantItemEvent ev) { + if (firstEnchant || !game.isAlive(ev.getEnchanter())) { + return; + } report.record(ReportEvent.withIcon( - I.t("{0} enchants the first tool", ev.getEnchanter().getName()), - "item-book-enchanted" + I.t("{0} enchants the first tool", ev.getEnchanter().getName()), + "item-book-enchanted" )); firstEnchant = true; } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBrewingStandUsed(final PlayerInteractEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBrewingStandUsed(final PlayerInteractEvent ev) { if (firstBrew || !game.isAlive(ev.getPlayer()) || !ev.hasBlock() || ev.getAction() != Action.RIGHT_CLICK_BLOCK - || ev.getClickedBlock().getType() != Material.BREWING_STAND) - { + || ev.getClickedBlock().getType() != Material.BREWING_STAND) { return; } lastBrewingStandUsers.put(ev.getClickedBlock().getLocation(), ev.getPlayer().getUniqueId()); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onFirstBrew(final BrewEvent ev) - { - if (firstBrew) return; + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onFirstBrew(final BrewEvent ev) { + if (firstBrew) { + return; + } final UUID player = lastBrewingStandUsers.get(ev.getBlock().getLocation()); - if (player == null) return; + if (player == null) { + return; + } report.record(ReportEvent.withIcon( I.t("{0} brewed the first potion", Bukkit.getOfflinePlayer(player).getName()), @@ -454,32 +488,26 @@ public void onFirstBrew(final BrewEvent ev) lastBrewingStandUsers = null; } - private void onFirstItemCollected(final Material item, final OfflinePlayer player) - { - if (!game.isAlive(player)) return; + private void onFirstItemCollected(final Material item, final OfflinePlayer player) { + if (!game.isAlive(player)) { + return; + } - if (!firstDiamond && (item == Material.DIAMOND || item == Material.DIAMOND_ORE)) - { + if (!firstDiamond && (item == Material.DIAMOND || item == Material.DIAMOND_ORE)) { report.record(ReportEvent.withIcon( I.t("{0} finds the first diamond", player.getName()), "item-diamond" )); firstDiamond = true; - } - - else if (!firstGold && (item == Material.GOLD_INGOT || item == Material.GOLD_ORE)) - { + } else if (!firstGold && (item == Material.GOLD_INGOT || item == Material.GOLD_ORE)) { report.record(ReportEvent.withIcon( I.t("{0} finds the first gold ingot", player.getName()), "item-gold-ingot" )); firstGold = true; - } - - else if (!firstApple && item == Material.APPLE) - { + } else if (!firstApple && item == Material.APPLE) { report.record(ReportEvent.withIcon( I.t("{0} harvested the first apple", player.getName()), "item-apple" @@ -498,50 +526,44 @@ else if (!firstApple && item == Material.APPLE) * The event will be called twice on intermediate versions, but the flag will ensure only * one event will be recorded for each item. */ - @FutureEventHandler (event = "entity.PlayerPickupItemEvent", priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onOldFirstItemCollected(final WrappedEvent ev) - { - try - { + @FutureEventHandler(event = "entity.PlayerPickupItemEvent", priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onOldFirstItemCollected(final WrappedEvent ev) { + try { onFirstItemCollected( ((Item) Reflection.call(ev.getEvent(), "getItem")).getItemStack().getType(), ((Player) Reflection.call(ev.getEvent(), "getPlayer")) ); } - catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) - { + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { PluginLogger.error("Unable to retrieve picked-up item to build the report. Will be ignored.", e); } } @FutureEventHandler(event = "entity.EntityPickupItemEvent", priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onFirstItemCollected(final WrappedEvent ev) - { - try - { + public void onFirstItemCollected(final WrappedEvent ev) { + try { LivingEntity entity = (LivingEntity) Reflection.call(ev.getEvent(), "getEntity"); - if (entity instanceof Player) - { + if (entity instanceof Player) { onFirstItemCollected( ((Item) Reflection.call(ev.getEvent(), "getItem")).getItemStack().getType(), (Player) entity ); } } - catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) - { + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { PluginLogger.error("Unable to retrieve picked-up item to build the report. Will be ignored.", e); } } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onWorldChange(final PlayerChangedWorldEvent ev) - { - if (!game.isAlive(ev.getPlayer())) return; + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onWorldChange(final PlayerChangedWorldEvent ev) { + if (!game.isAlive(ev.getPlayer())) { + return; + } - if (!firstNether && ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.NETHER).getName())) - { + if (!firstNether && + ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.NETHER).getName())) { report.record(ReportEvent.withIcon( ReportEvent.EventType.RED, I.t("{0} enters first the Nether", ev.getPlayer().getName()), @@ -549,10 +571,8 @@ public void onWorldChange(final PlayerChangedWorldEvent ev) )); firstNether = true; - } - - else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.THE_END).getName())) - { + } else if (!firstEnd && + ev.getPlayer().getWorld().getName().equals(QSG.get().getWorld(World.Environment.THE_END).getName())) { report.record(ReportEvent.withIcon( I.t("{0} enters first The End", ev.getPlayer().getName()), "block-endframe" @@ -562,26 +582,24 @@ else if (!firstEnd && ev.getPlayer().getWorld().getName().equals(QSG.get().getWo } } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onItemConsumed(final PlayerItemConsumeEvent ev) - { - if (!game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onItemConsumed(final PlayerItemConsumeEvent ev) { + if (!game.isAlive(ev.getPlayer()) || ev.getItem().getType() != Material.GOLDEN_APPLE) { return; + } - final SkullType headType = QSG.loaded(GoldenHeadsModule.class) ? QSG.module(GoldenHeadsModule.class).readHeadType(ev.getItem()) : null; + final SkullType headType = + QSG.loaded(GoldenHeadsModule.class) ? QSG.module(GoldenHeadsModule.class).readHeadType(ev.getItem()) : + null; - if (headType == SkullType.PLAYER && !firstGoldenHead) - { + if (headType == SkullType.PLAYER && !firstGoldenHead) { report.record(ReportEvent.withIcon( I.t("{0} ate the first golden head", ev.getPlayer().getName()), "item-apple-golden" )); firstGoldenHead = true; - } - - else if (!firstGoldenApple) - { + } else if (!firstGoldenApple) { report.record(ReportEvent.withIcon( I.t("{0} ate the first golden apple", ev.getPlayer().getName()), "item-apple-golden" diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java index e8da4a9..be7b94f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/Config.java @@ -31,22 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.motd; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<Boolean> DISPLAY_MATCH_NAME = item("display-match-name", true); static public final ConfigurationItem<String> MATCH_NAME_PREFIX = item("match-name-prefix", ""); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java index d6e2318..f87d182 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/motd/MotdModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.external.motd; import eu.carrade.amaury.quartzsurvivalgames.QSGConfig; @@ -47,34 +48,28 @@ import org.bukkit.event.server.ServerListPingEvent; -@ModuleInfo ( +@ModuleInfo( name = "MOTD", description = "Updates the MOTD according to the current game state.", category = ModuleCategory.EXTERNAL, icon = Material.DARK_OAK_SIGN, settings = Config.class ) -public class MotdModule extends QSGModule -{ +public class MotdModule extends QSGModule { private final GameModule game = QSG.module(GameModule.class); - private String getMOTD() - { + private String getMOTD() { final String matchName; - if (Config.DISPLAY_MATCH_NAME.get()) - { + if (Config.DISPLAY_MATCH_NAME.get()) { matchName = ChatColor.translateAlternateColorCodes('&', Config.MATCH_NAME_PREFIX.get()) - + QSGConfig.TITLE.get() - + ChatColor.RESET + "\n"; - } - else - { + + QSGConfig.TITLE.get() + + ChatColor.RESET + "\n"; + } else { matchName = ""; } - switch (game.getPhase()) - { + switch (game.getPhase()) { case WAIT: return matchName + I.t("Waiting for players..."); @@ -82,37 +77,35 @@ private String getMOTD() return matchName + I.t("Starting in progress..."); case IN_GAME: - if (game.isTeamsGame()) - { + if (game.isTeamsGame()) { /// Teams game running MOTD. {0} = players alive count. {1} = teams alive count. Plural based on players count. - return matchName + I.tn("Game running! {0} player alive in {1} team.", "Game running! {0} players alive in {1} teams.", game.countAlivePlayers(), game.countAlivePlayers(), game.countAliveTeams()); - } - else - { + return matchName + I.tn("Game running! {0} player alive in {1} team.", + "Game running! {0} players alive in {1} teams.", game.countAlivePlayers(), + game.countAlivePlayers(), game.countAliveTeams()); + } else { /// Solo game running MOTD. {0} = players alive count. - return matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", game.countAlivePlayers()); + return matchName + I.tn("Game running! {0} player alive.", "Game running! {0} players alive.", + game.countAlivePlayers()); } case END: default: final QuartzTeam winner = game.getWinner(); - if (game.isTeamsGame()) - { + if (game.isTeamsGame()) { /// Game finished MOTD with team winner ({0} = team display name). - return matchName + I.t("Game finished; the team {0} wins this match!", winner != null ? winner.getDisplayName() : "??"); - } - else - { + return matchName + I.t("Game finished; the team {0} wins this match!", + winner != null ? winner.getDisplayName() : "??"); + } else { /// Game finished MOTD with solo winner ({0} = winner raw name). - return matchName + I.t("Game finished; congratulation to {0} for his victory!", winner != null ? winner.getName() : "??"); + return matchName + I.t("Game finished; congratulation to {0} for his victory!", + winner != null ? winner.getName() : "??"); } } } @EventHandler - public void onServerListPing(final ServerListPingEvent ev) - { + public void onServerListPing(final ServerListPingEvent ev) { ev.setMotd(getMOTD()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java index 04a7ba3..46f0b2b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoEnderPearlDamagesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -43,20 +44,17 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -@ModuleInfo ( +@ModuleInfo( name = "No Ender Pearl Damages", description = "Removes all damages from ender pearls, basically allowing players to use them.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, icon = Material.ENDER_PEARL ) -public class NoEnderPearlDamagesModule extends QSGModule -{ +public class NoEnderPearlDamagesModule extends QSGModule { @EventHandler(ignoreCancelled = true) - public void onPlayerTeleport(final PlayerTeleportEvent ev) - { - if (ev.getCause() == TeleportCause.ENDER_PEARL) - { + public void onPlayerTeleport(final PlayerTeleportEvent ev) { + if (ev.getCause() == TeleportCause.ENDER_PEARL) { ev.setCancelled(true); // Technically its an ender pearl teleportation, but diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java index 814976b..8fd0c7d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoGhastTearsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -39,6 +40,8 @@ import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Material; import org.bukkit.entity.Ghast; import org.bukkit.event.EventHandler; @@ -46,10 +49,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.List; - -@ModuleInfo ( +@ModuleInfo( name = "No Ghast Tears", description = "Replaces ghast tears with gold, to disable regeneration " + "potions while keeping a reward for the action.", @@ -57,27 +57,20 @@ category = ModuleCategory.GAMEPLAY, icon = Material.GHAST_TEAR ) -public class NoGhastTearsModule extends QSGModule -{ +public class NoGhastTearsModule extends QSGModule { /** * Used to replace ghast tears with gold (if needed). */ @EventHandler(ignoreCancelled = true) - public void onEntityDeath(EntityDeathEvent ev) - { - if (ev.getEntity() instanceof Ghast) - { + public void onEntityDeath(EntityDeathEvent ev) { + if (ev.getEntity() instanceof Ghast) { final List<ItemStack> drops = new ArrayList<>(ev.getDrops()); ev.getDrops().clear(); - for (final ItemStack i : drops) - { - if (i.getType() == Material.GHAST_TEAR) - { + for (final ItemStack i : drops) { + if (i.getType() == Material.GHAST_TEAR) { ev.getDrops().add(new ItemStack(Material.GOLD_INGOT, i.getAmount())); - } - else - { + } else { ev.getDrops().add(i); } } @@ -87,11 +80,10 @@ public void onEntityDeath(EntityDeathEvent ev) /** * Used to prevent the user to get a ghast tear. */ - @EventHandler (ignoreCancelled = true) - public void onPlayerPickupItem(PlayerPickupItemEvent ev) - { - if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR && QSG.module(GameModule.class).isAlive(ev.getPlayer())) - { + @EventHandler(ignoreCancelled = true) + public void onPlayerPickupItem(PlayerPickupItemEvent ev) { + if (ev.getItem().getItemStack().getType() == Material.GHAST_TEAR && + QSG.module(GameModule.class).isAlive(ev.getPlayer())) { ev.setCancelled(true); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java index ab58833..d491df6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -46,15 +47,14 @@ import org.bukkit.inventory.Recipe; -@ModuleInfo ( +@ModuleInfo( name = "Onerous Glistering Melon", description = "Changes the vanilla recipe for glistering melon, replacing gold nuggets by gold ingots, to make healing potions harder to get.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, icon = Material.GLISTERING_MELON_SLICE // FIXME 1.13 ) -public class OnerousGlisteringMelon extends QSGModule -{ +public class OnerousGlisteringMelon extends QSGModule { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( new ItemStack(Material.GLISTERING_MELON_SLICE), "AAA", @@ -72,16 +72,13 @@ public class OnerousGlisteringMelon extends QSGModule ); @Override - protected void onEnable() - { + protected void onEnable() { CraftingRecipes.add(ONEROUS_RECIPE); } @EventHandler - private void onPreCraft(final PrepareItemCraftEvent ev) - { - if (RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) - { + private void onPreCraft(final PrepareItemCraftEvent ev) { + if (RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) { ev.getInventory().setResult(new ItemStack(Material.AIR)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java index 806d05f..bef2525 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -48,6 +49,12 @@ import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.MessageSender; import fr.zcraft.quartzteams.QuartzTeams; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Locale; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; import org.apache.commons.lang.math.RandomUtils; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -59,9 +66,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import java.util.*; - -@ModuleInfo ( +@ModuleInfo( name = "Compass", description = "Compasses in the game can be used to point to the nearest player, " + "and/or give the distance to them, at a configurable fee. The compass' craft " + @@ -71,24 +76,20 @@ icon = Material.COMPASS, settings = Config.class ) -public class CompassModule extends QSGModule -{ +public class CompassModule extends QSGModule { private CompassRecipes recipes = null; - private Set<UUID> compassLocked = new HashSet<>(); + private final Set<UUID> compassLocked = new HashSet<>(); @Override - public void onEnable() - { + public void onEnable() { recipes = QuartzLib.loadComponent(CompassRecipes.class); } @Override - protected void onDisable() - { - if (recipes != null) - { + protected void onDisable() { + if (recipes != null) { QuartzLib.unregisterEvents(recipes); recipes = null; } @@ -97,18 +98,15 @@ protected void onDisable() /** * Used to update the compass. */ - @EventHandler (priority = EventPriority.LOWEST) - public void onPlayerInteract(final PlayerInteractEvent ev) - { - if (ev.getAction() != Action.PHYSICAL) - { + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerInteract(final PlayerInteractEvent ev) { + if (ev.getAction() != Action.PHYSICAL) { ev.setCancelled(activateCompass(ev.getPlayer())); } } @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev) - { + public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev) { ev.setCancelled(activateCompass(ev.getPlayer())); } @@ -118,10 +116,13 @@ public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev) * @param compassUser The player. * @return {@code true} if the compass was activated. */ - private boolean activateCompass(final Player compassUser) - { - if (!QSG.game().isAlive(compassUser) || compassUser.getItemInHand().getType() != Material.COMPASS) return false; - if (compassLocked.contains(compassUser.getUniqueId())) return false; + private boolean activateCompass(final Player compassUser) { + if (!QSG.game().isAlive(compassUser) || compassUser.getItemInHand().getType() != Material.COMPASS) { + return false; + } + if (compassLocked.contains(compassUser.getUniqueId())) { + return false; + } compassLocked.add(compassUser.getUniqueId()); RunTask.later(() -> compassLocked.remove(compassUser.getUniqueId()), 10L); @@ -135,13 +136,15 @@ private boolean activateCompass(final Player compassUser) .mapToInt(ItemStack::getAmount) .sum(); - if (feeAvailable < Config.COMPASS_FEE_AMOUNT.get()) - { + if (feeAvailable < Config.COMPASS_FEE_AMOUNT.get()) { MessageSender.sendActionBarMessage(compassUser, new RawText() /// The singular is in the sentence « To use the compass, you must have one rotten flesh ». The plural: « […] you must have Rotten Flesh × 2 »? - .then(I.tln(locale, "To use the compass, you must have one ", "To use the compass, you must have ", Config.COMPASS_FEE_AMOUNT.get())).color(ChatColor.RED) - .then().translate(new ItemStack(Config.COMPASS_FEE_ITEM.get(), Config.COMPASS_FEE_AMOUNT.get())).color(ChatColor.RED) - .then(Config.COMPASS_FEE_AMOUNT.get() > 1 ? " × " + Config.COMPASS_FEE_AMOUNT.get() : "").color(ChatColor.RED) + .then(I.tln(locale, "To use the compass, you must have one ", "To use the compass, you must have ", + Config.COMPASS_FEE_AMOUNT.get())).color(ChatColor.RED) + .then().translate(new ItemStack(Config.COMPASS_FEE_ITEM.get(), Config.COMPASS_FEE_AMOUNT.get())) + .color(ChatColor.RED) + .then(Config.COMPASS_FEE_AMOUNT.get() > 1 ? " × " + Config.COMPASS_FEE_AMOUNT.get() : "") + .color(ChatColor.RED) .then(".").color(ChatColor.RED) .build() ); @@ -153,25 +156,22 @@ private boolean activateCompass(final Player compassUser) int feeLeft = Config.COMPASS_FEE_AMOUNT.get(); - for (final ItemStack item : compassUser.getInventory().getContents()) - { - if (item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) - { + for (final ItemStack item : compassUser.getInventory().getContents()) { + if (item != null && item.getType() == Config.COMPASS_FEE_ITEM.get()) { final int consumed = item.getAmount() - feeLeft; - if (consumed <= 0) - { + if (consumed <= 0) { feeLeft -= item.getAmount(); item.setAmount(0); item.setType(Material.AIR); - } - else - { + } else { feeLeft = 0; item.setAmount(consumed); } - if (feeLeft == 0) break; + if (feeLeft == 0) { + break; + } } } @@ -180,30 +180,30 @@ private boolean activateCompass(final Player compassUser) Player nearest = null; Double distance = Double.MAX_VALUE; - for (final Player otherPlayer : QSG.module(GameModule.class).getAliveConnectedPlayers()) - { - try - { + for (final Player otherPlayer : QSG.module(GameModule.class).getAliveConnectedPlayers()) { + try { Double calc = compassUser.getLocation().distanceSquared(otherPlayer.getLocation()); - if (calc > 1 && calc < distance) - { + if (calc > 1 && calc < distance) { distance = calc; - if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && (!Config.NEVER_TARGET_TEAMMATES.get() || !Objects.equals(QuartzTeams.get().getTeamForPlayer(compassUser), QuartzTeams.get().getTeamForPlayer(otherPlayer)))) - { + if (!otherPlayer.getUniqueId().equals(compassUser.getUniqueId()) && + (!Config.NEVER_TARGET_TEAMMATES.get() || + !Objects.equals(QuartzTeams.get().getTeamForPlayer(compassUser), + QuartzTeams.get().getTeamForPlayer(otherPlayer)))) { nearest = otherPlayer.getPlayer(); } } } - catch (Exception ignored) {} // Different worlds + catch (Exception ignored) { + } // Different worlds } - if (nearest == null) - { + if (nearest == null) { /// Error message if a player tries to use his pointing compass without a player nearby. MessageSender.sendActionBarMessage(compassUser, QSGUtils - .prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "Only silence answers your request."))); + .prefixedMessage(ChatColor.BOLD + I.tl(locale, "Compass"), ChatColor.YELLOW + "" + ChatColor.BOLD + + I.tl(locale, "Only silence answers your request."))); new QSGSound(1F, 1F, "BLOCK_WOOD_STEP", "STEP_WOOD").play(compassUser); return false; @@ -211,17 +211,19 @@ private boolean activateCompass(final Player compassUser) CompassBehavior behavior = Config.COMPASS_BEHAVIOR.get(); - if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) - { + if (behavior == CompassBehavior.GIVE_EITHER_RANDOMLY) { final double r = RandomUtils.nextDouble(); - if (r < .45) behavior = CompassBehavior.GIVE_DIRECTION; - else if (r < .9) behavior = CompassBehavior.GIVE_DISTANCE; - else behavior = CompassBehavior.GIVE_BOTH; + if (r < .45) { + behavior = CompassBehavior.GIVE_DIRECTION; + } else if (r < .9) { + behavior = CompassBehavior.GIVE_DISTANCE; + } else { + behavior = CompassBehavior.GIVE_BOTH; + } } - if (behavior == CompassBehavior.GIVE_BOTH) - { + if (behavior == CompassBehavior.GIVE_BOTH) { compassUser.setCompassTarget(nearest.getLocation()); compassUser.sendMessage(QSGUtils.prefixedMessage( I.tl(locale, "Compass"), @@ -232,19 +234,17 @@ private boolean activateCompass(final Player compassUser) (int) nearest.getLocation().distanceSquared(compassUser.getLocation()) ) )); - } - - else if (behavior == CompassBehavior.GIVE_DIRECTION) - { + } else if (behavior == CompassBehavior.GIVE_DIRECTION) { compassUser.setCompassTarget(nearest.getLocation()); /// Success message when a player uses his pointing compass. - MessageSender.sendActionBarMessage(compassUser, ChatColor.YELLOW + "" + ChatColor.BOLD + I.tl(locale, "The compass now points to the closest player.")); - } - - else - { - compassUser.sendMessage(QSGUtils.prefixedMessage(I.tl(locale, "Compass"), I.tln(locale, "{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", (int) nearest.getLocation().distance(compassUser.getLocation())))); + MessageSender.sendActionBarMessage(compassUser, ChatColor.YELLOW + "" + ChatColor.BOLD + + I.tl(locale, "The compass now points to the closest player.")); + } else { + compassUser.sendMessage(QSGUtils.prefixedMessage(I.tl(locale, "Compass"), + I.tln(locale, "{yellow}There is {gold}{0} block {yellow}between the nearest player and yourself.", + "{yellow}There are {gold}{0} blocks {yellow}between the nearest player and yourself.", + (int) nearest.getLocation().distance(compassUser.getLocation())))); } new QSGSound(1F, 1F, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT").play(compassUser); @@ -252,8 +252,7 @@ else if (behavior == CompassBehavior.GIVE_DIRECTION) return true; } - public enum CompassBehavior - { + public enum CompassBehavior { GIVE_DIRECTION, GIVE_DISTANCE, GIVE_BOTH, diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java index 386d48c..9462413 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java @@ -31,12 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; import eu.carrade.amaury.quartzsurvivalgames.utils.RecipesUtils; import fr.zcraft.quartzlib.core.QuartzComponent; import fr.zcraft.quartzlib.tools.items.CraftingRecipes; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.ArrayList; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Event; @@ -51,10 +53,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import java.util.ArrayList; - -public class CompassRecipes extends QuartzComponent implements Listener -{ +public class CompassRecipes extends QuartzComponent implements Listener { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( new ItemStack(Material.COMPASS), " A ", @@ -87,19 +86,18 @@ public class CompassRecipes extends QuartzComponent implements Listener * @param matrix The content of the crafting inventory. * @return true if the recipe is an alternate recipe for the compass. */ - public boolean isValidCompassRecipe(final ItemStack[] matrix) - { - if (matrix.length <= 5) - { + public boolean isValidCompassRecipe(final ItemStack[] matrix) { + if (matrix.length <= 5) { return false; // Small crafting grid } // 0: is it fully filled? - for (int i = 0; i < 9; i++) - { - if (matrix[i] == null) return false; + for (int i = 0; i < 9; i++) { + if (matrix[i] == null) { + return false; + } } @@ -115,8 +113,7 @@ public boolean isValidCompassRecipe(final ItemStack[] matrix) && iron2.equals(Material.IRON_INGOT) && iron3.equals(Material.IRON_INGOT) && iron4.equals(Material.IRON_INGOT) - && centralIngredient.equals(getCentralIngredient()))) - { + && centralIngredient.equals(getCentralIngredient()))) { return false; } @@ -135,10 +132,8 @@ public boolean isValidCompassRecipe(final ItemStack[] matrix) && corners.contains(Material.GUNPOWDER); } - private Material getCentralIngredient() - { - switch (Config.RECIPE.get()) - { + private Material getCentralIngredient() { + switch (Config.RECIPE.get()) { case MEDIUM: return Material.ENDER_PEARL; @@ -150,19 +145,18 @@ private Material getCentralIngredient() } } - @EventHandler (ignoreCancelled = true) - public void onInventoryClick(final InventoryClickEvent ev) - { - if (Config.RECIPE.get() == CompassRecipe.DEFAULT) return; + @EventHandler(ignoreCancelled = true) + public void onInventoryClick(final InventoryClickEvent ev) { + if (Config.RECIPE.get() == CompassRecipe.DEFAULT) { + return; + } - if (ev.getWhoClicked() instanceof Player) - { + if (ev.getWhoClicked() instanceof Player) { final Inventory inventory = ev.getInventory(); // Workaround to fix the crafting grid being not updated when the item is taken // from the grid. - if (inventory instanceof CraftingInventory && ev.getSlotType() == InventoryType.SlotType.RESULT) - { + if (inventory instanceof CraftingInventory && ev.getSlotType() == InventoryType.SlotType.RESULT) { RunTask.later( () -> ev.getViewers().stream() .filter(viewer -> viewer instanceof Player) @@ -174,18 +168,15 @@ public void onInventoryClick(final InventoryClickEvent ev) /* *** Allows any shape for the loots in the compass recipe. *** */ - if (inventory instanceof CraftingInventory) - { + if (inventory instanceof CraftingInventory) { // This is ran one tick after the click because when the event is fired, the inventory // object is not updated, and so the result of the isValidCompassResult is invalid. RunTask.later(() -> { - if (isValidCompassRecipe(((CraftingInventory) inventory).getMatrix())) - { + if (isValidCompassRecipe(((CraftingInventory) inventory).getMatrix())) { // Puts the compass in the result slot - if (ev.getSlotType() == InventoryType.SlotType.CRAFTING) - { + if (ev.getSlotType() == InventoryType.SlotType.CRAFTING) { ((CraftingInventory) inventory).setResult(new ItemStack(Material.COMPASS)); ev.setResult(Event.Result.ALLOW); @@ -194,20 +185,17 @@ public void onInventoryClick(final InventoryClickEvent ev) // Consumes the materials in the crafting grid. // Because this is not an "official" recipe, we need to do that manually. - else if (ev.getSlotType() == InventoryType.SlotType.RESULT) - { + else if (ev.getSlotType() == InventoryType.SlotType.RESULT) { int index = 1; - for (ItemStack stack : ((CraftingInventory) inventory).getMatrix()) - { - if (stack == null) continue; + for (ItemStack stack : ((CraftingInventory) inventory).getMatrix()) { + if (stack == null) { + continue; + } - if (stack.getAmount() != 1) - { + if (stack.getAmount() != 1) { stack.setAmount(stack.getAmount() - 1); inventory.setItem(index, stack); - } - else - { + } else { inventory.setItem(index, new ItemStack(Material.AIR)); } @@ -225,17 +213,16 @@ else if (ev.getSlotType() == InventoryType.SlotType.RESULT) } } - @EventHandler (ignoreCancelled = true) - public void onInventoryDrag(final InventoryDragEvent ev) - { - if (Config.RECIPE.get() == CompassRecipe.DEFAULT) return; + @EventHandler(ignoreCancelled = true) + public void onInventoryDrag(final InventoryDragEvent ev) { + if (Config.RECIPE.get() == CompassRecipe.DEFAULT) { + return; + } - if (ev.getInventory() instanceof CraftingInventory) - { + if (ev.getInventory() instanceof CraftingInventory) { RunTask.later(() -> { - if (isValidCompassRecipe(((CraftingInventory) ev.getInventory()).getMatrix())) - { + if (isValidCompassRecipe(((CraftingInventory) ev.getInventory()).getMatrix())) { ((CraftingInventory) ev.getInventory()).setResult(new ItemStack(Material.COMPASS)); ((Player) ev.getWhoClicked()).updateInventory(); // deprecated but needed } @@ -244,16 +231,13 @@ public void onInventoryDrag(final InventoryDragEvent ev) } @EventHandler - private void onPreCraft(final PrepareItemCraftEvent ev) - { - if (Config.RECIPE.get() != CompassRecipe.DEFAULT && RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) - { + private void onPreCraft(final PrepareItemCraftEvent ev) { + if (Config.RECIPE.get() != CompassRecipe.DEFAULT && RecipesUtils.areSimilar(ev.getRecipe(), VANILLA_RECIPE)) { ev.getInventory().setResult(new ItemStack(Material.AIR)); } } - public enum CompassRecipe - { + public enum CompassRecipe { /** * The default recipe with redstone and iron. */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java index 5aebcc3..eb6bf84 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/Config.java @@ -31,29 +31,26 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.compass; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; -import org.bukkit.Material; - import java.io.File; +import org.bukkit.Material; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - - public final static ConfigurationItem<CompassRecipes.CompassRecipe> RECIPE = item("recipe", CompassRecipes.CompassRecipe.EASY); - +public class Config extends ConfigurationInstance { + public final static ConfigurationItem<CompassRecipes.CompassRecipe> RECIPE = + item("recipe", CompassRecipes.CompassRecipe.EASY); public final static ConfigurationItem<Material> COMPASS_FEE_ITEM = item("compass-fee-item", Material.ROTTEN_FLESH); public final static ConfigurationItem<Integer> COMPASS_FEE_AMOUNT = item("compass-fee-amount", 1); - public final static ConfigurationItem<Boolean> NEVER_TARGET_TEAMMATES = item("never-target-teammates", true); + public final static ConfigurationItem<CompassModule.CompassBehavior> COMPASS_BEHAVIOR = + item("compass-behavior", CompassModule.CompassBehavior.GIVE_DIRECTION); - public final static ConfigurationItem<CompassModule.CompassBehavior> COMPASS_BEHAVIOR = item("compass-behavior", CompassModule.CompassBehavior.GIVE_DIRECTION); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java index 9c8d1d5..06df84f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/Config.java @@ -31,26 +31,23 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.daylightCycle; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<Boolean> ENABLE_DAYLIGHT_CYCLE = item("enable-daylight-cycle", true); - static public final ConfigurationItem<TimeDelta> DAYLIGHT_CYCLE_DURATION = item("daylight-cycle-duration", new TimeDelta(0, 20, 0)); - + static public final ConfigurationItem<TimeDelta> DAYLIGHT_CYCLE_DURATION = + item("daylight-cycle-duration", new TimeDelta(0, 20, 0)); static public final ConfigurationItem<Long> WAITING_PHASE_HOUR = item("waiting-phase-hour", 6000L); static public final ConfigurationItem<Long> INITIAL_GAME_HOUR = item("initial-game-hour", 0L); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java index 2106f4a..6ab0aa6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/daylightCycle/DaylightCycleModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.daylightCycle; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,23 +43,21 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.concurrent.atomic.AtomicLong; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.scheduler.BukkitTask; -import java.util.concurrent.atomic.AtomicLong; - -@ModuleInfo ( +@ModuleInfo( name = "Daylight Cycle", description = "Configures the daylight cycle (disabled, slowed down, normal, accelerated) and the initial time.", category = ModuleCategory.GAMEPLAY, icon = Material.CLOCK, settings = Config.class ) -public class DaylightCycleModule extends QSGModule -{ +public class DaylightCycleModule extends QSGModule { // Here are the Magic Values™. private final static long TICKS_IN_ONE_DAYLIGHT_CYCLE = 24000L; private final static TimeDelta NORMAL_DAYLIGHT_CYCLE_DURATION = new TimeDelta(0, 20, 0); @@ -67,8 +66,7 @@ public class DaylightCycleModule extends QSGModule @Override - protected void onEnable() - { + protected void onEnable() { QSG.get().getWorlds().forEach(world -> { world.setFullTime(Config.WAITING_PHASE_HOUR.get()); world.setGameRuleValue("doDaylightCycle", Boolean.FALSE.toString()); @@ -76,43 +74,35 @@ protected void onEnable() } @Override - public void onLateEnable() - { - if (QSG.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) - { + public void onLateEnable() { + if (QSG.module(GameModule.class).currentPhaseAfter(GamePhase.STARTING)) { initDayLightCycle(QSG.get().getWorld(World.Environment.NORMAL).getFullTime()); } } @Override - protected void onDisable() - { - if (daylightCycleTask != null) - { + protected void onDisable() { + if (daylightCycleTask != null) { daylightCycleTask.cancel(); daylightCycleTask = null; } } @EventHandler - public void onGameStart(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) - { + public void onGameStart(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { initDayLightCycle(Config.INITIAL_GAME_HOUR.get()); } } - private void initDayLightCycle(final long initialTime) - { + private void initDayLightCycle(final long initialTime) { final World world = QSG.get().getWorld(World.Environment.NORMAL); world.setFullTime(Config.INITIAL_GAME_HOUR.get()); world.setGameRuleValue("doDaylightCycle", Config.ENABLE_DAYLIGHT_CYCLE.get().toString()); // If the day cycle duration needs to be altered - if (!Config.DAYLIGHT_CYCLE_DURATION.get().equals(NORMAL_DAYLIGHT_CYCLE_DURATION)) - { + if (!Config.DAYLIGHT_CYCLE_DURATION.get().equals(NORMAL_DAYLIGHT_CYCLE_DURATION)) { // We disable the automatic cycle to avoid the sun and the moon to boggle on the clients world.setGameRuleValue("doDaylightCycle", Boolean.FALSE.toString()); @@ -123,14 +113,19 @@ private void initDayLightCycle(final long initialTime) final long updateInterval = (long) Math.max(1L, (ticksPerDay * 1.0f) / TICKS_IN_ONE_DAYLIGHT_CYCLE); final AtomicLong tick = new AtomicLong(initialTime % TICKS_IN_ONE_DAYLIGHT_CYCLE); - if (tick.get() < 0L) tick.addAndGet(TICKS_IN_ONE_DAYLIGHT_CYCLE); + if (tick.get() < 0L) { + tick.addAndGet(TICKS_IN_ONE_DAYLIGHT_CYCLE); + } daylightCycleTask = RunTask.timer(() -> { // We keep the current tick in one daylight cycle. - if (tick.addAndGet(updateInterval) >= ticksPerDay) tick.set(0L); + if (tick.addAndGet(updateInterval) >= ticksPerDay) { + tick.set(0L); + } // On each tick, we calculate the time of day we should be at this point. - final long convertedTick = (long) Math.floor((tick.floatValue() / ticksPerDay) * TICKS_IN_ONE_DAYLIGHT_CYCLE); + final long convertedTick = + (long) Math.floor((tick.floatValue() / ticksPerDay) * TICKS_IN_ONE_DAYLIGHT_CYCLE); // We update the main world. world.setTime(convertedTick); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java index 8d395c7..4e42358 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/Config.java @@ -31,58 +31,52 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH = item("drop-head-on-death", true); - public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH_PVP_ONLY = item("drop-head-on-death-pvp-only", false); - - public static final ConfigurationItem<Boolean> DISPLAY_REGEN_AMOUNT_ON_APPLES = item("display-regen-amount-on-apples", true); - + public static final ConfigurationItem<Boolean> DROP_HEAD_ON_DEATH_PVP_ONLY = + item("drop-head-on-death-pvp-only", false); + public static final ConfigurationItem<Boolean> DISPLAY_REGEN_AMOUNT_ON_APPLES = + item("display-regen-amount-on-apples", true); public static final GoldenAppleSection GOLDEN_APPLE = section("golden-apple", GoldenAppleSection.class); - public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = section("enchanted-golden-apple", EnchantedGoldenAppleSection.class); - + public static final EnchantedGoldenAppleSection ENCHANTED_GOLDEN_APPLE = + section("enchanted-golden-apple", EnchantedGoldenAppleSection.class); public static final GoldenHeadSection PLAYER_GOLDEN_HEAD = section("player-golden-head", GoldenHeadSection.class); public static final GoldenHeadSection WITHER_GOLDEN_HEAD = section("wither-golden-head", GoldenHeadSection.class); + public static final EnchantedGoldenHeadSection PLAYER_ENCHANTED_GOLDEN_HEAD = + section("player-enchanted-golden-head", EnchantedGoldenHeadSection.class); + public static final EnchantedGoldenHeadSection WITHER_ENCHANTED_GOLDEN_HEAD = + section("wither-enchanted-golden-head", EnchantedGoldenHeadSection.class); + public Config(File file) { + super(file); + } - public static final EnchantedGoldenHeadSection PLAYER_ENCHANTED_GOLDEN_HEAD = section("player-enchanted-golden-head", EnchantedGoldenHeadSection.class); - public static final EnchantedGoldenHeadSection WITHER_ENCHANTED_GOLDEN_HEAD = section("wither-enchanted-golden-head", EnchantedGoldenHeadSection.class); - - public static class GoldenAppleSection extends ConfigurationSection - { + public static class GoldenAppleSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLE = item("enable", true); public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 4); } - public static class EnchantedGoldenAppleSection extends ConfigurationSection - { + public static class EnchantedGoldenAppleSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLE = item("enable", false); public final ConfigurationItem<Integer> REGENERATION = item("regeneration", 180); } - public static class GoldenHeadSection extends GoldenAppleSection - { + public static class GoldenHeadSection extends GoldenAppleSection { public final ConfigurationItem<Integer> AMOUNT_CRAFTED = item("amount-crafted", 1); public final ConfigurationItem<Boolean> ADD_LORE = item("add-lore", true); } - public static class EnchantedGoldenHeadSection extends EnchantedGoldenAppleSection - { + public static class EnchantedGoldenHeadSection extends EnchantedGoldenAppleSection { public final ConfigurationItem<Integer> AMOUNT_CRAFTED = item("amount-crafted", 1); public final ConfigurationItem<Boolean> ADD_LORE = item("add-lore", true); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java index 3676cf6..a579009 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.goldenHeads; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -46,6 +47,7 @@ import fr.zcraft.quartzlib.tools.items.ItemUtils; import fr.zcraft.quartzlib.tools.reflection.NMSException; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.UUID; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -61,10 +63,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.UUID; - -@ModuleInfo ( +@ModuleInfo( name = "Golden Apple & Heads", description = "Changes golden apple behavior. This can change the regeneration from these apple, " + "and allow players to craft “golden heads” from fallen heads when they kill a player. You can " + @@ -74,46 +74,48 @@ icon = Material.GOLDEN_APPLE, // TODO 1.13: enchanted golden apple or player head settings = Config.class ) -public class GoldenHeadsModule extends QSGModule -{ +public class GoldenHeadsModule extends QSGModule { private final static UUID HEADS_UUID = UUID.fromString("1a050e3b-6274-434e-b8c0-a720048142e7"); - - private final String HEART = "\u2764"; - private final String HALF = "\u00bd"; - private final static int TICKS_BETWEEN_EACH_REGENERATION = 50; private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN = 4; private final static int DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH = 180; private final static int REGENERATION_LEVEL_GOLDEN_APPLE = 2; private final static int REGENERATION_LEVEL_NOTCH_GOLDEN_APPLE = 5; + private final String HEART = "\u2764"; + private final String HALF = "\u00bd"; @Override - protected void onEnable() - { - if (Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get()) + protected void onEnable() { + if (Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get()) { Bukkit.addRecipe(getOldEnchantedGoldenAppleRecipe()); + } - if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); + if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get()) { + Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + ChatColor.AQUA + I.t("Golden head"))); + } - if (Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); + if (Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { + Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + ChatColor.LIGHT_PURPLE + I.t("Golden head"))); + } - if (Config.WITHER_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); + if (Config.WITHER_GOLDEN_HEAD.ENABLE.get()) { + Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + ChatColor.AQUA + I.t("Golden head"))); + } - if (Config.WITHER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) - Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); + if (Config.WITHER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { + Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + ChatColor.LIGHT_PURPLE + I.t("Golden head"))); + } } - private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted, final int amount, final String resultDisplayName) - { - short damage = (short) (enchanted ? 1 : 0); - - final ItemStack goldenApple = new ItemStackBuilder(Material.GOLDEN_APPLE) + private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted, final int amount, + final String resultDisplayName) { + final ItemStack goldenApple = new ItemStackBuilder(enchanted ? Material.ENCHANTED_GOLDEN_APPLE : Material.GOLDEN_APPLE) .title(ChatColor.RESET + resultDisplayName) .amount(amount) - .data(damage) .craftItem(); // Required to write attributes by reference writeHeadType(goldenApple, player ? SkullType.PLAYER : SkullType.WITHER); @@ -127,9 +129,9 @@ private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted return goldenAppleFromHeadRecipe; } - private Recipe getOldEnchantedGoldenAppleRecipe() - { - final ShapedRecipe enchantedGoldenAppleRecipe = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); // FIXME 1.13 + private Recipe getOldEnchantedGoldenAppleRecipe() { + final ShapedRecipe enchantedGoldenAppleRecipe = + new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); // FIXME 1.13 enchantedGoldenAppleRecipe.shape("GGG", "GAG", "GGG"); enchantedGoldenAppleRecipe.setIngredient('G', Material.GOLD_BLOCK); enchantedGoldenAppleRecipe.setIngredient('A', Material.APPLE); @@ -137,18 +139,15 @@ private Recipe getOldEnchantedGoldenAppleRecipe() return enchantedGoldenAppleRecipe; } - private void writeHeadType(final ItemStack stack, final SkullType type) - { + private void writeHeadType(final ItemStack stack, final SkullType type) { final Attribute attribute = new Attribute(); attribute.setUUID(HEADS_UUID); attribute.setCustomData(type.name()); - try - { + try { Attributes.set(stack, attribute); } - catch (NMSException e) - { + catch (NMSException e) { PluginLogger.error("Unable to write head type into item stack.", e); } } @@ -157,7 +156,7 @@ private void writeHeadType(final ItemStack stack, final SkullType type) * From a golden apple, reads the head type written in it, so you can know * if it's a regular golden apple, a Wither golden head or a Player golden * head. - * + * <p> * TODO replace SkullType with Material * * @param stack The ItemStack to analyze. @@ -165,37 +164,36 @@ private void writeHeadType(final ItemStack stack, final SkullType type) * {@link SkullType#WITHER} (Wither golden head) or {@code null} (regular * golden apple). */ - public SkullType readHeadType(final ItemStack stack) - { - try - { + public SkullType readHeadType(final ItemStack stack) { + try { final Attribute attribute = Attributes.get(stack, HEADS_UUID); - if (attribute != null) - { + if (attribute != null) { return SkullType.valueOf(attribute.getCustomData()); + } else { + return null; } - else return null; } - catch (NMSException | IllegalArgumentException e) - { + catch (NMSException | IllegalArgumentException e) { return null; } } @EventHandler - public void onPreCraft(final PrepareItemCraftEvent ev) - { + public void onPreCraft(final PrepareItemCraftEvent ev) { /* *** We remove these recipes if disabled *** */ final ItemStack result = ev.getInventory().getResult(); - if (result == null || (result.getType() != Material.GOLDEN_APPLE && result.getType() != Material.ENCHANTED_GOLDEN_APPLE)) return; + if (result == null || + (result.getType() != Material.GOLDEN_APPLE && result.getType() != Material.ENCHANTED_GOLDEN_APPLE)) { + return; + } final boolean isEnchanted = result.getType() == Material.ENCHANTED_GOLDEN_APPLE; if ((!Config.GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && !isEnchanted) - || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && isEnchanted)) - { + || (!Config.ENCHANTED_GOLDEN_APPLE.ENABLE.get() && result.getType() == Material.GOLDEN_APPLE && + isEnchanted)) { result.setType(Material.AIR); } @@ -203,27 +201,23 @@ public void onPreCraft(final PrepareItemCraftEvent ev) /* *** We add a lore to the golden apples *** */ final SkullType headType = readHeadType(result); - if (headType != null) - { + if (headType != null) { final ItemStackBuilder revampedResult = new ItemStackBuilder(result); if (headType == SkullType.WITHER && - ((!isEnchanted && Config.WITHER_GOLDEN_HEAD.ADD_LORE.get()) || (isEnchanted && Config.WITHER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) - { - revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of a malignant monster")); - } - - else if (headType == SkullType.PLAYER && - ((!isEnchanted && Config.PLAYER_GOLDEN_HEAD.ADD_LORE.get()) || (isEnchanted && Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) - { + ((!isEnchanted && Config.WITHER_GOLDEN_HEAD.ADD_LORE.get()) || + (isEnchanted && Config.WITHER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) { + revampedResult.longLore(ChatColor.GRAY, + ChatColor.ITALIC + I.t("Made from the fallen head of a malignant monster")); + } else if (headType == SkullType.PLAYER && + ((!isEnchanted && Config.PLAYER_GOLDEN_HEAD.ADD_LORE.get()) || + (isEnchanted && Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ADD_LORE.get()))) { // We retrieve the player name to write it into the lore String name = null; - for (final ItemStack item : ev.getInventory().getContents()) - { + for (final ItemStack item : ev.getInventory().getContents()) { // An human head - if (item.getType() == Material.PLAYER_HEAD) - { + if (item.getType() == Material.PLAYER_HEAD) { SkullMeta sm = (SkullMeta) item.getItemMeta(); if (sm.hasOwner()) // An human head { @@ -233,43 +227,42 @@ else if (headType == SkullType.PLAYER && } } - if (name != null) - { - revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of {0}", name)); - } - else - { - revampedResult.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of a powerful opponent")); + if (name != null) { + revampedResult + .longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Made from the fallen head of {0}", name)); + } else { + revampedResult.longLore(ChatColor.GRAY, + ChatColor.ITALIC + I.t("Made from the fallen head of a powerful opponent")); } } - revampedResult.hideAttributes().item(); + revampedResult.hideAllAttributes().item(); } /* *** We add the regeneration amount on all apples, if non-vanilla *** */ - if (Config.DISPLAY_REGEN_AMOUNT_ON_APPLES.get()) - { + if (Config.DISPLAY_REGEN_AMOUNT_ON_APPLES.get()) { final int halfHearts = getRegenerationFor(headType, isEnchanted); - if (halfHearts != 0 && ((!isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN) || (isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH))) - { + if (halfHearts != 0 && ((!isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN) || + (isEnchanted && halfHearts != DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH))) { final int hearts = halfHearts / 2; final boolean plusHalf = halfHearts % 2 != 0; final String heartsSymbol; - if (hearts <= 10) - { - heartsSymbol = ChatColor.RED + StringUtils.repeat(HEART, hearts) + (plusHalf ? ChatColor.GRAY + " + " + HALF : ""); - } - else - { - heartsSymbol = ChatColor.RED + HEART + ChatColor.GRAY + " × " + hearts + (plusHalf ? " + " + HALF : ""); + if (hearts <= 10) { + heartsSymbol = ChatColor.RED + StringUtils.repeat(HEART, hearts) + + (plusHalf ? ChatColor.GRAY + " + " + HALF : ""); + } else { + heartsSymbol = + ChatColor.RED + HEART + ChatColor.GRAY + " × " + hearts + (plusHalf ? " + " + HALF : ""); } final ItemStackBuilder revampedResult = new ItemStackBuilder(result); - if (headType != null) revampedResult.loreSeparator(); + if (headType != null) { + revampedResult.loreSeparator(); + } revampedResult.loreLine(ChatColor.GRAY, I.t("Regenerates {0}", heartsSymbol)).item(); } @@ -277,16 +270,16 @@ else if (headType == SkullType.PLAYER && } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (Config.DROP_HEAD_ON_DEATH.get() && ev.getPlayer().isOnline() && (!Config.DROP_HEAD_ON_DEATH_PVP_ONLY.get() || ev.getPlayer().getPlayer().getKiller() != null)) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (Config.DROP_HEAD_ON_DEATH.get() && ev.getPlayer().isOnline() && + (!Config.DROP_HEAD_ON_DEATH_PVP_ONLY.get() || ev.getPlayer().getPlayer().getKiller() != null)) { final ItemStackBuilder headBuilder = new ItemStackBuilder(Material.PLAYER_HEAD) .title(ChatColor.AQUA, I.t("{0}'s head", ev.getPlayer().getName())); - if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get() || Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) - { - headBuilder.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Old legends tell how the heads of the brave fallen warriors can become, through a rich and complex transformation, a precious healing balm..."), 38); + if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get() || Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { + headBuilder.longLore(ChatColor.GRAY, ChatColor.ITALIC + + I.t("Old legends tell how the heads of the brave fallen warriors can become, through a rich and complex transformation, a precious healing balm..."), + 38); } // TODO update with QLib 0.1's ISB @@ -305,10 +298,9 @@ public void onPlayerDeath(final AlivePlayerDeathEvent ev) * Used to change the amount of regenerated hearts from a golden apple. */ @EventHandler - public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) - { - if (ev.getItem().getType() == Material.GOLDEN_APPLE || ev.getItem().getType() == Material.ENCHANTED_GOLDEN_APPLE) - { + public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) { + if (ev.getItem().getType() == Material.GOLDEN_APPLE || + ev.getItem().getType() == Material.ENCHANTED_GOLDEN_APPLE) { final SkullType headType = readHeadType(ev.getItem()); final boolean isEnchanted = ev.getItem().getType() == Material.ENCHANTED_GOLDEN_APPLE; @@ -322,23 +314,20 @@ public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) // What is needed to do? if ((!isEnchanted && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (isEnchanted && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) - { + || (isEnchanted && halfHearts == DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) { // Default behavior, nothing to do. return; } if ((!isEnchanted && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN) - || (isEnchanted && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) - { + || (isEnchanted && halfHearts > DEFAULT_NUMBER_OF_HEARTS_REGEN_NOTCH)) { // If the heal needs to be increased, the effect can be applied immediately. - int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * halfHearts; + int duration = + ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * halfHearts; new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); - } - else - { + } else { // The heal needs to be decreased. // We can't apply the effect immediately, because the server will just ignore it. // So, we apply it two ticks later, with one half-heart less (because in two ticks, @@ -350,7 +339,8 @@ public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) // The original, vanilla, effect is removed ev.getPlayer().removePotionEffect(PotionEffectType.REGENERATION); - int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * healthApplied; + int duration = ((int) Math.floor(TICKS_BETWEEN_EACH_REGENERATION / (Math.pow(2, realLevel)))) * + healthApplied; new PotionEffect(PotionEffectType.REGENERATION, duration, realLevel).apply(ev.getPlayer()); }, 2L); } @@ -360,50 +350,38 @@ public void onPlayerItemConsume(final PlayerItemConsumeEvent ev) /** * Returns the amount of regeneration we should apply for a given apple. * - * @param headType The apple type ({@code null} meaning standard apple; else, {@link SkullType#WITHER} or {@link SkullType#PLAYER}). + * @param headType The apple type ({@code null} meaning standard apple; else, {@link SkullType#WITHER} or {@link SkullType#PLAYER}). * @param isEnchanted True if this is an enchanted golden apple (aka Notch Apple). * @return The amount of regeneration, or 0 if invalid (i.e. bad skull type). */ - private int getRegenerationFor(final SkullType headType, final boolean isEnchanted) - { + private int getRegenerationFor(final SkullType headType, final boolean isEnchanted) { // Standard golden apple - if (headType == null) - { + if (headType == null) { if (!isEnchanted) // FIXME 1.13 { return Config.GOLDEN_APPLE.REGENERATION.get(); - } - else - { + } else { return Config.ENCHANTED_GOLDEN_APPLE.REGENERATION.get(); } - } - - else if (headType == SkullType.PLAYER) - { + } else if (headType == SkullType.PLAYER) { if (!isEnchanted) // FIXME 1.13 { return Config.PLAYER_GOLDEN_HEAD.REGENERATION.get(); - } - else - { + } else { return Config.PLAYER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); } - } - - else if (headType == SkullType.WITHER) - { + } else if (headType == SkullType.WITHER) { if (!isEnchanted) // FIXME 1.13 { return Config.WITHER_GOLDEN_HEAD.REGENERATION.get(); - } - else - { + } else { return Config.WITHER_ENCHANTED_GOLDEN_HEAD.REGENERATION.get(); } } // Invalid attribute. Should never happen. - else return 0; + else { + return 0; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java index 2d19655..c55660c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/Config.java @@ -31,23 +31,20 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.hardcore; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; -import org.bukkit.Difficulty; - import java.io.File; +import org.bukkit.Difficulty; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<Boolean> NATURAL_REGENERATION = item("natural-regeneration", false); static public final ConfigurationItem<Difficulty> DIFFICULTY = item("difficulty", Difficulty.HARD); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java index 9a44962..b7e7a22 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/hardcore/HardcoreModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.hardcore; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -38,14 +39,13 @@ import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; -import org.bukkit.Difficulty; -import org.bukkit.Material; - import java.util.HashMap; import java.util.Map; +import org.bukkit.Difficulty; +import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Hardcore Mode", description = "Disables health natural regeneration and sets correct difficulty in the game's worlds.", when = ModuleLoadTime.ON_GAME_START, @@ -53,14 +53,12 @@ icon = Material.GOLDEN_APPLE, settings = Config.class ) -public class HardcoreModule extends QSGModule -{ - private Map<String, Difficulty> oldDifficulties = new HashMap<>(); - private Map<String, String> oldNaturalRegenerations = new HashMap<>(); +public class HardcoreModule extends QSGModule { + private final Map<String, Difficulty> oldDifficulties = new HashMap<>(); + private final Map<String, String> oldNaturalRegenerations = new HashMap<>(); @Override - protected void onEnable() - { + protected void onEnable() { QSG.get().getWorlds().forEach(world -> { oldDifficulties.put(world.getName(), world.getDifficulty()); @@ -72,11 +70,11 @@ protected void onEnable() } @Override - protected void onDisable() - { + protected void onDisable() { QSG.get().getWorlds().forEach(world -> { world.setDifficulty(oldDifficulties.getOrDefault(world.getName(), Difficulty.NORMAL)); - world.setGameRuleValue("naturalRegeneration", oldNaturalRegenerations.getOrDefault(world.getName(), "true")); + world.setGameRuleValue("naturalRegeneration", + oldNaturalRegenerations.getOrDefault(world.getName(), "true")); }); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java index d1d2608..c760eca 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/Config.java @@ -31,22 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.killerRabbit; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Double> SPAWN_PROBABILITY = item("spawn-probability", 0.05); public static final ConfigurationItem<String> NAME = item("name", "The Killer Rabbit of Cærbannog"); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java index e962be9..8f4f2de 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/killerRabbit/KillerRabbitModule.java @@ -31,12 +31,14 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.killerRabbit; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import java.util.Random; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Rabbit; @@ -44,10 +46,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.CreatureSpawnEvent; -import java.util.Random; - -@ModuleInfo ( +@ModuleInfo( name = "Killer Rabbit", description = "Brings back the Killer Rabbit of Cærbannog into the game. Beware, it bites.", when = ModuleLoadTime.ON_GAME_START, @@ -55,24 +55,23 @@ icon = Material.RABBIT_FOOT, settings = Config.class ) -public class KillerRabbitModule extends QSGModule -{ +public class KillerRabbitModule extends QSGModule { private final Random random = new Random(); @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onRabbitSpawn(final CreatureSpawnEvent ev) - { - if (ev.getEntity().getType() != EntityType.RABBIT) + public void onRabbitSpawn(final CreatureSpawnEvent ev) { + if (ev.getEntity().getType() != EntityType.RABBIT) { return; + } - if (random.nextDouble() >= Config.SPAWN_PROBABILITY.get()) + if (random.nextDouble() >= Config.SPAWN_PROBABILITY.get()) { return; + } final Rabbit rabbit = (Rabbit) ev.getEntity(); rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY); - if (!Config.NAME.get().isEmpty()) - { + if (!Config.NAME.get().isEmpty()) { rabbit.setCustomName(Config.NAME.get()); rabbit.setCustomNameVisible(true); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java index d8eef3d..b0f3ac6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/Config.java @@ -31,22 +31,19 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.noWitches; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Boolean> DISABLE_NATURAL_SPAWN = item("disable-natural-spawn", true); public static final ConfigurationItem<Boolean> DISABLE_LIGHTNING_SPAWN = item("disable-lightning-spawn", true); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java index 682bfe9..265bf24 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/noWitches/NoWitchesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.noWitches; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -43,7 +44,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -@ModuleInfo ( +@ModuleInfo( name = "No Witches", description = "Prevents witches from spawning, either naturally, from lightning strike on a villager, or both.", when = ModuleLoadTime.ON_GAME_START, @@ -51,20 +52,15 @@ icon = Material.POTION, settings = Config.class ) -public class NoWitchesModule extends QSGModule -{ +public class NoWitchesModule extends QSGModule { @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent ev) - { - if (ev.getEntityType().equals(EntityType.WITCH)) - { - if (Config.DISABLE_NATURAL_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.NATURAL)) - { + public void onCreatureSpawn(CreatureSpawnEvent ev) { + if (ev.getEntityType().equals(EntityType.WITCH)) { + if (Config.DISABLE_NATURAL_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.NATURAL)) { ev.setCancelled(true); } - if (Config.DISABLE_LIGHTNING_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.LIGHTNING)) - { + if (Config.DISABLE_LIGHTNING_SPAWN.get() && ev.getSpawnReason().equals(SpawnReason.LIGHTNING)) { ev.setCancelled(true); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java index 1ad60dd..2b77244 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/CancelBrewTask.java @@ -33,6 +33,8 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; import fr.zcraft.quartzlib.tools.items.ItemUtils; +import java.util.HashSet; +import java.util.Set; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -40,51 +42,53 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashSet; -import java.util.Set; - -public class CancelBrewTask extends BukkitRunnable -{ +public class CancelBrewTask extends BukkitRunnable { private final BrewerInventory inventory; private final HumanEntity whoClicked; - public CancelBrewTask(BrewerInventory inventory, HumanEntity whoClicked) - { + public CancelBrewTask(BrewerInventory inventory, HumanEntity whoClicked) { this.inventory = inventory; this.whoClicked = whoClicked; } @Override - public void run() - { - if (inventory.getIngredient() == null) - { + public void run() { + if (inventory.getIngredient() == null) { return; // Nothing to do! } - if (whoClicked instanceof Player) - { + if (whoClicked instanceof Player) { final ItemStack ingredient = inventory.getIngredient(); final Set<Material> forbiddenIngredients = new HashSet<>(); - if (Config.DISABLE_EXTENDED.get()) forbiddenIngredients.add(Material.REDSTONE); - if (Config.DISABLE_LEVEL_II.get()) forbiddenIngredients.add(Material.GLOWSTONE_DUST); - if (Config.DISABLE_SPLASH.get()) forbiddenIngredients.add(Material.GUNPOWDER); - if (Config.DISABLE_LINGERING.get()) - { + if (Config.DISABLE_EXTENDED.get()) { + forbiddenIngredients.add(Material.REDSTONE); + } + if (Config.DISABLE_LEVEL_II.get()) { + forbiddenIngredients.add(Material.GLOWSTONE_DUST); + } + if (Config.DISABLE_SPLASH.get()) { + forbiddenIngredients.add(Material.GUNPOWDER); + } + if (Config.DISABLE_LINGERING.get()) { // 1.9 - 1.12 - try { forbiddenIngredients.add(Material.valueOf("DRAGONS_BREATH")); } - catch (IllegalArgumentException ignored) { } + try { + forbiddenIngredients.add(Material.valueOf("DRAGONS_BREATH")); + } + catch (IllegalArgumentException ignored) { + } // 1.13+ - try { forbiddenIngredients.add(Material.valueOf("DRAGON_BREATH")); } - catch (IllegalArgumentException ignored) { } + try { + forbiddenIngredients.add(Material.valueOf("DRAGON_BREATH")); + } + catch (IllegalArgumentException ignored) { + } } - if (ingredient.getType() != null && forbiddenIngredients.contains(ingredient.getType())) - { + if (ingredient.getType() != null && forbiddenIngredients.contains(ingredient.getType())) { // The element is removed and added back to the player's inventory. inventory.setIngredient(new ItemStack(Material.AIR)); ItemUtils.give((Player) whoClicked, ingredient); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java index ec11023..9cb35d6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/Config.java @@ -31,24 +31,21 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { final static public ConfigurationItem<Boolean> DISABLE_LEVEL_II = item("disable-level-II", true); final static public ConfigurationItem<Boolean> DISABLE_EXTENDED = item("disable-extended", false); final static public ConfigurationItem<Boolean> DISABLE_SPLASH = item("disable-splash", false); final static public ConfigurationItem<Boolean> DISABLE_LINGERING = item("disable-lingering", false); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java index 0b7893d..ad82ea9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/potions/PotionsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.potions; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -45,7 +46,7 @@ import org.bukkit.inventory.BrewerInventory; -@ModuleInfo ( +@ModuleInfo( name = "Potions", description = "Allows to tweak potions, by disabling level-II, enhanced, " + "splash or lingering potions.", @@ -54,22 +55,17 @@ icon = Material.BREWING_STAND, settings = Config.class ) -public class PotionsModule extends QSGModule -{ +public class PotionsModule extends QSGModule { @EventHandler - public void onInventoryDrag(InventoryDragEvent ev) - { - if (ev.getInventory() instanceof BrewerInventory) - { + public void onInventoryDrag(InventoryDragEvent ev) { + if (ev.getInventory() instanceof BrewerInventory) { RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); } } @EventHandler - public void onInventoryClick(InventoryClickEvent ev) - { - if (ev.getInventory() instanceof BrewerInventory) - { + public void onInventoryClick(InventoryClickEvent ev) { + if (ev.getInventory() instanceof BrewerInventory) { RunTask.later(new CancelBrewTask((BrewerInventory) ev.getInventory(), ev.getWhoClicked()), 1L); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java index 38e855f..73171ec 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/Config.java @@ -31,24 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.weather; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; -import org.bukkit.WeatherType; - import java.io.File; +import org.bukkit.WeatherType; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public final ConfigurationItem<Boolean> WEATHER_CYCLE = item("enable-weather-cycle", true); static public final ConfigurationItem<WeatherType> INITIAL_WEATHER = item("initial-weather", WeatherType.CLEAR); - static public final ConfigurationItem<WeatherType> WAITING_PHASE_WEATHER = item("waiting-phase-weather", WeatherType.CLEAR); + static public final ConfigurationItem<WeatherType> WAITING_PHASE_WEATHER = + item("waiting-phase-weather", WeatherType.CLEAR); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java index f6bc779..b5e160f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/weather/WeatherModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.weather; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -40,53 +41,46 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GamePhase; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.game.GamePhaseChangedEvent; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import java.util.HashSet; +import java.util.Set; import org.bukkit.Material; import org.bukkit.WeatherType; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.weather.WeatherChangeEvent; -import java.util.HashSet; -import java.util.Set; - -@ModuleInfo ( +@ModuleInfo( name = "Weather", description = "Manages the in-game weather.", settings = Config.class, category = ModuleCategory.GAMEPLAY, icon = Material.SUNFLOWER ) -public class WeatherModule extends QSGModule -{ - private Set<World> firstWeatherUpdateOccurred = new HashSet<>(); +public class WeatherModule extends QSGModule { + private final Set<World> firstWeatherUpdateOccurred = new HashSet<>(); @Override - protected void onEnable() - { - QSG.get().getWorlds().forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); + protected void onEnable() { + QSG.get().getWorlds() + .forEach(world -> world.setStorm(Config.WAITING_PHASE_WEATHER.get() == WeatherType.DOWNFALL)); } @Override - public void onLateEnable() - { + public void onLateEnable() { QSG.get().getWorlds().forEach(world -> world.setStorm(Config.INITIAL_WEATHER.get() == WeatherType.DOWNFALL)); } @EventHandler - public void onGameStarts(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) - { + public void onGameStarts(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { onLateEnable(); } } @EventHandler - public void onWeatherChange(final WeatherChangeEvent ev) - { - switch (QSG.module(GameModule.class).getPhase()) - { + public void onWeatherChange(final WeatherChangeEvent ev) { + switch (QSG.module(GameModule.class).getPhase()) { case WAIT: case STARTING: ev.setCancelled(true); @@ -94,16 +88,12 @@ public void onWeatherChange(final WeatherChangeEvent ev) case IN_GAME: case END: - if (!Config.WEATHER_CYCLE.get()) - { + if (!Config.WEATHER_CYCLE.get()) { // We allow a single weather update, as it will be // the one from the onGameStart event. - if (firstWeatherUpdateOccurred.contains(ev.getWorld())) - { + if (firstWeatherUpdateOccurred.contains(ev.getWorld())) { ev.setCancelled(true); - } - else - { + } else { firstWeatherUpdateOccurred.add(ev.getWorld()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java index f1f7ebc..69085dc 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/AdvancementsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.other; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -44,17 +45,16 @@ import fr.zcraft.quartzlib.components.events.WrappedEvent; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.CommandException; import org.bukkit.event.EventHandler; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -@ModuleInfo ( +@ModuleInfo( name = "Advancements", description = "Resets the advancements when the game starts. Disable if " + "you want to keep old advancements.\n\n" + @@ -64,42 +64,39 @@ category = ModuleCategory.OTHER, icon = Material.HAY_BLOCK ) -public class AdvancementsModule extends QSGModule -{ - @FutureEventHandler (event = "player.PlayerAchievementAwardedEvent", ignoreCancelled = true) - public void onAchievementAwarded(final WrappedEvent ev) - { - if (QSG.game().getPhase() == GamePhase.WAIT) - { +public class AdvancementsModule extends QSGModule { + @FutureEventHandler(event = "player.PlayerAchievementAwardedEvent", ignoreCancelled = true) + public void onAchievementAwarded(final WrappedEvent ev) { + if (QSG.game().getPhase() == GamePhase.WAIT) { ev.setCancelled(true); } } @EventHandler - public void onGameStarts(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) return; + public void onGameStarts(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME || !ev.isRunningForward()) { + return; + } // Achievements - try - { + try { final Object[] achievements = Class.forName("org.bukkit.Achievement").getEnumConstants(); QSG.game().getAliveConnectedPlayers().forEach(player -> { - try - { - for (final Object achievement : achievements) - { + try { + for (final Object achievement : achievements) { PluginLogger.info("Removing achievement {0}", achievement); Reflection.call(player, "removeAchievement", achievement); } } - catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { + } }); } - catch (final Exception ignored) {} // Unsupported + catch (final Exception ignored) { + } // Unsupported // Advancements @@ -111,15 +108,17 @@ public void onGameStarts(final GamePhaseChangedEvent ev) }); QSG.game().getAliveConnectedPlayers().forEach(player -> { - try - { + try { // ¯\_(ツ)_/¯ - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "advancement revoke " + player.getName() + " everything"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), + "advancement revoke " + player.getName() + " everything"); + } + catch (final CommandException ignored) { } - catch (final CommandException ignored) {} }); - QSG.get().getWorlds().forEach(world -> world.setGameRuleValue("sendCommandFeedback", oldGameRule.get(world.getName()))); + QSG.get().getWorlds() + .forEach(world -> world.setGameRuleValue("sendCommandFeedback", oldGameRule.get(world.getName()))); oldGameRule.clear(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java index 2c5ae71..ddbd8af 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/PomfModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.other; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -51,13 +52,10 @@ category = ModuleCategory.OTHER, icon = Material.SLIME_BLOCK ) -public class PomfModule extends QSGModule -{ +public class PomfModule extends QSGModule { @EventHandler - public void onEpisodeEnds(final EpisodeChangedEvent ev) - { - if (ev.getNewEpisode() == 5) - { + public void onEpisodeEnds(final EpisodeChangedEvent ev) { + if (ev.getNewEpisode() == 5) { RunTask.later(() -> Bukkit.broadcastMessage("- Pomf -"), Config.LENGTH.get().divide(2).getSeconds() * 20L); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java index 4501ccb..da65b1d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/StatisticsModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.other; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -47,7 +48,7 @@ import org.bukkit.event.player.PlayerStatisticIncrementEvent; -@ModuleInfo ( +@ModuleInfo( name = "Statistics", description = "If enabled, statistics will not be collected before the game" + "and will be reset at the beginning of the game. Disable if you want " + @@ -56,51 +57,42 @@ category = ModuleCategory.OTHER, icon = Material.CRAFTING_TABLE ) -public class StatisticsModule extends QSGModule -{ +public class StatisticsModule extends QSGModule { @EventHandler - public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) - { - if (QSG.game().getPhase() == GamePhase.WAIT) - { + public void onPlayerStatisticIncrement(final PlayerStatisticIncrementEvent ev) { + if (QSG.game().getPhase() == GamePhase.WAIT) { ev.setCancelled(true); } } @EventHandler - public void onGameStart(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) - { + public void onGameStart(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward()) { QSG.game().getAliveConnectedPlayers().forEach(player -> { - for (final Statistic statistic : Statistic.values()) - { - switch (statistic.getType()) - { + for (final Statistic statistic : Statistic.values()) { + switch (statistic.getType()) { case UNTYPED: player.setStatistic(statistic, 0); break; case ITEM: case BLOCK: - for (final Material material : Material.values()) - { - try - { + for (final Material material : Material.values()) { + try { player.setStatistic(statistic, material, 0); } - catch (final IllegalArgumentException ignored) {} + catch (final IllegalArgumentException ignored) { + } } break; case ENTITY: - for (final EntityType entityType : EntityType.values()) - { - try - { + for (final EntityType entityType : EntityType.values()) { + try { player.setStatistic(statistic, entityType, 0); } - catch (final Exception ignored) {} + catch (final Exception ignored) { + } } break; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java index cc9f169..070a6b1 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutCommand.java @@ -31,35 +31,32 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.other.about; -import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import eu.carrade.amaury.quartzsurvivalgames.utils.CommandUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.components.i18n.I18n; -@CommandInfo (name = "about") -public class AboutCommand extends Command -{ +@CommandInfo(name = "about") +public class AboutCommand extends Command { @Override - protected void run() - { + protected void run() { final AboutModule about = QSG.module(AboutModule.class); CommandUtils.displaySeparator(sender); - info(I.t("{yellow}{0} - version {1}", about.getPluginName(), about.getVersion()) + " - " + about.getStability().toString().toLowerCase()); + info(I.t("{yellow}{0} - version {1}", about.getPluginName(), about.getVersion()) + " - " + + about.getStability().toString().toLowerCase()); info(I.t("Plugin made with love by {0}.", about.getFormattedAuthors())); - if (about.getGitVersion() != null) - { + if (about.getGitVersion() != null) { info(I.t("Build number: {0}.", about.getGitVersion())); - } - else - { + } else { info(I.t("Build number not available.")); } @@ -67,8 +64,10 @@ protected void run() info(""); info(I.t("{aqua}------ Translations ------")); - info(I.t("Current language: {0} (translated by {1}).", I18n.getPrimaryLocale(), I18n.getTranslationTeam(I18n.getPrimaryLocale()))); - info(I.t("Fallback language: {0} (translated by {1}).", I18n.getFallbackLocale(), I18n.getTranslationTeam(I18n.getFallbackLocale()))); + info(I.t("Current language: {0} (translated by {1}).", I18n.getPrimaryLocale(), + I18n.getTranslationTeam(I18n.getPrimaryLocale()))); + info(I.t("Fallback language: {0} (translated by {1}).", I18n.getFallbackLocale(), + I18n.getTranslationTeam(I18n.getFallbackLocale()))); info(""); info(I.t("{aqua}------ License ------")); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java index 7d48b36..4a51b58 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/other/about/AboutModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.other.about; import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; @@ -43,59 +44,52 @@ import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - import java.io.IOException; import java.net.URL; import java.util.Collections; import java.util.List; import java.util.jar.Attributes; import java.util.jar.Manifest; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; -@ModuleInfo ( +@ModuleInfo( name = "About", description = "Provides information about this plugin.", category = ModuleCategory.OTHER, icon = Material.BOOK ) -public class AboutModule extends QSGModule -{ - private String shortName = "Quartz Survival Games"; +public class AboutModule extends QSGModule { + private final String shortName = "Quartz Survival Games"; private String version = null; private Stability stability = null; private String gitVersion = null; private String authors = null; @Override - protected void onEnable() - { + protected void onEnable() { computeVersion(); computeGitVersion(); computeFormattedAuthors(); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(AboutCommand.class); } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { - if (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT) - { + public void injectIntoSidebar(Player player, SidebarInjector injector) { + if (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT) { injector.injectLines( SidebarInjector.SidebarPriority.VERY_BOTTOM, true, false, ChatColor.GRAY + shortName + " " + version ); - if (getVersion() != null) - { + if (getVersion() != null) { injector.injectLines( SidebarInjector.SidebarPriority.VERY_BOTTOM, false, @@ -103,10 +97,8 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) ); } - if (stability != Stability.STABLE) - { - switch (stability) - { + if (stability != Stability.STABLE) { + switch (stability) { case BETA: injector.injectLines( SidebarInjector.SidebarPriority.VERY_BOTTOM, @@ -127,45 +119,36 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) } } - public String getPluginName() - { + public String getPluginName() { return QSG.get().getDescription().getDescription(); } - public String getShortPluginName() - { + public String getShortPluginName() { return shortName; } - public String getVersion() - { + public String getVersion() { return version; } - public Stability getStability() - { + public Stability getStability() { return stability; } - public String getGitVersion() - { + public String getGitVersion() { return gitVersion; } - public List<String> getAuthors() - { + public List<String> getAuthors() { return QSG.get().getDescription().getAuthors(); } - public String getFormattedAuthors() - { + public String getFormattedAuthors() { return authors; } - private void computeGitVersion() - { - try - { + private void computeGitVersion() { + try { final Class<? extends QuartzSurvivalGames> clazz = QSG.get().getClass(); final String className = clazz.getSimpleName() + ".class"; final String classPath = clazz.getResource(className).toString(); @@ -180,28 +163,21 @@ private void computeGitVersion() gitVersion = attr.getValue("Git-Commit"); } } - catch (IOException e) - { + catch (IOException e) { // Build not available. } } - private void computeFormattedAuthors() - { + private void computeFormattedAuthors() { final StringBuilder authors = new StringBuilder(); final List<String> listAuthors = getAuthors(); - for (final String author : listAuthors) - { - if (!author.equals(listAuthors.get(0))) - { - if (author.equals(listAuthors.get(listAuthors.size() - 1))) - { + for (final String author : listAuthors) { + if (!author.equals(listAuthors.get(0))) { + if (author.equals(listAuthors.get(listAuthors.size() - 1))) { /// The "and" in the authors list (like "Amaury Carrade, azenet and João Roda") authors.append(" ").append(I.tc("authors_list", "and")).append(" "); - } - else - { + } else { authors.append(", "); } } @@ -212,16 +188,13 @@ private void computeFormattedAuthors() this.authors = authors.toString(); } - private void computeVersion() - { + private void computeVersion() { final String[] versionParts = QSG.get().getDescription().getVersion().split("-", 2); version = versionParts[0]; - if (versionParts.length >= 2) - { - switch (versionParts[1].trim().toLowerCase()) - { + if (versionParts.length >= 2) { + switch (versionParts[1].trim().toLowerCase()) { case "dev": case "alpha": stability = Stability.ALPHA; @@ -238,13 +211,12 @@ private void computeVersion() default: stability = Stability.STABLE; } + } else { + stability = Stability.STABLE; } - - else stability = Stability.STABLE; } - public enum Stability - { + public enum Stability { STABLE, BETA, ALPHA } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java index e429bf9..0136982 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AllianceRequest.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -45,18 +46,24 @@ import fr.zcraft.quartzteams.QuartzTeam; import fr.zcraft.quartzteams.QuartzTeams; import fr.zcraft.quartzteams.colors.TeamColor; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; import me.cassayre.florian.hawk.report.ReportEvent; import org.apache.commons.lang3.Validate; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class AllianceRequest -{ +public class AllianceRequest { private final GameModule game; private final AlliancesModule alliances; @@ -71,8 +78,7 @@ public class AllianceRequest private final RequestError requestError; - public AllianceRequest(final UUID requesterID, final UUID requestedTo) - { + public AllianceRequest(final UUID requesterID, final UUID requestedTo) { Validate.notNull(requesterID, "The requester must not be null"); Validate.notNull(requestedTo, "The requested must not be null"); @@ -103,48 +109,33 @@ public AllianceRequest(final UUID requesterID, final UUID requestedTo) // We first check for errors - if (requestedTeam.equals(requesterTeam)) - { + if (requestedTeam.equals(requesterTeam)) { requestError = RequestError.BOTH_IN_THE_SAME_ALLIANCE; - } - else if (requesterPlayer == null || !requesterPlayer.isOnline() || requestedPlayer == null || !requestedPlayer.isOnline()) - { + } else if (requesterPlayer == null || !requesterPlayer.isOnline() || requestedPlayer == null || + !requestedPlayer.isOnline()) { requestError = RequestError.TOO_FAR; - } - else if (!requesterPlayer.getWorld().equals(requestedPlayer.getWorld())) - { + } else if (!requesterPlayer.getWorld().equals(requestedPlayer.getWorld())) { requestError = RequestError.TOO_FAR; - } - else if (requesterPlayer.getLocation().distanceSquared(requestedPlayer.getLocation()) > Math.pow(Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get(), 2)) - { + } else if (requesterPlayer.getLocation().distanceSquared(requestedPlayer.getLocation()) > + Math.pow(Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get(), 2)) { requestError = RequestError.TOO_FAR; - } - else if (!checkAlliancesLeft(requesterID)) - { + } else if (!checkAlliancesLeft(requesterID)) { requestError = RequestError.REQUESTER_OUT_OF_ALLIANCES; - } - else if (!checkAlliancesLeft(requestedTo)) - { + } else if (!checkAlliancesLeft(requestedTo)) { requestError = RequestError.REQUESTED_OUT_OF_ALLIANCES; - } - else if (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1) - { + } else if (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1) { requestError = RequestError.BOTH_IN_A_DIFFERENT_ALLIANCE; - } - else if (!checkFutureAllianceSize()) - { + } else if (!checkFutureAllianceSize()) { requestError = RequestError.FUTURE_ALLIANCE_TOO_BIG; - } - else if (!checkGameEnd()) - { + } else if (!checkGameEnd()) { requestError = RequestError.WOULD_END_THE_GAME; - } - else - { + } else { requestError = RequestError.OK; } - if (requestError != RequestError.OK) return; + if (requestError != RequestError.OK) { + return; + } // Okay so here we have a valid request. Yay! @@ -165,8 +156,7 @@ else if (!checkGameEnd()) approvalsIDs.put(requestedTo, false); - if (requesterTeam.size() > 1 || requestedTeam.size() > 1) - { + if (requesterTeam.size() > 1 || requestedTeam.size() > 1) { (requestedTeam.size() > 1 ? requestedTeam : requesterTeam) .getPlayers().stream() .map(OfflinePlayer::getUniqueId) @@ -182,8 +172,7 @@ else if (!checkGameEnd()) /** * Sends an approval request to the players. */ - public void sendApprovalRequests() - { + public void sendApprovalRequests() { checkError(); final QSGSound[] jingle = new QSGSound[] { @@ -193,76 +182,78 @@ public void sendApprovalRequests() }; approvalsIDs.keySet().stream() - .map(Bukkit::getPlayer) - .filter(Objects::nonNull) - .forEach(player -> { - player.sendMessage(""); - - player.sendMessage(I.t("{green}{bold}{0} would like to join you in an alliance.", getName(requesterID))); - - if (!player.getUniqueId().equals(requestedID)) - { - player.sendMessage(I.t("{gray}This request was sent to {0}, but everyone in the alliance also need to accept.", getName(requestedID))); - } + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .forEach(player -> { + player.sendMessage(""); + + player.sendMessage( + I.t("{green}{bold}{0} would like to join you in an alliance.", getName(requesterID))); + + if (!player.getUniqueId().equals(requestedID)) { + player.sendMessage( + I.t("{gray}This request was sent to {0}, but everyone in the alliance also need to accept.", + getName(requestedID))); + } - player.sendMessage(""); + player.sendMessage(""); - RawMessage.send(player, new RawText(" ") - .then(I.t("{darkgreen}{bold}» {green}{bold}Accept {darkgreen}{bold}«")) + RawMessage.send(player, new RawText(" ") + .then(I.t("{darkgreen}{bold}» {green}{bold}Accept {darkgreen}{bold}«")) .command(RequestAnswerCommand.class, allianceRequestUUID.toString(), "yes") .hover(I.t("{green}{bold}Accept {green}this alliance")) - .then(" ") - .then(I.t("{darkred}{bold}» {red}{bold}Decline {darkred}{bold}«")) + .then(" ") + .then(I.t("{darkred}{bold}» {red}{bold}Decline {darkred}{bold}«")) .command(RequestAnswerCommand.class, allianceRequestUUID.toString(), "no") .hover(I.t("{red}{bold}Decline {red}this alliance")) - .build() - ); + .build() + ); - player.sendMessage(""); + player.sendMessage(""); - for (int i = 0; i < jingle.length; i++) - { - final int index = i; - RunTask.later(() -> jingle[index].play(player), i * 5L); - } - }); + for (int i = 0; i < jingle.length; i++) { + final int index = i; + RunTask.later(() -> jingle[index].play(player), i * 5L); + } + }); } - public void registerApproval(final UUID approver, final boolean approval) - { + public void registerApproval(final UUID approver, final boolean approval) { checkError(); - if (!approvalsIDs.containsKey(approver)) - { + if (!approvalsIDs.containsKey(approver)) { throw new IllegalArgumentException("This player was not asked for approval"); } - if (!approval) - { + if (!approval) { denyAndClose(approver); - } - else - { + } else { approvalsIDs.put(approver, true); // Missing approvers for notifications final int missingApproversCount = (int) approvalsIDs.values().stream().filter(answer -> !answer).count(); final String missingApprovers = missingApproversCount > 0 - ? " " + I.tn("{gray}Still waiting for {0}'s answer.", "{gray}Still waiting for answers from: {0}.", missingApproversCount, String.join(", ", approvalsIDs.keySet().stream().filter(id -> !approvalsIDs.get(id)).map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName).collect(Collectors.toSet()))) + ? " " + I.tn("{gray}Still waiting for {0}'s answer.", "{gray}Still waiting for answers from: {0}.", + missingApproversCount, String.join(", ", + approvalsIDs.keySet().stream().filter(id -> !approvalsIDs.get(id)) + .map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName) + .collect(Collectors.toSet()))) : ""; // We notify the player who just approved the request. - if (missingApproversCount > 0) - { + if (missingApproversCount > 0) { final Player player = Bukkit.getPlayer(approver); - if (player != null && player.isOnline()) - { + if (player != null && player.isOnline()) { final UUID allianceWith; - if (requesterTeam.containsPlayer(player)) allianceWith = requestedID; - else allianceWith = requesterID; + if (requesterTeam.containsPlayer(player)) { + allianceWith = requestedID; + } else { + allianceWith = requesterID; + } - player.sendMessage(I.t("You accepted the request for an alliance with {0}.", getName(allianceWith))); + player.sendMessage( + I.t("You accepted the request for an alliance with {0}.", getName(allianceWith))); } } @@ -271,43 +262,34 @@ public void registerApproval(final UUID approver, final boolean approval) final QuartzTeam notifiedTeam; final UUID allianceWith; - if (alliances.allianceSize(requesterTeam) > 1) - { + if (alliances.allianceSize(requesterTeam) > 1) { notifiedTeam = requesterTeam; allianceWith = requestedID; - } - else if (alliances.allianceSize(requestedTeam) > 1) - { + } else if (alliances.allianceSize(requestedTeam) > 1) { notifiedTeam = requestedTeam; allianceWith = requesterID; - } - else - { - notifiedTeam = null; - allianceWith = null; + } else { + notifiedTeam = null; + allianceWith = null; } - if (notifiedTeam != null) - { - for (Player player : requesterTeam.getOnlinePlayers()) - { - if (game.isAlive(player) && !player.getUniqueId().equals(approver)) - { - player.sendMessage(I.t("{green}The request for an alliance with {0} was accepted by {1}.", getName(allianceWith), getName(approver)) + missingApprovers); + if (notifiedTeam != null) { + for (Player player : requesterTeam.getOnlinePlayers()) { + if (game.isAlive(player) && !player.getUniqueId().equals(approver)) { + player.sendMessage(I.t("{green}The request for an alliance with {0} was accepted by {1}.", + getName(allianceWith), getName(approver)) + missingApprovers); } } } // If everyone agree - if (approvalsIDs.values().stream().allMatch(answer -> answer)) - { + if (approvalsIDs.values().stream().allMatch(answer -> answer)) { applyApprovedRequest(); } } } - private void denyAndClose(final UUID closedBy) - { + private void denyAndClose(final UUID closedBy) { // If one of the players deny the request, it is closed. All players must agree. // If the request was closed by one of the members of an existing alliance, players // *of this alliance only* are notified. @@ -318,28 +300,24 @@ private void denyAndClose(final UUID closedBy) final OfflinePlayer allianceWith; final OfflinePlayer closer = Bukkit.getOfflinePlayer(closedBy); - if (alliances.allianceSize(requesterTeam) > 1 && requesterTeam.containsPlayer(closedBy)) - { + if (alliances.allianceSize(requesterTeam) > 1 && requesterTeam.containsPlayer(closedBy)) { notifiedTeam = requesterTeam; allianceWith = Bukkit.getOfflinePlayer(requestedID); - } - else if (alliances.allianceSize(requestedTeam) > 1 && requestedTeam.containsPlayer(closedBy)) - { + } else if (alliances.allianceSize(requestedTeam) > 1 && requestedTeam.containsPlayer(closedBy)) { notifiedTeam = requestedTeam; allianceWith = Bukkit.getOfflinePlayer(requesterID); - } - else - { + } else { notifiedTeam = null; allianceWith = null; } - if (notifiedTeam != null) - { + if (notifiedTeam != null) { notifiedTeam.getOnlinePlayers().stream().filter(player -> !player.getUniqueId().equals(closedBy)).forEach( player -> { player.sendMessage(""); - player.sendMessage(I.t("{red}The alliance with {0} was {bold}denied{red} by {1}.", allianceWith.getName(), closer.getName())); + player.sendMessage( + I.t("{red}The alliance with {0} was {bold}denied{red} by {1}.", allianceWith.getName(), + closer.getName())); player.sendMessage(""); } ); @@ -351,8 +329,7 @@ else if (alliances.allianceSize(requestedTeam) > 1 && requestedTeam.containsPlay } } - private void applyApprovedRequest() - { + private void applyApprovedRequest() { // In all cases we unregisters this request. alliances.unregisterRequest(this); @@ -363,13 +340,15 @@ private void applyApprovedRequest() if (!checkAlliancesLeft(requestedID) || !checkAlliancesLeft(requesterID) || !checkGameEnd() - || (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1)) - { - QSG.log(AlliancesModule.class).warning("The alliance request from {0} to {1} was about to be approved but is now invalid.", getName(requesterID), getName(requestedID)); + || (alliances.allianceSize(requestedTeam) > 1 && alliances.allianceSize(requesterTeam) > 1)) { + QSG.log(AlliancesModule.class) + .warning("The alliance request from {0} to {1} was about to be approved but is now invalid.", + getName(requesterID), getName(requestedID)); Stream.of(requesterID, requestedID) .map(Bukkit::getPlayer).filter(Objects::nonNull) - .forEach(player -> player.sendMessage(I.t("{ce}This alliance request is no longer valid. Please re-send it."))); + .forEach(player -> player + .sendMessage(I.t("{ce}This alliance request is no longer valid. Please re-send it."))); return; } @@ -408,21 +387,21 @@ private void applyApprovedRequest() allianceTeam.getOnlinePlayers().forEach(player -> { player.sendMessage(""); - if (allianceTeam.size() == 2) - { - player.sendMessage(I.t("{green}{bold}You are now allied with {0}!", allianceTeam.getPlayers().stream().filter(p -> !p.getUniqueId().equals(player.getUniqueId())).findAny().map(OfflinePlayer::getName).orElse("<Unknown>"))); - player.sendMessage(I.t("{green}Your objective is to win together. But chhhh! Other players are not aware of your alliance...")); - } - else - { + if (allianceTeam.size() == 2) { + player.sendMessage(I.t("{green}{bold}You are now allied with {0}!", + allianceTeam.getPlayers().stream().filter(p -> !p.getUniqueId().equals(player.getUniqueId())) + .findAny().map(OfflinePlayer::getName).orElse("<Unknown>"))); + player.sendMessage( + I.t("{green}Your objective is to win together. But chhhh! Other players are not aware of your alliance...")); + } else { player.sendMessage(I.t("{green}{bold}The alliance expands!")); - player.sendMessage(I.t("{gray}Players in the alliance: {0}", String.join(", ", allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())))); + player.sendMessage(I.t("{gray}Players in the alliance: {0}", String.join(", ", + allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())))); } player.sendMessage(""); - for (int i = 0; i < jingle.length; i++) - { + for (int i = 0; i < jingle.length; i++) { final int index = i; RunTask.later(() -> jingle[index].play(player), i * 3L); } @@ -435,7 +414,8 @@ private void applyApprovedRequest() "{0} succeeded! A new alliance was created between these players: {1}.", this, String.join(", ", allianceTeam.getPlayers().stream() - .map(player -> player.getName() + " (a=" + alliances.getAlliancesLeft(player.getUniqueId()) + ")") + .map(player -> player.getName() + " (a=" + alliances.getAlliancesLeft(player.getUniqueId()) + + ")") .collect(Collectors.toSet()) ) ); @@ -444,8 +424,7 @@ private void applyApprovedRequest() // Also in the timeline QSG.ifLoaded(HawkModule.class, hawk -> { - if (allianceTeam.size() == 2) - { + if (allianceTeam.size() == 2) { final Iterator<OfflinePlayer> players = allianceTeam.getPlayers().iterator(); hawk.getReport().record(ReportEvent.withIcon( @@ -453,27 +432,24 @@ private void applyApprovedRequest() I.t("Between {0} and {1}", players.next().getName(), players.next().getName()), "block-structure-block-data" )); - } - else - { - @SuppressWarnings("OptionalGetWithoutIsPresent") - final OfflinePlayer joiningPlayer = requestedTeam.size() == 1 ? requestedTeam.getPlayers().stream().findFirst().get() : requesterTeam.getPlayers().stream().findFirst().get(); - - final List<String> playersNames = allianceTeam.getPlayers().stream().filter(player -> !player.equals(joiningPlayer)).map(OfflinePlayer::getName).collect(Collectors.toList()); + } else { + @SuppressWarnings("OptionalGetWithoutIsPresent") final OfflinePlayer joiningPlayer = + requestedTeam.size() == 1 ? requestedTeam.getPlayers().stream().findFirst().get() : + requesterTeam.getPlayers().stream().findFirst().get(); + + final List<String> playersNames = + allianceTeam.getPlayers().stream().filter(player -> !player.equals(joiningPlayer)) + .map(OfflinePlayer::getName).collect(Collectors.toList()); final int size = playersNames.size(); final StringBuilder sentence = new StringBuilder(size * 16); - for (int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { sentence.append(playersNames.get(i)); - if (i == size - 2) - { + if (i == size - 2) { sentence.append(" ").append(I.t("and")).append(" "); - } - else if (i != size - 1) - { + } else if (i != size - 1) { sentence.append(", "); } } @@ -488,7 +464,8 @@ else if (i != size - 1) allianceTeam.getPlayers().forEach(player -> hawk.getReport().getPlayer(player).setTagLine( I.t("Allied"), null, - I.t("Players in the (latest) alliance: {0}", String.join(", ", allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet()))) + I.t("Players in the (latest) alliance: {0}", String.join(", ", + allianceTeam.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet()))) )); }); } @@ -496,32 +473,28 @@ else if (i != size - 1) /** * @return The request's UUID, used for request identification in commands. */ - public UUID getUniqueId() - { + public UUID getUniqueId() { return allianceRequestUUID; } /** * @return The request sender's UUID. */ - public UUID getRequesterID() - { + public UUID getRequesterID() { return requesterID; } /** * @return The request's target UUID. */ - public UUID getRequestedID() - { + public UUID getRequestedID() { return requestedID; } /** * @return The error for this request (including « OK »). */ - public RequestError getError() - { + public RequestError getError() { return requestError; } @@ -531,8 +504,7 @@ public RequestError getError() * @param playerID A player's UUID. * @return The player name as a string. */ - private String getName(final UUID playerID) - { + private String getName(final UUID playerID) { return Optional.of(Bukkit.getOfflinePlayer(playerID)).map(OfflinePlayer::getName).orElse("<Unknown>"); } @@ -542,9 +514,9 @@ private String getName(final UUID playerID) * * @return {@code true} if the future size is OK. */ - private boolean checkFutureAllianceSize() - { - return alliances.allianceSize(requestedTeam) + alliances.allianceSize(requesterTeam) <= Config.MAX_PLAYERS_PER_ALLIANCE.get(); + private boolean checkFutureAllianceSize() { + return alliances.allianceSize(requestedTeam) + alliances.allianceSize(requesterTeam) <= + Config.MAX_PLAYERS_PER_ALLIANCE.get(); } /** @@ -553,8 +525,7 @@ private boolean checkFutureAllianceSize() * @param checkedPlayerID The player to check. * @return {@code true} if there are enough alliances left. */ - private boolean checkAlliancesLeft(final UUID checkedPlayerID) - { + private boolean checkAlliancesLeft(final UUID checkedPlayerID) { return alliances.getAlliancesLeft(checkedPlayerID) >= 1; } @@ -563,8 +534,7 @@ private boolean checkAlliancesLeft(final UUID checkedPlayerID) * * @return {@code true} if this alliance would <strong>not</strong> end the game. */ - private boolean checkGameEnd() - { + private boolean checkGameEnd() { final Set<UUID> playersInFutureAlliance = Stream.of(requestedTeam.getPlayers(), requesterTeam.getPlayers()) .flatMap(Collection::stream) .map(OfflinePlayer::getUniqueId) @@ -575,23 +545,24 @@ private boolean checkGameEnd() /** * Throws an {@link IllegalStateException} if the request has errored. */ - private void checkError() - { - if (requestError != RequestError.OK) throw new IllegalStateException("This alliance request errored."); + private void checkError() { + if (requestError != RequestError.OK) { + throw new IllegalStateException("This alliance request errored."); + } } @Override - public String toString() - { - return "AllianceRequest [from " + getName(requesterID) + " (n=" + requesterTeam.size() + ", a=" + alliances.getAlliancesLeft(requesterID) + ") to " + getName(requestedID) + " (n=" + requesterTeam.size() + ", a=" + alliances.getAlliancesLeft(requesterID) + ")]"; + public String toString() { + return "AllianceRequest [from " + getName(requesterID) + " (n=" + requesterTeam.size() + ", a=" + + alliances.getAlliancesLeft(requesterID) + ") to " + getName(requestedID) + " (n=" + + requesterTeam.size() + ", a=" + alliances.getAlliancesLeft(requesterID) + ")]"; } /** * The request error state. If not OK, all methods except {@link #getError()} will throw * an {@link IllegalStateException}. */ - public enum RequestError - { + public enum RequestError { OK, TOO_FAR, REQUESTER_OUT_OF_ALLIANCES, diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java index 9fbca36..8bac36f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/AlliancesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; import com.google.common.collect.ImmutableMap; @@ -50,16 +51,21 @@ import fr.zcraft.quartzteams.QuartzTeam; import fr.zcraft.quartzteams.QuartzTeams; import fr.zcraft.quartzteams.colors.TeamColor; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import java.util.*; -import java.util.stream.Collectors; - -@ModuleInfo ( +@ModuleInfo( name = "Alliances Scenario", short_description = "Provides an alliances-based game, where players form alliances only " + "by meeting in the game, everyone being alone at the beginning.", @@ -84,16 +90,13 @@ settings = Config.class, can_be_loaded_late = false ) -public class AlliancesModule extends QSGModule -{ - private GameModule game = null; - +public class AlliancesModule extends QSGModule { private final Map<UUID, Integer> alliancesLeft = new HashMap<>(); private final Map<UUID, AllianceRequest> ongoingRequests = new HashMap<>(); + private GameModule game = null; @Override - protected void onEnable() - { + protected void onEnable() { game = QSG.module(GameModule.class); // We update some settings @@ -102,13 +105,14 @@ protected void onEnable() eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.SIDEBAR.TITLE.USE_TEAM_NAME.set(true); QuartzTeams.settings() - .setTeamsOptions( - eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES.get(), - false, - false, - true // Important! As we use the same team names for lots of teams, as titles. - ) - .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_ALLIANCE.get()); + .setTeamsOptions( + eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.Config.CAN_SEE_FRIENDLY_INVISIBLES + .get(), + false, + false, + true // Important! As we use the same team names for lots of teams, as titles. + ) + .setMaxPlayersPerTeam(Config.MAX_PLAYERS_PER_ALLIANCE.get()); QSG.ifLoaded(HawkModule.class, hawk -> hawk.getReport().settings().enableSummary(true, true, false)); @@ -118,14 +122,12 @@ protected void onEnable() } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList(AllianceRequestCommand.class, RequestAnswerCommand.class); } @Override - public Map<String, Class<? extends Command>> getCommandsAliases() - { + public Map<String, Class<? extends Command>> getCommandsAliases() { return ImmutableMap.of( "alliance", AllianceRequestCommand.class, "a", AllianceRequestCommand.class @@ -135,10 +137,10 @@ public Map<String, Class<? extends Command>> getCommandsAliases() /** * Inits the count of left alliances to the configured max if not already stored. + * * @param playerID The player to initialize the count for. */ - private void initAlliancesCountIfRequired(final UUID playerID) - { + private void initAlliancesCountIfRequired(final UUID playerID) { alliancesLeft.putIfAbsent(playerID, Config.ALLIANCES_PER_PLAYER.get()); } @@ -146,10 +148,9 @@ private void initAlliancesCountIfRequired(final UUID playerID) * Consumes an amount of alliances for the given player. * * @param playerID The player's ID. - * @param amount The amount to consume. + * @param amount The amount to consume. */ - public void consumeAlliance(final UUID playerID, final int amount) - { + public void consumeAlliance(final UUID playerID, final int amount) { initAlliancesCountIfRequired(playerID); alliancesLeft.put(playerID, Math.max(0, alliancesLeft.get(playerID) - amount)); } @@ -160,8 +161,7 @@ public void consumeAlliance(final UUID playerID, final int amount) * @param playerID The player's ID. * @return The amount of alliances left. */ - public int getAlliancesLeft(final UUID playerID) - { + public int getAlliancesLeft(final UUID playerID) { initAlliancesCountIfRequired(playerID); return alliancesLeft.get(playerID); } @@ -171,61 +171,55 @@ public int getAlliancesLeft(final UUID playerID) * borrows them and returns {@code true}. Else, returns {@code false}. * * @param playerID The player's ID. - * @param amount The amount of alliances to borrow. - * + * @param amount The amount of alliances to borrow. * @return {@code true} if they could (and were) borrowed. */ - public boolean consumeAlliancesIfPossible(final UUID playerID, final int amount) - { - if (getAlliancesLeft(playerID) >= amount) - { + public boolean consumeAlliancesIfPossible(final UUID playerID, final int amount) { + if (getAlliancesLeft(playerID) >= amount) { consumeAlliance(playerID, amount); return true; + } else { + return false; } - else return false; } - public void registerRequest(final AllianceRequest request) - { + public void registerRequest(final AllianceRequest request) { ongoingRequests.put(request.getUniqueId(), request); } - public void unregisterRequest(final AllianceRequest request) - { + public void unregisterRequest(final AllianceRequest request) { ongoingRequests.remove(request.getUniqueId()); } - public AllianceRequest getRequestByID(final UUID requestID) - { + public AllianceRequest getRequestByID(final UUID requestID) { return ongoingRequests.get(requestID); } - public Set<AllianceRequest> getRequestsBySender(final UUID requestSenderID) - { + public Set<AllianceRequest> getRequestsBySender(final UUID requestSenderID) { return ongoingRequests.values().stream() .filter(request -> request.getRequesterID().equals(requestSenderID)) .collect(Collectors.toSet()); } - public AllianceRequest getRequestByCouple(final UUID requestSenderID, final UUID requestedID) - { + public AllianceRequest getRequestByCouple(final UUID requestSenderID, final UUID requestedID) { return ongoingRequests.values().stream() .filter(request -> request.getRequesterID().equals(requestSenderID)) .filter(request -> request.getRequestedID().equals(requestedID)) .findAny().orElse(null); } - public int allianceSize(UUID playerID) - { + public int allianceSize(UUID playerID) { final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(playerID); - if (team != null) return allianceSize(team); - else return 1; + if (team != null) { + return allianceSize(team); + } else { + return 1; + } } - public int allianceSize(final QuartzTeam team) - { + public int allianceSize(final QuartzTeam team) { return (int) team.getPlayers().stream().filter(game::isAlive).count(); } @@ -235,9 +229,8 @@ public int allianceSize(final QuartzTeam team) * indistinguishable, and the game will be considered as a teams game, even with * everyone in solo. */ - @EventHandler (priority = EventPriority.LOWEST) - private void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) - { + @EventHandler(priority = EventPriority.LOWEST) + private void onPreSpawnSelection(final BeforeTeleportationPhaseEvent ev) { final SpectatorsModule spectators = QSG.module(SpectatorsModule.class); new HashSet<>(QuartzTeams.get().getTeams()).forEach(QuartzTeam::deleteTeam); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java index 2d9700a..3a18c6b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/Config.java @@ -31,24 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { static public ConfigurationItem<Integer> ALLIANCES_PER_PLAYER = item("alliances-per-player", 2); static public ConfigurationItem<Integer> MAX_PLAYERS_PER_ALLIANCE = item("max-players-per-alliance", 3); + static public ConfigurationItem<Integer> MAX_DISTANCE_TO_CREATE_AN_ALLIANCE = + item("max-distance-to-create-an-alliance", 60); - static public ConfigurationItem<Integer> MAX_DISTANCE_TO_CREATE_AN_ALLIANCE = item("max-distance-to-create-an-alliance", 60); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java index 0ac7aff..6dc4d23 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/TeamsPermissionsChecker.java @@ -31,26 +31,23 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances; import fr.zcraft.quartzteams.QuartzTeamsPermission; import fr.zcraft.quartzteams.permissions.PermissionsChecker; import org.bukkit.permissions.Permissible; -public class TeamsPermissionsChecker implements PermissionsChecker -{ - private PermissionsChecker delegate; +public class TeamsPermissionsChecker implements PermissionsChecker { + private final PermissionsChecker delegate; - public TeamsPermissionsChecker(PermissionsChecker delegate) - { + public TeamsPermissionsChecker(PermissionsChecker delegate) { this.delegate = delegate; } @Override - public boolean hasPermission(Permissible permissible, QuartzTeamsPermission permission) - { - switch (permission) - { + public boolean hasPermission(Permissible permissible, QuartzTeamsPermission permission) { + switch (permission) { case CREATE_TEAM: case DELETE_TEAM: diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java index 4c2b3fc..c5ee697 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/AllianceRequestCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -44,24 +45,18 @@ import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzteams.QuartzTeams; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; -@CommandInfo (name = "alliance-request", usageParameters = "<player>", aliases = {"alliancerequest", "alliance", "ally"}) -public class AllianceRequestCommand extends Command -{ +@CommandInfo(name = "alliance-request", usageParameters = "<player>", aliases = {"alliancerequest", "alliance", "ally"}) +public class AllianceRequestCommand extends Command { @Override - protected void run() throws CommandException - { - if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) - { + protected void run() throws CommandException { + if (QSG.module(GameModule.class).currentPhaseBefore(GamePhase.IN_GAME)) { error(I.t("The game is not started.")); - } - else if (args.length == 0) - { + } else if (args.length == 0) { throwInvalidArgument(I.t("You must provide a player name.")); } @@ -69,13 +64,11 @@ else if (args.length == 0) final Player requested = getPlayerParameter(0); - if (requested.getUniqueId().equals(playerSender().getUniqueId())) - { + if (requested.getUniqueId().equals(playerSender().getUniqueId())) { error(I.t("You cannot create an alliance with yourself.")); - } - else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.getUniqueId()) != null) - { - error(I.t("You already have an ongoing alliance request sent to {0}. Please be patient!", requested.getName())); + } else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.getUniqueId()) != null) { + error(I.t("You already have an ongoing alliance request sent to {0}. Please be patient!", + requested.getName())); } final AllianceRequest request = new AllianceRequest(playerSender().getUniqueId(), requested.getUniqueId()); @@ -85,10 +78,10 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge // The rule to send error messages is: no answer should not be distinguishable from // errors linked to existing alliances, because the alliances are secret. - switch (request.getError()) - { + switch (request.getError()) { case TOO_FAR: - error(I.t("{0} is too far. You must be within {1} blocks of each other.", requested.getName(), Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get())); + error(I.t("{0} is too far. You must be within {1} blocks of each other.", requested.getName(), + Config.MAX_DISTANCE_TO_CREATE_AN_ALLIANCE.get())); return; case REQUESTER_OUT_OF_ALLIANCES: @@ -99,8 +92,12 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge yourRequestHasBeenSent(requested); requested.sendMessage(""); - requested.sendMessage(I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because you have no alliance left.", sender.getName())); - requested.sendMessage(I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", sender.getName())); + requested.sendMessage( + I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because you have no alliance left.", + sender.getName())); + requested.sendMessage( + I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", + sender.getName())); requested.sendMessage(""); return; @@ -109,20 +106,22 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge // Here, if the player is solo, we say that the request was sent and we warn the // other alliance members. If the player is in an alliance he know its size and // the other one is solo. - if (alliances.allianceSize(playerSender().getUniqueId()) == 1) - { + if (alliances.allianceSize(playerSender().getUniqueId()) == 1) { yourRequestHasBeenSent(requested); QuartzTeams.get().getTeamForPlayer(requested).getOnlinePlayers().forEach(teammate -> { teammate.sendMessage(""); - teammate.sendMessage(I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because your alliance is already at full capacity.", sender.getName())); - teammate.sendMessage(I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", sender.getName())); + teammate.sendMessage( + I.t("{gray}{bold}{0} just sent you an alliance request, but you cannot accept it because your alliance is already at full capacity.", + sender.getName())); + teammate.sendMessage( + I.t("{gray}{0} is not aware of this, but I preferred to warn you so that you would not be caught off guard if he or she mentions it.", + sender.getName())); teammate.sendMessage(""); }); - } - else - { - error(I.t("You cannot send a request alliance as your alliance is already at full capacity. Don't be too greedy!")); + } else { + error(I.t( + "You cannot send a request alliance as your alliance is already at full capacity. Don't be too greedy!")); } return; @@ -149,14 +148,18 @@ else if (alliances.getRequestByCouple(playerSender().getUniqueId(), requested.ge } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingPlayerNames(Bukkit.getOnlinePlayers().stream().filter(player -> !player.equals(sender)).collect(Collectors.toSet()), args[0]); - else return null; + protected List<String> complete() { + if (args.length == 1) { + return getMatchingPlayerNames( + Bukkit.getOnlinePlayers().stream().filter(player -> !player.equals(sender)) + .collect(Collectors.toSet()), + args[0]); + } else { + return null; + } } - private void yourRequestHasBeenSent(final Player to) - { + private void yourRequestHasBeenSent(final Player to) { info(""); success(I.t("{bold}Your request has been sent to {0}.", to.getName())); success(I.t("Wait until it is accepted. Let's hope you don't hear only silence...")); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java index a330f42..16d32db 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/scenarii/alliances/commands/RequestAnswerCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AllianceRequest; @@ -40,48 +41,45 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.entity.Player; - import java.util.UUID; +import org.bukkit.entity.Player; -@CommandInfo (name = "alliance-request-answer", usageParameters = "<requestUUID> <yes|no> §8(internal)") -public class RequestAnswerCommand extends Command -{ +@CommandInfo(name = "alliance-request-answer", usageParameters = "<requestUUID> <yes|no> §8(internal)") +public class RequestAnswerCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length < 2) - { - QSG.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); - throwInvalidArgument(I.t("Invalid command usage. But, you shouldn't use this command directly. What are you doing?")); + protected void run() throws CommandException { + if (args.length < 2) { + QSG.log(AlliancesModule.class) + .info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + throwInvalidArgument( + I.t("Invalid command usage. But, you shouldn't use this command directly. What are you doing?")); } - try - { + try { final Player player = playerSender(); final UUID requestID = UUID.fromString(args[0]); final boolean answer = getBooleanParameter(1); final AllianceRequest request = QSG.module(AlliancesModule.class).getRequestByID(requestID); - if (request != null) - { - try - { + if (request != null) { + try { QSG.log(AlliancesModule.class).info("{0}: reply from {1}: {2}", request, player.getName(), answer); request.registerApproval(player.getUniqueId(), answer); } - catch (IllegalArgumentException e) - { - QSG.log(AlliancesModule.class).warning("{0}: {1} tried to reply {2} but was not in the approvers list.", request, player.getName(), answer); + catch (IllegalArgumentException e) { + QSG.log(AlliancesModule.class) + .warning("{0}: {1} tried to reply {2} but was not in the approvers list.", request, + player.getName(), answer); error(I.t("You weren't asked for your opinion regarding this request.")); } + } else { + error(I.t("This request has expired.")); } - else error(I.t("This request has expired.")); } - catch (IllegalArgumentException e) - { - QSG.log(AlliancesModule.class).info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); + catch (IllegalArgumentException e) { + QSG.log(AlliancesModule.class) + .info("{0} (badly) used the alliance-request-answer directly.", sender.getName()); throwInvalidArgument("Malformed UUID."); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java index 81ba9b6..09ab4bd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Cage.java @@ -1,20 +1,20 @@ /* * Copyright or © or Copr. AmauryCarrade (2015) - * + * * http://amaury.carrade.eu - * + * * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, + * abiding by the rules of distribution of free software. You can use, * modify and/ or redistribute the software under the terms of the CeCILL-B * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * + * "http://www.cecill.info". + * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited - * liability. - * + * liability. + * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the * software by the user in light of its specific status of free software, @@ -22,17 +22,19 @@ * therefore means that it is reserved for developers and experienced * professionals having in-depth computer knowledge. Users are therefore * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; +import fr.zcraft.quartzlib.tools.items.ColorableMaterial; +import fr.zcraft.quartzlib.tools.items.ItemUtils; import fr.zcraft.quartzteams.QuartzTeam; -import fr.zcraft.quartzteams.colors.ColorsUtils; import java.util.HashMap; import java.util.Map; import org.bukkit.ChatColor; @@ -43,20 +45,15 @@ import org.bukkit.block.data.BlockData; -public class Cage -{ +public class Cage { private final Location baseLocation; - - private Material material = Material.BARRIER; - private final boolean buildCeiling; private final boolean visibleWalls; - + private final Map<Location, SimpleBlock> blocksBuilt = new HashMap<>(); + private Material material = Material.BARRIER; private int radius = 1; private int internalHeight = 3; - private boolean built = false; - private final Map<Location, SimpleBlock> blocksBuilt = new HashMap<>(); /** @@ -64,45 +61,85 @@ public class Cage * teleported to be on the ground). * @param buildCeiling {@code true} to build the ceiling of the cage. */ - public Cage(Location baseLocation, boolean buildCeiling, boolean visibleWalls) - { + public Cage(Location baseLocation, boolean buildCeiling, boolean visibleWalls) { this.baseLocation = baseLocation; this.buildCeiling = buildCeiling; this.visibleWalls = visibleWalls; } + /** + * Creates a Cage instance for the given team. + * + * @param team The team. Can be null (fallbacks to white if a color is needed). + * @param location Where the cage should be built. + * @return A Cage + */ + static public Cage createInstanceForTeam(final QuartzTeam team, final Location location) { + final Material cageMaterial; + + switch (Config.TYPE.get()) { + case TEAM_COLOR_TRANSPARENT: + cageMaterial = ItemUtils.colorize( + ColorableMaterial.STAINED_GLASS, team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE); + break; + + case TEAM_COLOR_SOLID: + cageMaterial = ItemUtils.colorize(ColorableMaterial.TERRACOTTA, team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE); + break; + + case TEAM_COLOR_FANCY: + cageMaterial = ItemUtils.colorize(ColorableMaterial.GLAZED_TERRACOTTA, team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE); + break; + + case CUSTOM: + cageMaterial = Config.CUSTOM_BLOCK.get(); + break; + + // Should never happen + default: + cageMaterial = null; + } + + final Cage cage = new Cage(location, Config.BUILD_CEILING.get(), Config.VISIBLE_WALLS.get()); + + if (cageMaterial != null) // Should always be true + { + cage.setCustomMaterial(cageMaterial); + cage.setInternalHeight(Config.HEIGHT.get()); + cage.setRadius(Config.RADIUS.get()); + } + + return cage; + } + /** * Sets the custom material to use. * * @param customMaterial A material. */ - public void setCustomMaterial(Material customMaterial) - { + public void setCustomMaterial(Material customMaterial) { this.material = customMaterial == null ? Material.BARRIER : customMaterial; } - /** * Sets the internal height, i.e. the height of the open space for players * (the ceiling will be above this height, and the ground under). * * @param internalHeight The height. */ - public void setInternalHeight(int internalHeight) - { + public void setInternalHeight(int internalHeight) { this.internalHeight = internalHeight; } /** * Sets the square radius of the cage. - * + * <p> * With 0, you'll have a cage with one block to walk. With 1, you'll have a * 3×3 cage. With 2, a 5×5 cage. Etc. * * @param radius The radius. */ - public void setRadius(int radius) - { + public void setRadius(int radius) { this.radius = radius; } @@ -112,23 +149,23 @@ public void setRadius(int radius) * @param location The location * @param material The block material */ - private void setBlock(final Location location, final Material material) - { + private void setBlock(final Location location, final Material material) { final Block block = location.getBlock(); - if (!blocksBuilt.containsKey(location)) + if (!blocksBuilt.containsKey(location)) { blocksBuilt.put(location, new SimpleBlock(block.getType(), block.getState().getBlockData().clone())); + } block.setType(material); } - /** * Builds the cage. */ - public boolean build() - { - if (built) return false; + public boolean build() { + if (built) { + return false; + } final int externalRadius = radius + 1; final int xMin = baseLocation.getBlockX() - externalRadius; @@ -142,35 +179,35 @@ public boolean build() // Builds the base barrier square under any cage, to support falling blocks and to avoid players falling // through the blocks when teleported - for (int x = xMin; x <= xMax; x++) - for (int z = zMin; z <= zMax; z++) + for (int x = xMin; x <= xMax; x++) { + for (int z = zMin; z <= zMax; z++) { setBlock(new Location(world, x, baseLocation.getBlockY() - 2, z), Material.BARRIER); + } + } // Builds the ground - for (int x = xMin + 1; x <= xMax - 1; x++) - for (int z = zMin + 1; z <= zMax - 1; z++) + for (int x = xMin + 1; x <= xMax - 1; x++) { + for (int z = zMin + 1; z <= zMax - 1; z++) { setBlock(new Location(world, x, baseLocation.getBlockY() - 1, z), material); + } + } // Builds the walls final Material wallsMaterial = visibleWalls ? material : Material.BARRIER; - for (int x = xMin; x <= xMax; x++) - { - for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) - { + for (int x = xMin; x <= xMax; x++) { + for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) { setBlock(new Location(world, x, y, zMin), wallsMaterial); setBlock(new Location(world, x, y, zMax), wallsMaterial); } } - for (int z = zMin; z <= zMax; z++) - { - for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) - { + for (int z = zMin; z <= zMax; z++) { + for (int y = baseLocation.getBlockY() - 1; y < baseLocation.getBlockY() + internalHeight; y++) { setBlock(new Location(world, xMin, y, z), wallsMaterial); setBlock(new Location(world, xMax, y, z), wallsMaterial); } @@ -183,17 +220,18 @@ public boolean build() int xMinCeiling = xMin, xMaxCeiling = xMax, zMinCeiling = zMin, zMaxCeiling = zMax; - if (buildCeiling && !visibleWalls) - { + if (buildCeiling && !visibleWalls) { xMinCeiling++; xMaxCeiling--; zMinCeiling++; zMaxCeiling--; } - for (int x = xMinCeiling; x <= xMaxCeiling; x++) - for (int z = zMinCeiling; z <= zMaxCeiling; z++) + for (int x = xMinCeiling; x <= xMaxCeiling; x++) { + for (int z = zMinCeiling; z <= zMaxCeiling; z++) { setBlock(new Location(world, x, baseLocation.getBlockY() + internalHeight, z), ceilingMaterial); + } + } built = true; @@ -203,74 +241,30 @@ public boolean build() /** * Destroys the cage. */ - public void destroy() - { - if (!built) return; + public void destroy() { + if (!built) { + return; + } - for (final Map.Entry<Location, SimpleBlock> entry : blocksBuilt.entrySet()) - { + for (final Map.Entry<Location, SimpleBlock> entry : blocksBuilt.entrySet()) { final Block block = entry.getKey().getBlock(); final SimpleBlock originalBlock = entry.getValue(); block.setType(originalBlock.material); - if (originalBlock.data != null) + if (originalBlock.data != null) { block.getState().setBlockData(originalBlock.data); + } } built = false; } - /** - * Creates a Cage instance for the given team. - * - * @param team The team. Can be null (fallbacks to white if a color is needed). - * @param location Where the cage should be built. - * - * @return A Cage - */ - static public Cage createInstanceForTeam(final QuartzTeam team, final Location location) - { - final Material cageMaterial; - - switch (Config.TYPE.get()) - { - case TEAM_COLOR_TRANSPARENT: - cageMaterial = ColorsUtils.chat2Block(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE, "STAINED_GLASS"); - break; - - case TEAM_COLOR_SOLID: - cageMaterial = ColorsUtils.chat2Block(team != null ? team.getColorOrWhite().toChatColor() : ChatColor.WHITE, "TERRACOTTA"); - break; - - case CUSTOM: - cageMaterial = Config.CUSTOM_BLOCK.get(); - break; - - // Should never happen - default: - cageMaterial = null; - } - - final Cage cage = new Cage(location, Config.BUILD_CEILING.get(), Config.VISIBLE_WALLS.get()); - - if (cageMaterial != null) // Should always be true - { - cage.setCustomMaterial(cageMaterial); - cage.setInternalHeight(Config.HEIGHT.get()); - cage.setRadius(Config.RADIUS.get()); - } - - return cage; - } - - /** * Cage type, enum used for the configuration */ - public enum CageType - { + public enum CageType { /** * Cages in stained glass, using the team color (or the closest color * available). @@ -299,13 +293,11 @@ public enum CageType * A block + data value (storage class used to restore old blocks when the * cage is destroyed). */ - private class SimpleBlock - { + private class SimpleBlock { public Material material; public BlockData data; - public SimpleBlock(Material material, BlockData data) - { + public SimpleBlock(Material material, BlockData data) { this.material = material; this.data = data; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java index 414547a..554c096 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/CagesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -43,16 +44,15 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerSpawnPointSelectedEvent; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.events.start.PlayerTeleportedToSpawnPointEvent; import fr.zcraft.quartzteams.QuartzTeams; +import java.util.HashMap; +import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import java.util.HashMap; -import java.util.Map; - -@ModuleInfo ( +@ModuleInfo( name = "Cages", description = "Puts players in cages (or platforms) instead of letting them float in the air, during the startup process.", when = ModuleLoadTime.ON_GAME_STARTING, @@ -61,34 +61,31 @@ settings = Config.class, can_be_loaded_late = false ) -public class CagesModule extends QSGModule -{ - private Map<Location, Cage> cages = new HashMap<>(); +public class CagesModule extends QSGModule { + private final Map<Location, Cage> cages = new HashMap<>(); - @EventHandler (priority = EventPriority.MONITOR) - public void onPlayerSpawnSelected(PlayerSpawnPointSelectedEvent ev) - { + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerSpawnSelected(PlayerSpawnPointSelectedEvent ev) { final Location spawn = cloneAndNormalize(ev.getSpawnPoint()); cages.putIfAbsent(spawn, Cage.createInstanceForTeam(QuartzTeams.get().getTeamForPlayer(ev.getPlayer()), spawn)); } @EventHandler - public void onPlayerAboutToBeTeleportedToSpawn(PlayerAboutToBeTeleportedToSpawnPointEvent ev) - { + public void onPlayerAboutToBeTeleportedToSpawn(PlayerAboutToBeTeleportedToSpawnPointEvent ev) { final Cage cage = cages.get(cloneAndNormalize(ev.getSpawnPoint())); - if (cage != null) cage.build(); + if (cage != null) { + cage.build(); + } } @EventHandler - public void onPlayerTeleportedToSpawn(PlayerTeleportedToSpawnPointEvent ev) - { + public void onPlayerTeleportedToSpawn(PlayerTeleportedToSpawnPointEvent ev) { final Location normalizedLocation = cloneAndNormalize(ev.getSpawnPoint()); // We only remove the fly if there is a cage for that player. - if (cages.containsKey(normalizedLocation)) - { + if (cages.containsKey(normalizedLocation)) { ev.getPlayer().setFlying(false); ev.getPlayer().setAllowFlight(false); @@ -98,14 +95,15 @@ public void onPlayerTeleportedToSpawn(PlayerTeleportedToSpawnPointEvent ev) } @EventHandler - public void onGameStarts(GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() != GamePhase.IN_GAME) return; + public void onGameStarts(GamePhaseChangedEvent ev) { + if (ev.getNewPhase() != GamePhase.IN_GAME) { + return; + } cages.forEach((location, nicolas) -> nicolas.destroy()); // Not even sorry. } - private Location cloneAndNormalize(final Location location) - { - return new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), 0, 0); + private Location cloneAndNormalize(final Location location) { + return new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), 0, + 0); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java index 9c554ed..17c4cee 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/starting/cages/Config.java @@ -31,28 +31,25 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.starting.cages; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; -import org.bukkit.Material; - import java.io.File; +import org.bukkit.Material; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; - - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } +public class Config extends ConfigurationInstance { public static final ConfigurationItem<Cage.CageType> TYPE = item("type", Cage.CageType.TEAM_COLOR_TRANSPARENT); public static final ConfigurationItem<Material> CUSTOM_BLOCK = item("custom-block", Material.BARRIER); public static final ConfigurationItem<Boolean> BUILD_CEILING = item("build-ceiling", false); public static final ConfigurationItem<Boolean> VISIBLE_WALLS = item("visible-walls", true); public static final ConfigurationItem<Integer> RADIUS = item("radius", 2); public static final ConfigurationItem<Integer> HEIGHT = item("height", 3); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java index 209134f..52815c3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.check; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -41,22 +42,17 @@ import fr.zcraft.quartzlib.components.i18n.I; @CommandInfo(name = "border-check", usageParameters = "<radius>", aliases = {"bordercheck", "bcheck", "bc"}) -public class CheckCommand extends Command -{ +public class CheckCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length == 0) - { + protected void run() throws CommandException { + if (args.length == 0) { throwInvalidArgument(I.t("You must provide a check radius.")); } - try - { + try { QSG.module(BorderModule.class).sendCheckMessage(sender, Integer.valueOf(args[0])); } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java index 9f4aa75..c085aa0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/check/CheckModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.check; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -38,23 +39,20 @@ import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import fr.zcraft.quartzlib.components.commands.Command; -import org.bukkit.Material; - import java.util.Collections; import java.util.List; +import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Border Check", description = "Offers a command to check how far players are from a given border size.", category = ModuleCategory.UTILITIES, icon = Material.JUNGLE_FENCE, when = ModuleLoadTime.ON_GAME_START ) -public class CheckModule extends QSGModule -{ +public class CheckModule extends QSGModule { @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(CheckCommand.class); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java index 72a56ae..ed3efb3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/FoodModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -40,24 +41,21 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands.FeedAllCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands.FeedCommand; import fr.zcraft.quartzlib.components.commands.Command; -import org.bukkit.Material; - import java.util.Arrays; import java.util.List; +import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Food Commands", description = "Provides commands to update food level & saturation of some or all players.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.UTILITIES, icon = Material.MUSHROOM_STEW ) -public class FoodModule extends QSGModule -{ +public class FoodModule extends QSGModule { @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList(FeedCommand.class, FeedAllCommand.class); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java index a82628a..f927885 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedAllCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands; import fr.zcraft.quartzlib.components.commands.Command; @@ -41,44 +42,37 @@ import org.bukkit.entity.Player; -@CommandInfo (name = "feed-all", usageParameters = "[foodPoints=20] [saturation=max]") -public class FeedAllCommand extends Command -{ +@CommandInfo(name = "feed-all", usageParameters = "[foodPoints=20] [saturation=max]") +public class FeedAllCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { int foodLevel = 20; float saturation = 20f; // /uh feed-all <foodLevel> - if (args.length > 0) - { - try - { + if (args.length > 0) { + try { foodLevel = Integer.valueOf(args[0]); } - catch (NumberFormatException e) - { - throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + catch (NumberFormatException e) { + throwInvalidArgument( + I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); } // /uh feed-all <foodLevel> <saturation> - if (args.length > 1) - { - try - { + if (args.length > 1) { + try { // The saturation value cannot be more than the food level. saturation = Math.max(foodLevel, Float.valueOf(args[1])); } - catch (NumberFormatException e) - { - throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + catch (NumberFormatException e) { + throwInvalidArgument( + I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); } } } - for (final Player player : Bukkit.getOnlinePlayers()) - { + for (final Player player : Bukkit.getOnlinePlayers()) { player.setFoodLevel(foodLevel); player.setSaturation(saturation); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java index 19b7cef..67b6d71 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/food/commands/FeedCommand.java @@ -31,51 +31,45 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.food.commands; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.entity.Player; - import java.util.List; +import org.bukkit.entity.Player; -@CommandInfo (name = "feed", usageParameters = "<player> [foodPoints=20] [saturation=max]", aliases = {"food"}) -public class FeedCommand extends Command -{ +@CommandInfo(name = "feed", usageParameters = "<player> [foodPoints=20] [saturation=max]", aliases = {"food"}) +public class FeedCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final Player target = getPlayerParameter(0); int foodLevel = 20; float saturation = 20f; // /uh feed <player> <foodLevel> - if (args.length > 1) - { - try - { + if (args.length > 1) { + try { foodLevel = Integer.valueOf(args[1]); } - catch (final NumberFormatException e) - { - throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + catch (final NumberFormatException e) { + throwInvalidArgument( + I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); } // /uh feed <player> <foodLevel> <saturation> - if (args.length > 2) - { - try - { + if (args.length > 2) { + try { // The saturation value cannot be more than the food level. saturation = Math.max(foodLevel, Float.valueOf(args[2])); } - catch (final NumberFormatException e) - { - throwInvalidArgument(I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); + catch (final NumberFormatException e) { + throwInvalidArgument( + I.t("{ce}Food points and saturation must be numbers (floats for the saturation)!")); } } } @@ -87,9 +81,11 @@ protected void run() throws CommandException } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingPlayerNames(args[0]); - else return null; + protected List<String> complete() { + if (args.length == 1) { + return getMatchingPlayerNames(args[0]); + } else { + return null; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java index d083bed..e30a9d2 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezeCommand.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.freezer; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; @@ -37,129 +38,104 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.List; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import java.util.List; -import java.util.stream.Collectors; - /** * This command freezes the players. - * + * <p> * Usage: /uh freeze <on [player]|off [player]|all|none> - * - on [player]: freezes the given player, or the sender if no player was provided. - * - off [player]: unfreezes the given player (or the sender, same condition). - * - all: freezes all the alive players, the mobs and the timer. - * - none: unfreezes all the alive players (even if there where frozen before using - * /uh freeze all), the mobs and the timer. + * - on [player]: freezes the given player, or the sender if no player was provided. + * - off [player]: unfreezes the given player (or the sender, same condition). + * - all: freezes all the alive players, the mobs and the timer. + * - none: unfreezes all the alive players (even if there where frozen before using + * /uh freeze all), the mobs and the timer. */ -@CommandInfo (name = "freeze", usageParameters = "<on|off|all|none> [target]") -public class FreezeCommand extends Command -{ +@CommandInfo(name = "freeze", usageParameters = "<on|off|all|none> [target]") +public class FreezeCommand extends Command { @Override - public void run() throws CommandException - { - if (args.length == 0) - { + public void run() throws CommandException { + if (args.length == 0) { info(I.t("{aqua}------ Freeze commands ------")); info(I.t("{cc}/uh freeze on [player]{ci}: freezes a player, or the sender without a specified player.")); - info(I.t("{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if the entire game is frozen.")); + info(I.t( + "{cc}/uh freeze off [player]{ci}: unfreezes a player (or the sender), even if the entire game is frozen.")); info(I.t("{cc}/uh freeze all{ci}: freezes the entire game (players, mobs, timer).")); - info(I.t("{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this in order to relaunch the timer.")); + info(I.t( + "{cc}/uh freeze none{ci}: unfreezes the entire game. You NEED to execute this in order to relaunch the timer.")); return; } final String subCommand = args[0]; - if (subCommand.equalsIgnoreCase("on") || subCommand.equalsIgnoreCase("off")) - { + if (subCommand.equalsIgnoreCase("on") || subCommand.equalsIgnoreCase("off")) { final boolean on = subCommand.equalsIgnoreCase("on"); // /uh freeze on: freezes the sender - if (args.length == 1) - { + if (args.length == 1) { QSG.module(FreezerModule.class).setPlayerFreezeState(playerSender(), on); - if (on) - { + if (on) { info(I.t("{cst}You where frozen by {0}.", sender.getName())); - } - else - { + } else { info(I.t("{cst}You where unfrozen by {0}.", sender.getName())); } } // /uh freeze on <player>: freezes <player>. - else if (args.length == 2) - { + else if (args.length == 2) { final Player player = getPlayerParameter(1); - if (player == null) - { + if (player == null) { error(I.t("{ce}{0} is offline!", args[1])); - } - else - { + } else { QSG.module(FreezerModule.class).setPlayerFreezeState(player, on); - if (on) - { + if (on) { player.sendMessage( - QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where frozen by {0}.", sender.getName()))); + QSGUtils.prefixedMessage(I.t("Freezer"), + I.t("{cst}You where frozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now frozen.", player.getName())); - } - else - { + } else { player.sendMessage( - QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{cst}You where unfrozen by {0}.", sender.getName()))); + QSGUtils.prefixedMessage(I.t("Freezer"), + I.t("{cst}You where unfrozen by {0}.", sender.getName()))); success(I.t("{cs}{0} is now unfrozen.", player.getName())); } } } - } - - else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none")) - { + } else if (subCommand.equalsIgnoreCase("all") || subCommand.equalsIgnoreCase("none")) { final boolean on = subCommand.equalsIgnoreCase("all"); QSG.module(FreezerModule.class).setGlobalFreezeState(on); Bukkit.broadcastMessage(""); - if (on) - { - Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The entire game is now frozen."))); - } - else - { - Bukkit.broadcastMessage(QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The game is now unfrozen."))); + if (on) { + Bukkit.broadcastMessage( + QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The entire game is now frozen."))); + } else { + Bukkit.broadcastMessage( + QSGUtils.prefixedMessage(I.t("Freezer"), I.t("{darkaqua}The game is now unfrozen."))); } Bukkit.broadcastMessage(""); } } @Override - public List<String> complete() - { - if (args.length == 1) - { + public List<String> complete() { + if (args.length == 1) { return getMatchingSubset(args[0], "on", "off", "all", "none"); - } - - else if (args.length == 2) - { - if (args[0].equalsIgnoreCase("off")) - { + } else if (args.length == 2) { + if (args[0].equalsIgnoreCase("off")) { return getMatchingSubset( QSG.module(FreezerModule.class).getFrozenPlayers().stream() .map(OfflinePlayer::getName) .collect(Collectors.toSet()), args[1]); - } - - else if (args[0].equalsIgnoreCase("on")) - { + } else if (args[0].equalsIgnoreCase("on")) { return getMatchingSubset( QSG.game().getAlivePlayers().stream() .filter(player -> !QSG.module(FreezerModule.class).isPlayerFrozen(player)) @@ -167,11 +143,11 @@ else if (args[0].equalsIgnoreCase("on")) .collect(Collectors.toSet()), args[1] ); + } else { + return null; } - - else return null; + } else { + return null; } - - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java index 75489dc..9f077a0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerListener.java @@ -39,20 +39,21 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.*; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.player.PlayerMoveEvent; -public class FreezerListener implements Listener -{ +public class FreezerListener implements Listener { /** * Used to prevent frozen players to break blocks. */ @EventHandler - public void onBlockBreakEvent(final BlockBreakEvent ev) - { - if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) - { + public void onBlockBreakEvent(final BlockBreakEvent ev) { + if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } } @@ -61,10 +62,8 @@ public void onBlockBreakEvent(final BlockBreakEvent ev) * Used to prevent frozen players to place blocks. */ @EventHandler - public void onBlockPlaceEvent(final BlockPlaceEvent ev) - { - if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) - { + public void onBlockPlaceEvent(final BlockPlaceEvent ev) { + if (QSG.module(FreezerModule.class).isPlayerFrozen(ev.getPlayer())) { ev.setCancelled(true); } } @@ -73,8 +72,7 @@ public void onBlockPlaceEvent(final BlockPlaceEvent ev) * Used to freeze the players. */ @EventHandler - public void onPlayerMove(PlayerMoveEvent ev) - { + public void onPlayerMove(PlayerMoveEvent ev) { QSG.module(FreezerModule.class).freezePlayerIfNeeded(ev.getPlayer(), ev.getFrom(), ev.getTo()); } @@ -82,18 +80,16 @@ public void onPlayerMove(PlayerMoveEvent ev) * Used to prevent the bows to be used while in global freeze mode. */ @EventHandler - public void onEntityShoot(EntityShootBowEvent ev) - { - if ((ev.getEntity() instanceof Player && QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) - || QSG.module(FreezerModule.class).getGlobalFreezeState()) - { + public void onEntityShoot(EntityShootBowEvent ev) { + if ((ev.getEntity() instanceof Player && + QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) + || QSG.module(FreezerModule.class).getGlobalFreezeState()) { ev.setCancelled(true); // If a shoot from a player is cancelled, the arrow seems to be // consumed in the player' screen. // The inventory needs to be updated for the arrow to "come back". - if (ev.getEntity() instanceof Player) - { + if (ev.getEntity() instanceof Player) { ((Player) ev.getEntity()).updateInventory(); } } @@ -103,10 +99,8 @@ public void onEntityShoot(EntityShootBowEvent ev) * Used to prevent items from de-spawning if the game is frozen. */ @EventHandler - public void onItemDespawn(ItemDespawnEvent ev) - { - if (QSG.module(FreezerModule.class).getGlobalFreezeState()) - { + public void onItemDespawn(ItemDespawnEvent ev) { + if (QSG.module(FreezerModule.class).getGlobalFreezeState()) { ev.setCancelled(true); } } @@ -115,10 +109,8 @@ public void onItemDespawn(ItemDespawnEvent ev) * Used to freeze the mobs spawning while the game is frozen. */ @EventHandler - public void onEntitySpawn(CreatureSpawnEvent ev) - { - if (QSG.module(FreezerModule.class).getGlobalFreezeState() && ev.getEntity() instanceof Creature) - { + public void onEntitySpawn(CreatureSpawnEvent ev) { + if (QSG.module(FreezerModule.class).getGlobalFreezeState() && ev.getEntity() instanceof Creature) { QSG.module(FreezerModule.class).freezeCreature((Creature) ev.getEntity(), true); } } @@ -127,12 +119,9 @@ public void onEntitySpawn(CreatureSpawnEvent ev) * Used to disable any damages if the player is frozen. */ @EventHandler - public void onEntityDamage(final EntityDamageEvent ev) - { - if (ev.getEntity() instanceof Player) - { - if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) - { + public void onEntityDamage(final EntityDamageEvent ev) { + if (ev.getEntity() instanceof Player) { + if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { ev.setCancelled(true); } } @@ -142,12 +131,9 @@ public void onEntityDamage(final EntityDamageEvent ev) * Used to cancel any food loss (but the players can still eat). */ @EventHandler - public void onFoodUpdate(FoodLevelChangeEvent ev) - { - if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) - { - if (ev.getFoodLevel() < ((Player) ev.getEntity()).getFoodLevel()) - { + public void onFoodUpdate(FoodLevelChangeEvent ev) { + if (QSG.module(FreezerModule.class).isPlayerFrozen((Player) ev.getEntity())) { + if (ev.getFoodLevel() < ((Player) ev.getEntity()).getFoodLevel()) { ev.setCancelled(true); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java index 16fbb50..5df4ca6 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/freezer/FreezerModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.freezer; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,6 +42,14 @@ import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.core.QuartzLib; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -51,11 +60,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.*; -import java.util.stream.Collectors; - -@ModuleInfo ( +@ModuleInfo( name = "Freezer", description = "Provides a command to freeze some or all players, " + "allowing to “pause” the game.", @@ -63,50 +69,39 @@ category = ModuleCategory.UTILITIES, icon = Material.PACKED_ICE ) -public class FreezerModule extends QSGModule -{ - private boolean isListenerRegistered = false; - private FreezerListener freezerListener; - - private boolean globalFreeze = false; +public class FreezerModule extends QSGModule { private final Set<UUID> frozenPlayers = new HashSet<>(); private final Map<UUID, Boolean> oldAllowFly = new HashMap<>(); private final Map<UUID, Boolean> oldFlyMode = new HashMap<>(); - + private boolean isListenerRegistered = false; + private FreezerListener freezerListener; + private boolean globalFreeze = false; private boolean hiddenFreeze = false; @Override - public void onEnable() - { + public void onEnable() { this.freezerListener = new FreezerListener(); } @Override - protected void onDisable() - { + protected void onDisable() { QuartzLib.unregisterEvents(freezerListener); freezerListener = null; } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(FreezeCommand.class); } @Override - public void injectIntoSidebar(Player player, SidebarInjector injector) - { - if (!hiddenFreeze) - { - if (globalFreeze) - { + public void injectIntoSidebar(Player player, SidebarInjector injector) { + if (!hiddenFreeze) { + if (globalFreeze) { /// Notice displayed at the bottom of the sidebar if the game is paused (/uh freeze all). injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, I.t("{darkaqua}Game frozen")); - } - else if (isPlayerFrozen(player)) - { + } else if (isPlayerFrozen(player)) { injector.injectLines(SidebarInjector.SidebarPriority.BOTTOM, true, I.t("{darkaqua}You are frozen")); } } @@ -115,22 +110,22 @@ else if (isPlayerFrozen(player)) /** * Freezes a player, if needed. * The player is blocked inside the block he is currently. - * + * <p> * This method is intended to be executed when a player moves. * * @param player The player to freeze - * @param from The old position from the PlayerMoveEvent - * @param to The new position from the PlayerMoveEvent + * @param from The old position from the PlayerMoveEvent + * @param to The new position from the PlayerMoveEvent */ - public void freezePlayerIfNeeded(Player player, Location from, Location to) - { - if (frozenPlayers.contains(player.getUniqueId())) - { + public void freezePlayerIfNeeded(Player player, Location from, Location to) { + if (frozenPlayers.contains(player.getUniqueId())) { // If the X, Y or Z coordinate of the player change, he needs to be teleported inside the old block. // The yaw and pitch are conserved, to teleport more smoothly. - if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ()) - { - player.teleport(new Location(from.getWorld(), from.getBlockX() + 0.5, from.getBlockY(), from.getBlockZ() + 0.5, to.getYaw(), to.getPitch()), TeleportCause.PLUGIN); + if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || + from.getBlockZ() != to.getBlockZ()) { + player.teleport( + new Location(from.getWorld(), from.getBlockX() + 0.5, from.getBlockY(), from.getBlockZ() + 0.5, + to.getYaw(), to.getPitch()), TeleportCause.PLUGIN); } } } @@ -139,16 +134,14 @@ public void freezePlayerIfNeeded(Player player, Location from, Location to) /** * Enables or disables the global freeze of players, mobs, timer. * - * @param frozen If true the global freeze will be enabled. + * @param frozen If true the global freeze will be enabled. * @param showStateInScoreboard If false, the freeze state will not be displayed in the scoreboard. */ - public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) - { + public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) { this.globalFreeze = frozen; this.hiddenFreeze = !showStateInScoreboard; - if (frozen) - { + if (frozen) { QSG.game().getAlivePlayers().forEach(player -> setPlayerFreezeState(player, true)); // Freezes the mobs by applying a Slowness effect. There isn't any EntityMoveEvent, so... @@ -159,10 +152,7 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) // Freezes the timers. QSG.module(TimersModule.class).pauseAllRunning(true); - } - - else - { + } else { // All the online players are listed, not the internal list of frozen players, // to avoid a ConcurrentModificationException if the iterated list is being emptied. QSG.game().getAlivePlayers().stream() @@ -183,24 +173,21 @@ public void setGlobalFreezeState(Boolean frozen, Boolean showStateInScoreboard) } /** - * Enables or disables the global freeze of players, mobs, timer. + * Returns the current state of the global freeze. * - * @param frozen If true the global freeze will be enabled. + * @return True if the global freeze is enabled. */ - public void setGlobalFreezeState(Boolean frozen) - { - setGlobalFreezeState(frozen, true); + public boolean getGlobalFreezeState() { + return this.globalFreeze; } - /** - * Returns the current state of the global freeze. + * Enables or disables the global freeze of players, mobs, timer. * - * @return True if the global freeze is enabled. + * @param frozen If true the global freeze will be enabled. */ - public boolean getGlobalFreezeState() - { - return this.globalFreeze; + public void setGlobalFreezeState(Boolean frozen) { + setGlobalFreezeState(frozen, true); } /** @@ -209,25 +196,23 @@ public boolean getGlobalFreezeState() * @param player The player to freeze. * @param frozen If true the player will be frozen. If false, unfrozen. */ - public void setPlayerFreezeState(OfflinePlayer player, Boolean frozen) - { - if (frozen && !frozenPlayers.contains(player.getUniqueId())) - { + public void setPlayerFreezeState(OfflinePlayer player, Boolean frozen) { + if (frozen && !frozenPlayers.contains(player.getUniqueId())) { this.frozenPlayers.add(player.getUniqueId()); this.oldAllowFly.put(player.getUniqueId(), player.isOnline() && player.getPlayer().getAllowFlight()); this.oldFlyMode.put(player.getUniqueId(), player.isOnline() && player.getPlayer().isFlying()); // Used to prevent the player to be kicked for fly if he was frozen during a fall. // He is blocked inside his current block anyway. - if (player.isOnline()) player.getPlayer().setAllowFlight(true); + if (player.isOnline()) { + player.getPlayer().setAllowFlight(true); + } } - if (!frozen && frozenPlayers.contains(player.getUniqueId())) - { + if (!frozen && frozenPlayers.contains(player.getUniqueId())) { this.frozenPlayers.remove(player.getUniqueId()); - if (player.isOnline()) - { + if (player.isOnline()) { player.getPlayer().setFlying(oldFlyMode.get(player.getUniqueId())); player.getPlayer().setAllowFlight(oldAllowFly.get(player.getUniqueId())); } @@ -245,8 +230,7 @@ public void setPlayerFreezeState(OfflinePlayer player, Boolean frozen) * @param player The player to be checked. * @return true if the given player is frozen. */ - public boolean isPlayerFrozen(final OfflinePlayer player) - { + public boolean isPlayerFrozen(final OfflinePlayer player) { return frozenPlayers.contains(player.getUniqueId()); } @@ -254,17 +238,13 @@ public boolean isPlayerFrozen(final OfflinePlayer player) * (Un)freezes a creature. * * @param creature The creature to freeze. - * @param frozen If true the creature will be frozen. Else... + * @param frozen If true the creature will be frozen. Else... */ - public void freezeCreature(final Creature creature, final boolean frozen) - { - if (frozen) - { + public void freezeCreature(final Creature creature, final boolean frozen) { + if (frozen) { // Freezes the creature for about 68 years. creature.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 100, true)); - } - else - { + } else { creature.removePotionEffect(PotionEffectType.SLOW); } } @@ -272,28 +252,23 @@ public void freezeCreature(final Creature creature, final boolean frozen) /** * Registers the listener if it wasn't registered, and unregisters this listener * if there isn't any frozen player. - * + * <p> * Call this AFTER registering the first frozen player, and AFTER unregistering * the last one. */ - private void updateListenerRegistration() - { + private void updateListenerRegistration() { // Registers the listener if needed // (i.e if there isn't any frozen player, or if the global freeze is enabled). - if (!this.isListenerRegistered) - { - if (!this.frozenPlayers.isEmpty() || this.getGlobalFreezeState()) - { + if (!this.isListenerRegistered) { + if (!this.frozenPlayers.isEmpty() || this.getGlobalFreezeState()) { QuartzLib.registerEvents(freezerListener); this.isListenerRegistered = true; } } // Unregisters the listener if needed - else - { - if (this.frozenPlayers.isEmpty() && !this.getGlobalFreezeState()) - { + else { + if (this.frozenPlayers.isEmpty() && !this.getGlobalFreezeState()) { QuartzLib.unregisterEvents(freezerListener); this.isListenerRegistered = false; } @@ -306,8 +281,7 @@ private void updateListenerRegistration() * * @return The list. */ - public Set<OfflinePlayer> getFrozenPlayers() - { + public Set<OfflinePlayer> getFrozenPlayers() { return frozenPlayers.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toSet()); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java index df53647..4099650 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/HealthModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -40,24 +41,21 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands.HealAllCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands.HealCommand; import fr.zcraft.quartzlib.components.commands.Command; -import org.bukkit.Material; - import java.util.Arrays; import java.util.List; +import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Health Commands", description = "Provides commands to update health of some or all players.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.UTILITIES, icon = Material.GOLDEN_APPLE ) -public class HealthModule extends QSGModule -{ +public class HealthModule extends QSGModule { @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList(HealCommand.class, HealAllCommand.class); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java index 302a9a3..75840ee 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealAllCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; @@ -43,56 +44,44 @@ import org.bukkit.entity.Player; -@CommandInfo (name = "heal-all", usageParameters = "[half-hearts=20|±diff]", aliases = {"healall"}) -public class HealAllCommand extends Command -{ +@CommandInfo(name = "heal-all", usageParameters = "[half-hearts=20|±diff]", aliases = {"healall"}) +public class HealAllCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { double diffHealth; boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode // /uh heal-all: full life for player. - if (args.length == 0) - { + if (args.length == 0) { diffHealth = Integer.MAX_VALUE; } // /uh heal-all <hearts> - else - { - try - { - if (args[0].startsWith("+") || args[0].startsWith("-")) - { + else { + try { + if (args[0].startsWith("+") || args[0].startsWith("-")) { add = true; } diffHealth = Double.parseDouble(args[0]); } - catch (final NumberFormatException e) - { + catch (final NumberFormatException e) { throwInvalidArgument(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); return; } } - if (!add && diffHealth <= 0) - { + if (!add && diffHealth <= 0) { error(I.t("{ce}Serial killer!")); } - for (final Player player : Bukkit.getServer().getOnlinePlayers()) - { + for (final Player player : Bukkit.getServer().getOnlinePlayers()) { double health = !add ? diffHealth : player.getHealth() + diffHealth; - if (health <= 0D) - { + if (health <= 0D) { warning(I.t("{ce}The health of {0} was not updated to avoid a kill.", player.getName())); continue; - } - else if (health > player.getMaxHealth()) - { + } else if (health > player.getMaxHealth()) { health = player.getMaxHealth(); } @@ -100,23 +89,15 @@ else if (health > player.getMaxHealth()) QSG.module(TeamsModule.class).getSidebarPlayerCache(player.getUniqueId()).updateHealth(health); } - if (!add) - { - if (diffHealth == Integer.MAX_VALUE) - { + if (!add) { + if (diffHealth == Integer.MAX_VALUE) { success(I.t("The health of all players was completely filled.", diffHealth)); - } - else - { + } else { success(I.t("The health of all players was set to {0}.", diffHealth)); } - } - else if (diffHealth > 0) - { + } else if (diffHealth > 0) { success(I.t("The health of all players was increased by {0}.", diffHealth)); - } - else - { + } else { success(I.t("The health of all players was decreased by {0}.", -diffHealth)); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java index c200f1a..497c741 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/health/commands/HealCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.health.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.teams.TeamsModule; @@ -39,19 +40,16 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.entity.Player; - import java.util.List; +import org.bukkit.entity.Player; -@CommandInfo (name = "heal", usageParameters = "<player> [half-hearts=20|±diff]", aliases = {"life", "set-health", "sethealth"}) -public class HealCommand extends Command -{ +@CommandInfo(name = "heal", usageParameters = "<player> [half-hearts=20|±diff]", aliases = {"life", "set-health", + "sethealth"}) +public class HealCommand extends Command { @Override - protected void run() throws CommandException - { - if (args.length == 0) - { + protected void run() throws CommandException { + if (args.length == 0) { throwInvalidArgument(I.t("A player is required")); } @@ -61,39 +59,31 @@ protected void run() throws CommandException boolean add = false; // "add" (±, true) or "raw" (exact health, false) mode // /uh heal <player> : full life for player. - if (args.length == 1) - { + if (args.length == 1) { health = 20D; } // /uh heal <player> <hearts> - else - { + else { double diffHealth; - try - { - if (args[1].startsWith("+") || args[1].startsWith("-")) - { + try { + if (args[1].startsWith("+") || args[1].startsWith("-")) { add = true; } diffHealth = Double.parseDouble(args[1]); } - catch (final NumberFormatException e) - { + catch (final NumberFormatException e) { throwInvalidArgument(I.t("{ce}Hey, this is not a number of half-hearts. It's a text. Pfff.")); return; } health = !add ? diffHealth : target.getHealth() + diffHealth; - if (health <= 0D) - { + if (health <= 0D) { error(I.t("{ce}You can't kill a player with this command, to avoid typo fails.")); - } - else if (health > 20D) - { + } else if (health > 20D) { health = 20D; } } @@ -107,9 +97,11 @@ else if (health > 20D) } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingPlayerNames(args[0]); - else return null; + protected List<String> complete() { + if (args.length == 1) { + return getMatchingPlayerNames(args[0]); + } else { + return null; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java index ec54fb2..1d847d4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/LoadPlayersCommand.java @@ -31,36 +31,32 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.playersLoader; import eu.carrade.amaury.quartzsurvivalgames.utils.OfflinePlayersLoader; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.Arrays; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import java.util.Arrays; - -@CommandInfo ( +@CommandInfo( name = "load-players", usageParameters = "<player1> [player2] [player3] […]", aliases = {"loadplayers", "load-player", "loadplayer"} ) -public class LoadPlayersCommand extends Command -{ +public class LoadPlayersCommand extends Command { @Override - protected void run() - { - if (!Bukkit.getOnlineMode()) - { + protected void run() { + if (!Bukkit.getOnlineMode()) { sender.sendMessage(I.t("{ce}You cannot load unknown players in offline mode, sorry.")); return; } - if (args.length == 0) - { + if (args.length == 0) { /// Error returned if one calls /uh loadplayers without arguments. sender.sendMessage(I.t("{ce}You need to provide at least one player name.")); return; @@ -72,12 +68,15 @@ protected void run() final CommandSender fSender = sender; OfflinePlayersLoader.loadPlayers( - Arrays.asList(args), - addedPlayers -> fSender.sendMessage(I.tn("{cs}Loaded {0} player successfully.", "{cs}Loaded {0} players successfully.", addedPlayers.size())), - notFound -> { - /// Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). - fSender.sendMessage(I.tn("{ce}{0} player is missing: {1}.", "{ce}{0} players are missing: {1}.", notFound.size(), notFound.size(), StringUtils.join(notFound, ", "))); - } + Arrays.asList(args), + addedPlayers -> fSender.sendMessage( + I.tn("{cs}Loaded {0} player successfully.", "{cs}Loaded {0} players successfully.", + addedPlayers.size())), + notFound -> { + /// Message sent if some players cannot be loaded while /uh loadplayers is used. 0 = amount of players missing; 1 = list of nicknames (format "nick1, nick2, nick3"). + fSender.sendMessage(I.tn("{ce}{0} player is missing: {1}.", "{ce}{0} players are missing: {1}.", + notFound.size(), notFound.size(), StringUtils.join(notFound, ", "))); + } ); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java index b1f3d78..ed00109 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/playersLoader/PlayersLoaderModule.java @@ -31,29 +31,28 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.playersLoader; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; import fr.zcraft.quartzlib.components.commands.Command; -import org.bukkit.Material; - import java.util.Collections; import java.util.List; +import org.bukkit.Material; -@ModuleInfo ( +@ModuleInfo( name = "Players Loader", - description = "Loads player into the server even if they never came before, so you can add them to teams and such. " + - "An interface to the built-in players loader.", + description = + "Loads player into the server even if they never came before, so you can add them to teams and such. " + + "An interface to the built-in players loader.", category = ModuleCategory.UTILITIES, icon = Material.PLAYER_HEAD ) -public class PlayersLoaderModule extends QSGModule -{ +public class PlayersLoaderModule extends QSGModule { @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(LoadPlayersCommand.class); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java index abda80a..17e99a0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/Config.java @@ -31,32 +31,28 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; +public class Config extends ConfigurationInstance { + public static final DisplaySection DISPLAY = section("display", DisplaySection.class); + public static final ConfigurationList<String> RULES = list("rules", String.class); -public class Config extends ConfigurationInstance -{ - public Config(File file) - { + public Config(File file) { super(file); } - public static final DisplaySection DISPLAY = section("display", DisplaySection.class); - - static public class DisplaySection extends ConfigurationSection - { + static public class DisplaySection extends ConfigurationSection { public final ConfigurationItem<Boolean> ON_JOIN = item("on-join", false); public final ConfigurationItem<Boolean> ON_START = item("on-start", true); } - - public static final ConfigurationList<String> RULES = list("rules", String.class); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java index 3b25e17..f48287c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesCommand.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; @@ -36,50 +37,43 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import java.util.List; import java.util.Optional; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; -@CommandInfo (name = "rules", usageParameters = "[player]") -public class RulesCommand extends Command -{ - public void run() throws CommandException - { - if (!QSG.module(RulesModule.class).hasRules()) - { +@CommandInfo(name = "rules", usageParameters = "[player]") +public class RulesCommand extends Command { + public void run() throws CommandException { + if (!QSG.module(RulesModule.class).hasRules()) { error(I.t("{ce}No rules are set in the config file.")); } - if (args.length >= 1) - { + if (args.length >= 1) { final Optional<? extends Player> player = Bukkit.getOnlinePlayers().stream() .filter(onlinePlayer -> onlinePlayer.getName().equalsIgnoreCase(args[0].trim())) .findAny(); - if (player.isPresent()) - { + if (player.isPresent()) { QSG.module(RulesModule.class).displayRulesTo(player.get()); - if (!sender.equals(player.get())) + if (!sender.equals(player.get())) { sender.sendMessage(I.t("{cs}Rules sent to {0}.", player.get().getName())); - } - else - { + } + } else { sender.sendMessage(I.t("{ce}Cannot display the rules to {0} because he (or she) is offline.", args[0])); } - } - else - { + } else { QSG.module(RulesModule.class).broadcastRules(); } } @Override - public List<String> complete() - { - if (args.length == 1) return getMatchingPlayerNames(args[0]); - else return null; + public List<String> complete() { + if (args.length == 1) { + return getMatchingPlayerNames(args[0]); + } else { + return null; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java index edb449a..a87ffc5 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/rules/RulesModule.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.rules; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,6 +43,9 @@ import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -49,11 +53,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@ModuleInfo ( +@ModuleInfo( name = "Rules", description = "Displays configured game rules when the game start or the " + "players join", @@ -62,44 +62,43 @@ icon = Material.BOOKSHELF, settings = Config.class ) -public class RulesModule extends QSGModule -{ +public class RulesModule extends QSGModule { private final List<String> rules = new ArrayList<>(); @Override - public void onEnable() - { - if (Config.RULES.isDefined() && !Config.RULES.isEmpty() ) - { + public void onEnable() { + if (Config.RULES.isDefined() && !Config.RULES.isEmpty()) { // We check if the list is non-empty, i.e. if there is at least a non-empty rule. boolean empty = true; - for (final String rule : Config.RULES) - { - if (rule == null) continue; + for (final String rule : Config.RULES) { + if (rule == null) { + continue; + } - rules.add(ChatColor.translateAlternateColorCodes('&',rule.trim())); + rules.add(ChatColor.translateAlternateColorCodes('&', rule.trim())); - if (!rule.isEmpty()) + if (!rule.isEmpty()) { empty = false; + } } // If the list is empty, no rules are displayed. We reset the list. - if (empty) rules.clear(); + if (empty) { + rules.clear(); + } } } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(RulesCommand.class); } /** * @return {@code true} if the rules system is enabled */ - public boolean hasRules() - { + public boolean hasRules() { return rules.size() != 0; } @@ -109,21 +108,16 @@ public boolean hasRules() * * @param receiver The receiver. */ - public void displayRulesTo(CommandSender receiver) - { + public void displayRulesTo(CommandSender receiver) { CommandUtils.displaySeparator(receiver); /// Title of the rules box. receiver.sendMessage(I.t("{red}{bold}Rules and informations")); - for (String rule : rules) - { - if (rule.isEmpty()) - { + for (String rule : rules) { + if (rule.isEmpty()) { receiver.sendMessage(""); - } - else - { + } else { /// Rule item in the rule box. receiver.sendMessage(I.t("{darkgray}- {reset}{0}", rule)); } @@ -135,26 +129,26 @@ public void displayRulesTo(CommandSender receiver) /** * Broadcasts the rules to the whole server. */ - public void broadcastRules() - { + public void broadcastRules() { Bukkit.getOnlinePlayers().forEach(this::displayRulesTo); displayRulesTo(Bukkit.getConsoleSender()); } @EventHandler - public void onPlayerJoin(final PlayerJoinEvent ev) - { - if (QSG.game().getPhase() == GamePhase.WAIT && hasRules() && Config.DISPLAY.ON_JOIN.get()) - { - RunTask.later(() -> { if (ev.getPlayer().isOnline()) displayRulesTo(ev.getPlayer()); }, 100L); + public void onPlayerJoin(final PlayerJoinEvent ev) { + if (QSG.game().getPhase() == GamePhase.WAIT && hasRules() && Config.DISPLAY.ON_JOIN.get()) { + RunTask.later(() -> { + if (ev.getPlayer().isOnline()) { + displayRulesTo(ev.getPlayer()); + } + }, 100L); } } @EventHandler - public void onGameStart(final GamePhaseChangedEvent ev) - { - if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward() && hasRules() && Config.DISPLAY.ON_START.get()) - { + public void onGameStart(final GamePhaseChangedEvent ev) { + if (ev.getNewPhase() == GamePhase.IN_GAME && ev.isRunningForward() && hasRules() && + Config.DISPLAY.ON_START.get()) { RunTask.later(this::broadcastRules, 200L); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java index 16f305d..c72a278 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/Config.java @@ -31,25 +31,22 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.runtimeCommandsExecutor; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationList; - import java.io.File; import java.util.Map; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; - -public class Config extends ConfigurationInstance -{ - public Config(File file) - { - super(file); - } - +public class Config extends ConfigurationInstance { public final static ConfigurationList<Map> WAIT = list("wait", Map.class); public final static ConfigurationList<Map> STARTING = list("starting", Map.class); public final static ConfigurationList<Map> IN_GAME = list("in-game", Map.class); public final static ConfigurationList<Map> END = list("end", Map.class); + public Config(File file) { + super(file); + } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java index 73354b1..b9269e8 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/RuntimeCommandsExecutor.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.runtimeCommandsExecutor; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -41,22 +42,21 @@ import fr.zcraft.quartzlib.components.configuration.ConfigurationList; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.runners.RunTask; -import org.bukkit.Material; -import org.bukkit.event.EventHandler; -import org.bukkit.scheduler.BukkitTask; - import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitTask; /** * This will execute the commands to be executed during runtime, as configured in the config file * or added through the API. */ -@ModuleInfo ( +@ModuleInfo( name = "Runtime Commands Executor", description = "Executes commands during runtime, at specific times of the game, automatically. " + "This is a powerful tool to schedule any command at any time relative to the game progression.", @@ -65,8 +65,7 @@ icon = Material.COMMAND_BLOCK, settings = Config.class ) -public class RuntimeCommandsExecutor extends QSGModule -{ +public class RuntimeCommandsExecutor extends QSGModule { /** * Stores the commands to be executed later. * <p> @@ -90,8 +89,7 @@ public class RuntimeCommandsExecutor extends QSGModule * * @param key The key to schedule. All commands previously registered under this key will be executed. */ - public void runCommands(final String key) - { + public void runCommands(final String key) { runCommands(key, scheduled.get(key)); } @@ -102,25 +100,22 @@ public void runCommands(final String key) * * @param phase The phase to schedule. All commands previously registered under this phase will be executed. */ - public void runCommands(final GamePhase phase) - { + public void runCommands(final GamePhase phase) { runCommands(getPhaseKey(phase)); } /** * Register the given commands in the Bukkit' scheduler. - * + * <p> * Delays are from the execution of this method. - * @param key The key to store the tasks under. + * + * @param key The key to store the tasks under. * @param scheduledCommands The commands to schedule */ - private void runCommands(final String key, final Map<Integer, HashSet<String>> scheduledCommands) - { - if (scheduledCommands != null) - { + private void runCommands(final String key, final Map<Integer, HashSet<String>> scheduledCommands) { + if (scheduledCommands != null) { final Set<BukkitTask> tasks = runningTasks.computeIfAbsent(key, k -> new HashSet<>()); - for (Entry<Integer, HashSet<String>> scheduledCommandsStack : scheduledCommands.entrySet()) - { + for (Entry<Integer, HashSet<String>> scheduledCommandsStack : scheduledCommands.entrySet()) { tasks.add(RunTask.later( new ScheduledCommandsExecutorTask(scheduledCommandsStack.getValue()), scheduledCommandsStack.getKey() * 20L @@ -132,12 +127,11 @@ private void runCommands(final String key, final Map<Integer, HashSet<String>> s /** * Cancels all tasks currently running for the given key. + * * @param key The key. */ - public void cancelTasks(final String key) - { - if (runningTasks.containsKey(key)) - { + public void cancelTasks(final String key) { + if (runningTasks.containsKey(key)) { runningTasks.get(key).forEach(BukkitTask::cancel); runningTasks.get(key).clear(); } @@ -145,26 +139,25 @@ public void cancelTasks(final String key) /** * Cancels all tasks currently running for the given phase. + * * @param phase The phase. */ - public void cancelTasks(final GamePhase phase) - { + public void cancelTasks(final GamePhase phase) { cancelTasks(getPhaseKey(phase)); } /** * Schedules a command. - * + * <p> * Commands scheduled with any non-standard key will not be executed automatically. You'll have * to call {@link #runCommands(String)} to schedule them. * - * @param key The command will be stored under this key. + * @param key The command will be stored under this key. * @param command The command to add. - * @param delay The delay. + * @param delay The delay. * @see #scheduleCommand(GamePhase, String, TimeDelta) to schedule a command from one game phase change. */ - public void scheduleCommand(final String key, final String command, final TimeDelta delay) - { + public void scheduleCommand(final String key, final String command, final TimeDelta delay) { final Map<Integer, HashSet<String>> commandsMap = scheduled.computeIfAbsent(key, k -> new HashMap<>()); scheduleCommand(commandsMap, command, delay); } @@ -172,12 +165,11 @@ public void scheduleCommand(final String key, final String command, final TimeDe /** * Schedule a command to be run when the given phase starts. * - * @param phase The phase + * @param phase The phase * @param command The command to execute - * @param delay The delay after the phase's beginning. + * @param delay The delay after the phase's beginning. */ - public void scheduleCommand(final GamePhase phase, String command, final TimeDelta delay) - { + public void scheduleCommand(final GamePhase phase, String command, final TimeDelta delay) { scheduleCommand(getPhaseKey(phase), command, delay); } @@ -185,11 +177,10 @@ public void scheduleCommand(final GamePhase phase, String command, final TimeDel * Schedules a command. * * @param scheduledCommands A map containing the scheduled commands, sorted by delay. - * @param command The command to add. - * @param delay The delay (seconds). + * @param command The command to add. + * @param delay The delay (seconds). */ - private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, TimeDelta delay) - { + private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, TimeDelta delay) { final Set<String> list = scheduledCommands.computeIfAbsent((int) delay.getSeconds(), k -> new HashSet<>()); list.add(clearCommandName(command)); } @@ -198,11 +189,10 @@ private void scheduleCommand(Map<Integer, HashSet<String>> scheduledCommands, St /** * Removes the given command from everywhere. * - * @param key The command will be stored under this key. + * @param key The command will be stored under this key. * @param command The command. Not case-sensitive. */ - public void removeScheduledCommand(String key, String command) - { + public void removeScheduledCommand(String key, String command) { removeScheduledCommand(scheduled.get(key), command); } @@ -210,16 +200,12 @@ public void removeScheduledCommand(String key, String command) * Removes the given command from everywhere. * * @param scheduledCommands A map containing the scheduled commands, sorted by delay. - * @param command The command. Not case-sensitive. + * @param command The command. Not case-sensitive. */ - private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command) - { - for (HashSet<String> commands : scheduledCommands.values()) - { - for (String scheduledCommand : new HashSet<>(commands)) - { - if (scheduledCommand.equalsIgnoreCase(clearCommandName(command))) - { + private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command) { + for (HashSet<String> commands : scheduledCommands.values()) { + for (String scheduledCommand : new HashSet<>(commands)) { + if (scheduledCommand.equalsIgnoreCase(clearCommandName(command))) { commands.remove(scheduledCommand); } } @@ -230,22 +216,20 @@ private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledComma /** * Removes the given command from everywhere. * - * @param key The key the command was registered under. + * @param key The key the command was registered under. * @param command The command. Not case-sensitive. */ - public void removeScheduledCommand(String key, String command, TimeDelta delay) - { + public void removeScheduledCommand(String key, String command, TimeDelta delay) { removeScheduledCommand(scheduled.get(key), command, delay); } /** * Removes the given command from everywhere. * - * @param phase The phase the command was registered under. + * @param phase The phase the command was registered under. * @param command The command. Not case-sensitive. */ - public void removeScheduledCommand(GamePhase phase, String command, TimeDelta delay) - { + public void removeScheduledCommand(GamePhase phase, String command, TimeDelta delay) { removeScheduledCommand(getPhaseKey(phase), command, delay); } @@ -253,36 +237,32 @@ public void removeScheduledCommand(GamePhase phase, String command, TimeDelta de * Removes the given command from everywhere. * * @param scheduledCommands A map containing the scheduled commands, sorted by delay. - * @param command The command. Not case-sensitive. + * @param command The command. Not case-sensitive. */ - private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, TimeDelta delay) - { + private void removeScheduledCommand(Map<Integer, HashSet<String>> scheduledCommands, String command, + TimeDelta delay) { HashSet<String> commands = scheduledCommands.get(((int) delay.getSeconds())); - if (commands != null) - { + if (commands != null) { commands.stream() .filter(scheduledCommand -> scheduledCommand.equalsIgnoreCase(clearCommandName(command))) .forEach(commands::remove); } } - - /* Utilities */ + + /* Utilities */ - private String clearCommandName(String command) - { - if (command.startsWith("/")) - { + private String clearCommandName(String command) { + if (command.startsWith("/")) { command = command.substring(1); } return command; } - private String getPhaseKey(final GamePhase phase) - { + private String getPhaseKey(final GamePhase phase) { return "internal." + phase.name().toLowerCase().replace('_', '-'); } @@ -290,10 +270,8 @@ private String getPhaseKey(final GamePhase phase) /* Events to launch tasks */ @EventHandler - protected void onGamePhaseChanged(final GamePhaseChangedEvent ev) - { - if (!ev.isRunningForward()) - { + protected void onGamePhaseChanged(final GamePhaseChangedEvent ev) { + if (!ev.isRunningForward()) { cancelTasks(ev.getNewPhase()); return; } @@ -301,32 +279,39 @@ protected void onGamePhaseChanged(final GamePhaseChangedEvent ev) // We load the commands to run final ConfigurationList<Map> commands; - switch (ev.getNewPhase()) - { - case WAIT: commands = Config.WAIT; break; - case STARTING: commands = Config.STARTING; break; - case IN_GAME: commands = Config.IN_GAME; break; - case END: commands = Config.END; break; - default: return; + switch (ev.getNewPhase()) { + case WAIT: + commands = Config.WAIT; + break; + case STARTING: + commands = Config.STARTING; + break; + case IN_GAME: + commands = Config.IN_GAME; + break; + case END: + commands = Config.END; + break; + default: + return; } commands.stream() - .filter(command -> command.containsKey("exec") && !command.get("exec").toString().isEmpty()) - .forEach(command -> { - try - { - scheduleCommand(ev.getNewPhase(), command.get("exec").toString(), new TimeDelta(command.get("delay").toString())); - } - catch (IllegalArgumentException e) - { - PluginLogger.error( - "Invalid delay “{0}” in scheduled command “{1}” for phase {2}", - command.get("delay").toString(), - command.get("exec").toString(), - ev.getNewPhase() - ); - } - }); + .filter(command -> command.containsKey("exec") && !command.get("exec").toString().isEmpty()) + .forEach(command -> { + try { + scheduleCommand(ev.getNewPhase(), command.get("exec").toString(), + new TimeDelta(command.get("delay").toString())); + } + catch (IllegalArgumentException e) { + PluginLogger.error( + "Invalid delay “{0}” in scheduled command “{1}” for phase {2}", + command.get("delay").toString(), + command.get("exec").toString(), + ev.getNewPhase() + ); + } + }); // And we schedule all of them. runCommands(ev.getNewPhase()); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java index a2de0b6..47a9ca4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/runtimeCommandsExecutor/ScheduledCommandsExecutorTask.java @@ -34,36 +34,29 @@ import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; import fr.zcraft.quartzlib.tools.PluginLogger; -import org.bukkit.command.CommandException; - import java.util.HashSet; +import org.bukkit.command.CommandException; /** * Schedules a stack of commands executed at the same time. */ -public class ScheduledCommandsExecutorTask implements Runnable -{ +public class ScheduledCommandsExecutorTask implements Runnable { private final QuartzSurvivalGames p; private final HashSet<String> commands; - public ScheduledCommandsExecutorTask(HashSet<String> commands) - { + public ScheduledCommandsExecutorTask(HashSet<String> commands) { this.p = QuartzSurvivalGames.get(); this.commands = commands; } @Override - public void run() - { - for (final String command : commands) - { - try - { + public void run() { + for (final String command : commands) { + try { p.getServer().dispatchCommand(p.getServer().getConsoleSender(), command); } - catch (CommandException e) - { + catch (CommandException e) { PluginLogger.error("The scheduled command '{0}' failed.", e, command); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java index d20037d..c11f659 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/TeleportationModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,27 +43,28 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPSpectatorsCommand; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands.TPTeamCommand; import fr.zcraft.quartzlib.components.commands.Command; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; -import java.util.*; - -@ModuleInfo ( +@ModuleInfo( name = "Teleportation Commands", description = "Provides commands to teleport to spawn, death location, or groups of players.", category = ModuleCategory.UTILITIES, icon = Material.COMMAND_BLOCK_MINECART ) -public class TeleportationModule extends QSGModule -{ +public class TeleportationModule extends QSGModule { private final Map<UUID, Location> deathLocations = new HashMap<>(); @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Arrays.asList( TPDeathCommand.class, TPSpawnCommand.class, @@ -72,21 +74,17 @@ public List<Class<? extends Command>> getCommands() } @EventHandler - public void onPlayerDeath(final AlivePlayerDeathEvent ev) - { - if (ev.getPlayer().isOnline()) - { + public void onPlayerDeath(final AlivePlayerDeathEvent ev) { + if (ev.getPlayer().isOnline()) { deathLocations.put(ev.getPlayer().getUniqueId(), ev.getPlayer().getPlayer().getLocation()); } } - public boolean hasDeathLocation(final OfflinePlayer player) - { + public boolean hasDeathLocation(final OfflinePlayer player) { return deathLocations.containsKey(player.getUniqueId()); } - public Location getDeathLocation(final OfflinePlayer player) - { + public Location getDeathLocation(final OfflinePlayer player) { return deathLocations.get(player.getUniqueId()).clone(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java index e4df846..44c75c0 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPDeathCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.TeleportationModule; @@ -40,63 +41,51 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.List; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import java.util.List; -import java.util.stream.Collectors; - -@CommandInfo (name = "tp-death", usageParameters = "[player] [force]",aliases = {"tpback", "tpdeath", "tpd"}) -public class TPDeathCommand extends Command -{ +@CommandInfo(name = "tp-death", usageParameters = "[player] [force]", aliases = {"tpback", "tpdeath", "tpd"}) +public class TPDeathCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final Player player = args.length > 0 ? getPlayerParameter(0) : playerSender(); final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); - if (!QSG.module(TeleportationModule.class).hasDeathLocation(player)) - { + if (!QSG.module(TeleportationModule.class).hasDeathLocation(player)) { error(I.t("{ce}No death location available for the player {0}.", player.getName())); } final Location deathLocation = QSG.module(TeleportationModule.class).getDeathLocation(player); - if (force) - { + if (force) { QSGUtils.safeTP(player, deathLocation, true); success(I.t("{cs}The player {0} was teleported back.", player.getName())); - } - else if (QSGUtils.safeTP(player, deathLocation)) - { + } else if (QSGUtils.safeTP(player, deathLocation)) { success(I.t("{cs}The player {0} was teleported back.", player.getName())); - } - else - { - warning(I.t("{ce}The player {0} was NOT teleported back because no safe spot was found.", player.getName())); - warning(I.t("{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this point.", player.getName())); + } else { + warning(I + .t("{ce}The player {0} was NOT teleported back because no safe spot was found.", player.getName())); + warning(I.t("{ci}Use {cc}/uh tpback {0} force{ci} to teleport the player regardless this point.", + player.getName())); } } @Override - protected List<String> complete() - { - if (args.length == 1) - { + protected List<String> complete() { + if (args.length == 1) { final TeleportationModule tm = QSG.module(TeleportationModule.class); return getMatchingPlayerNames( Bukkit.getOnlinePlayers().stream().filter(tm::hasDeathLocation).collect(Collectors.toList()), args[0] ); - } - - else if (args.length == 2) - { + } else if (args.length == 2) { return getMatchingSubset(args[1].toLowerCase(), "force"); + } else { + return null; } - - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java index 3c2066a..b03d36d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpawnCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; @@ -41,23 +42,19 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.List; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; -import java.util.List; -import java.util.stream.Collectors; - -@CommandInfo (name = "tp-spawn", usageParameters = "<player> [force]", aliases = {"tpspawn"}) -public class TPSpawnCommand extends Command -{ +@CommandInfo(name = "tp-spawn", usageParameters = "<player> [force]", aliases = {"tpspawn"}) +public class TPSpawnCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final Teleporter teleporter = QSG.module(GameModule.class).getTeleporter(); - if (teleporter == null) - { + if (teleporter == null) { error(I.t("{ce}The spawn points are not already assigned to the player, because the game is not started.")); return; } @@ -66,48 +63,41 @@ protected void run() throws CommandException final boolean force = args.length > 1 && args[1].equalsIgnoreCase("force"); final Location spawnLocation = teleporter.getSpawnForPlayer(player.getUniqueId()); - if (spawnLocation == null) - { + if (spawnLocation == null) { error(I.t("{ce}No spawn location available for the player {0}.", player.getName())); return; } - if (force) - { + if (force) { teleporter.teleportPlayer(player.getUniqueId(), true); success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); - } - else if (QSGUtils.safeTP(player, spawnLocation)) - { + } else if (QSGUtils.safeTP(player, spawnLocation)) { success(I.t("{cs}The player {0} was teleported to his spawn location.", player.getName())); - } - else - { - warning(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", player.getName())); - warning(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", player.getName())); + } else { + warning(I.t("{ce}The player {0} was NOT teleported to his spawn because no safe spot was found.", + player.getName())); + warning(I.t("{ci}Use {cc}/uh tpspawn {0} force{ci} to teleport the player regardless this point.", + player.getName())); } } @Override - protected List<String> complete() - { + protected List<String> complete() { final Teleporter teleporter = QSG.module(GameModule.class).getTeleporter(); - if (teleporter == null) return null; - - else if (args.length == 1) - { + if (teleporter == null) { + return null; + } else if (args.length == 1) { return getMatchingPlayerNames( - Bukkit.getOnlinePlayers().stream().filter(player -> teleporter.hasSpawnForPlayer(player.getUniqueId())).collect(Collectors.toList()), + Bukkit.getOnlinePlayers().stream() + .filter(player -> teleporter.hasSpawnForPlayer(player.getUniqueId())) + .collect(Collectors.toList()), args[0] ); - } - - else if (args.length == 2) - { + } else if (args.length == 2) { return getMatchingSubset(args[1].toLowerCase(), "force"); + } else { + return null; } - - else return null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java index 5b11a0a..5a6a5cf 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPSpectatorsCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; import eu.carrade.amaury.quartzsurvivalgames.modules.core.spectators.SpectatorsModule; @@ -38,28 +39,24 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; +import java.util.List; +import java.util.Objects; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import java.util.List; -import java.util.Objects; - -@CommandInfo (name = "tp-spectators", usageParameters = "<x> <y> <z> | <target>", aliases = {"tpspectators", "tp-specs", "tpspecs"}) -public class TPSpectatorsCommand extends WorldBasedCommand -{ +@CommandInfo(name = "tp-spectators", usageParameters = "<x> <y> <z> | <target>", aliases = {"tpspectators", "tp-specs", + "tpspecs"}) +public class TPSpectatorsCommand extends WorldBasedCommand { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final SpectatorsModule spectators = QSG.module(SpectatorsModule.class); // /uh tp-spectators <x> <y> <z> - if (args.length == 3) - { - try - { + if (args.length == 3) { + try { final World world = getTargetWorld(); final double x = Integer.parseInt(args[0]) + 0.5; @@ -73,15 +70,13 @@ protected void run() throws CommandException /// {0}: world name. {1-3}: x, y, z. success(I.t("All spectators were teleported to ({0} ; {1} ; {2} ; {3}).", world.getName(), x, y, z)); } - catch (final NumberFormatException e) - { + catch (final NumberFormatException e) { throwInvalidArgument(I.t("{ce}The coordinates must be three valid numbers.")); } } // /uh tp-spectators <target> - else if (args.length == 1) - { + else if (args.length == 1) { final Player target = getPlayerParameter(0); spectators.getSpectators().stream() @@ -89,15 +84,17 @@ else if (args.length == 1) .forEach(spectator -> spectator.teleport(target, TeleportCause.PLUGIN)); success(I.t("All spectators were teleported to the player {0}.", target.getName())); + } else { + throwInvalidArgument(I.t("You must specify either three coordinates or a player name.")); } - - else throwInvalidArgument(I.t("You must specify either three coordinates or a player name.")); } @Override - protected List<String> complete() - { - if (args.length == 1) return getMatchingPlayerNames(args[0]); - else return null; + protected List<String> complete() { + if (args.length == 1) { + return getMatchingPlayerNames(args[0]); + } else { + return null; + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java index 8a7ba10..caa40d3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/TPTeamCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; import fr.zcraft.quartzlib.components.commands.CommandException; @@ -39,31 +40,26 @@ import fr.zcraft.quartzteams.QuartzTeam; import fr.zcraft.quartzteams.QuartzTeams; import fr.zcraft.quartzteams.texts.TextUtils; +import java.util.stream.Collectors; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; -import java.util.stream.Collectors; - -@CommandInfo (name = "tp-team", usageParameters = "<x> <y> <z> \"<team name>\" | <target> \"<team name>\"", aliases = {"tpteam", "tpt"}) -public class TPTeamCommand extends WorldBasedCommand -{ +@CommandInfo(name = "tp-team", usageParameters = "<x> <y> <z> \"<team name>\" | <target> \"<team name>\"", aliases = { + "tpteam", "tpt"}) +public class TPTeamCommand extends WorldBasedCommand { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final String[] qargs = TextUtils.extractArgsWithQuotes(args, 0); // possibly /uh tp-team <x> <y> <z> "<team ...>" - if (qargs.length == 4) - { + if (qargs.length == 4) { final QuartzTeam team = QuartzTeams.get().getTeamByName(qargs[3]); // ok, the team exists. - if (team != null) - { - try - { + if (team != null) { + try { final World world = getTargetWorld(); final double x = Integer.parseInt(args[0]) + 0.5; @@ -76,30 +72,26 @@ protected void run() throws CommandException success(I.t( "The players in the team {0} ({1}) were teleported to ({2} ; {3} ; {4} ; {5}).", team.getName(), - String.join(", ", team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), + String.join(", ", + team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), world.getName(), x, y, z )); return; } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { throwInvalidArgument(I.t("{ce}The coordinates must be three valid numbers.")); } } } // /uh tp team <target> "<team ...>" - if (qargs.length == 2) - { + if (qargs.length == 2) { final QuartzTeam team = QuartzTeams.get().getTeamByName(qargs[1]); - if (team == null) - { + if (team == null) { throwInvalidArgument(I.t("{ce}This team is not registered.")); - } - else - { + } else { final Player player = getPlayerParameter(0); team.teleportTo(player.getLocation()); @@ -107,7 +99,8 @@ protected void run() throws CommandException success(I.t( "The players in the team {0} ({1}) were teleported to the player {2}.", team.getName(), - String.join(", ", team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), + String.join(", ", + team.getPlayers().stream().map(OfflinePlayer::getName).collect(Collectors.toSet())), player.getName() )); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java index 0a65dce..0a53899 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/teleportation/commands/WorldBasedCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.teleportation.commands; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; @@ -39,20 +40,13 @@ import org.bukkit.command.BlockCommandSender; import org.bukkit.entity.Player; -public abstract class WorldBasedCommand extends Command -{ - protected World getTargetWorld() - { - if (sender instanceof Player) - { +public abstract class WorldBasedCommand extends Command { + protected World getTargetWorld() { + if (sender instanceof Player) { return ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { + } else if (sender instanceof BlockCommandSender) { return ((BlockCommandSender) sender).getBlock().getWorld(); - } - else - { + } else { return QSG.get().getWorld(World.Environment.NORMAL); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java index 8c796e9..480dae8 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/Config.java @@ -31,31 +31,27 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; import fr.zcraft.quartzlib.components.configuration.ConfigurationSection; -import org.bukkit.Material; - import java.io.File; +import org.bukkit.Material; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.section; +public class Config extends ConfigurationInstance { + public static final ConfigurationItem<Integer> HEIGHT = item("height", 128); + public static final BlockSection BLOCK = section("block", BlockSection.class); -public class Config extends ConfigurationInstance -{ - public Config(File file) - { + public Config(File file) { super(file); } - public static final ConfigurationItem<Integer> HEIGHT = item("height", 128); - - public static final BlockSection BLOCK = section("block", BlockSection.class); - - static public class BlockSection extends ConfigurationSection - { + static public class BlockSection extends ConfigurationSection { public final ConfigurationItem<Material> REPLACE_AIR = item("replace-air", Material.GLASS); public final ConfigurationItem<Material> REPLACE_SOLID = item("replace-solid", Material.BEDROCK); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java index 69c5458..c29984e 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; import eu.carrade.amaury.quartzsurvivalgames.QuartzSurvivalGames; @@ -45,41 +46,32 @@ import org.bukkit.entity.Player; @CommandInfo(name = "build-walls", aliases = {"buildwalls", "generate-walls", "generatewalls"}) -public class WallsCommand extends Command -{ +public class WallsCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { info(I.t("{cst}Generating the walls...")); final World world; - if (sender instanceof Player) - { + if (sender instanceof Player) { world = ((Player) sender).getWorld(); - } - else if (sender instanceof BlockCommandSender) - { + } else if (sender instanceof BlockCommandSender) { world = ((BlockCommandSender) sender).getBlock().getWorld(); - } - else - { + } else { world = QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL); info(I.t("{ci}From the console, generating the walls of the default world, {0}", world.getName())); } - try - { + try { QSG.module(WallsModule.class).generateWalls(world); } - catch (CannotGenerateWallsException e) - { - error(I.t("{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); + catch (CannotGenerateWallsException e) { + error(I.t( + "{ce}Unable to generate the wall: see logs for details. The blocks set in the config are probably invalid.")); return; } - catch (Exception e) - { + catch (Exception e) { error(I.t("{ce}An error occurred, see console for details.")); e.printStackTrace(); return; diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java index ffaf2ac..ac06ec1 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/WallsModule.java @@ -31,26 +31,26 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions.CannotGenerateWallsException; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions.UnknownWallGenerator; import eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators.WallGenerator; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; import fr.zcraft.quartzlib.components.commands.Command; -import org.bukkit.Material; -import org.bukkit.World; - import java.util.Collections; import java.util.List; +import org.bukkit.Material; +import org.bukkit.World; -@ModuleInfo ( +@ModuleInfo( name = "Walls Generator", description = "Provides a command to generate a solid wall around the arena.", when = ModuleLoadTime.POST_WORLD, @@ -58,19 +58,16 @@ icon = Material.BARRIER, settings = Config.class ) -public class WallsModule extends QSGModule -{ +public class WallsModule extends QSGModule { private BorderModule borderModule; @Override - protected void onEnable() - { + protected void onEnable() { borderModule = QSG.module(BorderModule.class); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(WallsCommand.class); } @@ -80,23 +77,23 @@ public List<Class<? extends Command>> getCommands() * @param world The world were the walls will be built in. * @throws CannotGenerateWallsException If an error occurred while generating the wall. */ - public void generateWalls(final World world) throws CannotGenerateWallsException - { + public void generateWalls(final World world) throws CannotGenerateWallsException { final Integer wallHeight = Config.HEIGHT.get(); final Material wallBlockAir = Config.BLOCK.REPLACE_AIR.get(); final Material wallBlockSolid = Config.BLOCK.REPLACE_SOLID.get(); - if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid()) - { + if (wallBlockAir == null || !wallBlockAir.isSolid() || wallBlockSolid == null || !wallBlockSolid.isSolid()) { throw new CannotGenerateWallsException("Cannot generate the walls: invalid blocks set in the config"); } - final WallGenerator generator = WallGenerator.fromShape(borderModule.getMapShape(), wallBlockAir, wallBlockSolid); + final WallGenerator generator = + WallGenerator.fromShape(borderModule.getMapShape(), wallBlockAir, wallBlockSolid); - if (generator != null) + if (generator != null) { generator.build(world, borderModule.getCurrentBorderDiameter(), wallHeight); - else + } else { throw new UnknownWallGenerator("Unable to load walls generator."); + } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java index dfc0cd1..1cc1216 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/CannotGenerateWallsException.java @@ -29,12 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions; -public class CannotGenerateWallsException extends Exception -{ - public CannotGenerateWallsException(String message) - { +public class CannotGenerateWallsException extends Exception { + public CannotGenerateWallsException(String message) { super(message); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java index e917799..001284b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/exceptions/UnknownWallGenerator.java @@ -29,12 +29,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.exceptions; -public class UnknownWallGenerator extends CannotGenerateWallsException -{ - public UnknownWallGenerator(String message) - { +public class UnknownWallGenerator extends CannotGenerateWallsException { + public UnknownWallGenerator(String message) { super(message); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java index 6c743d8..720457c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/CircularWallGenerator.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; import org.bukkit.Material; @@ -36,10 +37,8 @@ import org.bukkit.block.Block; -public class CircularWallGenerator extends WallGenerator -{ - public CircularWallGenerator(Material wallBlockAir, Material wallBlockSolid) - { +public class CircularWallGenerator extends WallGenerator { + public CircularWallGenerator(Material wallBlockAir, Material wallBlockSolid) { super(wallBlockAir, wallBlockSolid); } @@ -51,8 +50,7 @@ public CircularWallGenerator(Material wallBlockAir, Material wallBlockSolid) * @param wallHeight The height of the wall. */ @Override - public void build(World world, int diameter, int wallHeight) - { + public void build(World world, int diameter, int wallHeight) { // Only one quarter of the circle is explicitly set, the other parts are generated // following the first quarter. // The quarter chosen to be explicitly generated if the one on the South-East, @@ -76,16 +74,14 @@ public void build(World world, int diameter, int wallHeight) Block candidate3; // Infinite loop broken when the generation is done. - while (true) - { + while (true) { // 1) the current point, the symmetries and the opposite point are built. this.buildWallPoint(world, currentBlock.getX(), currentBlock.getZ(), wallHeight, diameter); // 2) the two candidates are found, except if the build is finished. - if (currentBlock.getX() == xSpawn) - { + if (currentBlock.getX() == xSpawn) { // END break; } @@ -96,22 +92,23 @@ public void build(World world, int diameter, int wallHeight) // 3) The good block is selected - Double distanceCandidate1ToRef = Math.abs((candidate1.getLocation().distance(world.getSpawnLocation()) - radius)); - Double distanceCandidate2ToRef = Math.abs((candidate2.getLocation().distance(world.getSpawnLocation()) - radius)); - Double distanceCandidate3ToRef = Math.abs((candidate3.getLocation().distance(world.getSpawnLocation()) - radius)); + Double distanceCandidate1ToRef = + Math.abs((candidate1.getLocation().distance(world.getSpawnLocation()) - radius)); + Double distanceCandidate2ToRef = + Math.abs((candidate2.getLocation().distance(world.getSpawnLocation()) - radius)); + Double distanceCandidate3ToRef = + Math.abs((candidate3.getLocation().distance(world.getSpawnLocation()) - radius)); // The first is better - if (distanceCandidate1ToRef < distanceCandidate2ToRef && distanceCandidate1ToRef < distanceCandidate3ToRef) - { + if (distanceCandidate1ToRef < distanceCandidate2ToRef && + distanceCandidate1ToRef < distanceCandidate3ToRef) { currentBlock = candidate1; } // The second is better - else if (distanceCandidate2ToRef < distanceCandidate1ToRef && distanceCandidate2ToRef < distanceCandidate3ToRef) - { + else if (distanceCandidate2ToRef < distanceCandidate1ToRef && + distanceCandidate2ToRef < distanceCandidate3ToRef) { currentBlock = candidate2; - } - else - { + } else { currentBlock = candidate3; } } @@ -128,8 +125,7 @@ else if (distanceCandidate2ToRef < distanceCandidate1ToRef && distanceCandidate2 * @param wallHeight * @param diameter */ - private void buildWallPoint(World world, int x, int z, int wallHeight, int diameter) - { + private void buildWallPoint(World world, int x, int z, int wallHeight, int diameter) { WallPosition positionOriginal; WallPosition positionSymmetricX; WallPosition positionSymmetricZ; @@ -147,15 +143,12 @@ private void buildWallPoint(World world, int x, int z, int wallHeight, int diame // Following the way the wall is generated, the position of the original // "tower" can only be « SOUTH » or « EAST ». - if (z > Math.floor(diameter / 2)) - { + if (z > Math.floor(diameter / 2)) { positionOriginal = WallPosition.SOUTH; positionSymmetricX = WallPosition.SOUTH; positionSymmetricZ = WallPosition.NORTH; positionOpposite = WallPosition.NORTH; - } - else - { + } else { positionOriginal = WallPosition.EAST; positionSymmetricX = WallPosition.WEST; positionSymmetricZ = WallPosition.EAST; @@ -163,8 +156,7 @@ private void buildWallPoint(World world, int x, int z, int wallHeight, int diame } // The 4 towers are built. - for (int y = 1; y <= wallHeight; y++) - { + for (int y = 1; y <= wallHeight; y++) { setBlock(world.getBlockAt(x, y, z), positionOriginal); setBlock(world.getBlockAt(x - 2 * (x - xSpawn), y, z), positionSymmetricX); setBlock(world.getBlockAt(x, y, z + 2 * (zSpawn - z)), positionSymmetricZ); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java index b91d7b3..afba7e4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/SquaredWallGenerator.java @@ -29,16 +29,15 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.walls.generators; import org.bukkit.Material; import org.bukkit.World; -public class SquaredWallGenerator extends WallGenerator -{ - public SquaredWallGenerator(Material wallBlockAir, Material wallBlockSolid) - { +public class SquaredWallGenerator extends WallGenerator { + public SquaredWallGenerator(Material wallBlockAir, Material wallBlockSolid) { super(wallBlockAir, wallBlockSolid); } @@ -50,8 +49,7 @@ public SquaredWallGenerator(Material wallBlockAir, Material wallBlockSolid) * @param wallHeight The height of the wall. */ @Override - public void build(World world, int diameter, int wallHeight) - { + public void build(World world, int diameter, int wallHeight) { final int halfDiameter = (int) Math.floor(diameter / 2); final int limitXInf = world.getSpawnLocation().add(-halfDiameter, 0, 0).getBlockX(); @@ -59,25 +57,21 @@ public void build(World world, int diameter, int wallHeight) final int limitZInf = world.getSpawnLocation().add(0, 0, -halfDiameter).getBlockZ(); final int limitZSup = world.getSpawnLocation().add(0, 0, halfDiameter).getBlockZ(); - for (int x = limitXInf; x <= limitXSup; x++) - { + for (int x = limitXInf; x <= limitXSup; x++) { world.getBlockAt(x, 1, limitZInf).setType(Material.BEDROCK); world.getBlockAt(x, 1, limitZSup).setType(Material.BEDROCK); - for (int y = 2; y <= wallHeight; y++) - { + for (int y = 2; y <= wallHeight; y++) { setBlock(world.getBlockAt(x, y, limitZInf), WallPosition.NORTH); setBlock(world.getBlockAt(x, y, limitZSup), WallPosition.SOUTH); } } - for (int z = limitZInf + 1; z <= limitZSup - 1; z++) - { + for (int z = limitZInf + 1; z <= limitZSup - 1; z++) { world.getBlockAt(limitXInf, 1, z).setType(Material.BEDROCK); world.getBlockAt(limitXSup, 1, z).setType(Material.BEDROCK); - for (int y = 2; y <= wallHeight; y++) - { + for (int y = 2; y <= wallHeight; y++) { setBlock(world.getBlockAt(limitXInf, y, z), WallPosition.WEST); setBlock(world.getBlockAt(limitXSup, y, z), WallPosition.EAST); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java index 6acb80c..fe1ab04 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallGenerator.java @@ -39,19 +39,40 @@ import org.bukkit.block.Block; -public abstract class WallGenerator -{ +public abstract class WallGenerator { final private Material wallBlockAir; final private Material wallBlockSolid; private int blocksSet = 0; - public WallGenerator(Material wallBlockAir, Material wallBlockSolid) - { + public WallGenerator(Material wallBlockAir, Material wallBlockSolid) { this.wallBlockAir = wallBlockAir != null ? wallBlockAir : Material.GLASS; this.wallBlockSolid = wallBlockSolid != null ? wallBlockSolid : Material.BEDROCK; } + /** + * Returns a new instance of the wall generator for the given shape. + * + * @param shape The shape. + * @param wallBlockAir The block to use to replace air. + * @param wallBlockSolid The block to use to replace solid blocks. + * @return The instance. + * @see WallGenerator#WallGenerator(Material, Material) + */ + public static WallGenerator fromShape(final MapShape shape, final Material wallBlockAir, + final Material wallBlockSolid) { + Validate.notNull(shape, "Map shape must not be null."); + + switch (shape) { + case CIRCULAR: + return new CircularWallGenerator(wallBlockAir, wallBlockSolid); + + case SQUARED: + return new SquaredWallGenerator(wallBlockAir, wallBlockSolid); + } + + return null; + } /** * Builds a wall in the world. @@ -62,33 +83,26 @@ public WallGenerator(Material wallBlockAir, Material wallBlockSolid) */ public abstract void build(World world, int diameter, int wallHeight); - /** * Sets a block according to his environment. * If the block replaces a "air/tree" block, or if it is next to a transparent block, it needs to be a * "wall.block.replaceAir" block. * In all other cases, it needs to be a "wall.block.replaceSolid" one. * - * @param block The block to set. + * @param block The block to set. * @param position The position of the current wall in the world */ - protected void setBlock(Block block, WallPosition position) - { + protected void setBlock(Block block, WallPosition position) { // The block is a transparent block or a tree - if (isBlockTransparentOrNatural(block.getType())) - { + if (isBlockTransparentOrNatural(block.getType())) { block.setType(wallBlockAir); } // We set the block according to the block near it inside the border. - else - { + else { final Material innerMaterial = getInnerBlock(block, position).getType(); - if (isBlockTransparentOrNatural(innerMaterial)) - { + if (isBlockTransparentOrNatural(innerMaterial)) { block.setType(wallBlockAir); - } - else - { + } else { block.setType(wallBlockSolid); } } @@ -103,15 +117,12 @@ protected void setBlock(Block block, WallPosition position) * @return boolean True if the block is transparent, or part of a tree/a giant mushroom/a * generated structure/etc. */ - protected Boolean isBlockTransparentOrNatural(Material blockType) - { - if (blockType.isTransparent()) - { + protected Boolean isBlockTransparentOrNatural(Material blockType) { + if (blockType.isTransparent()) { return true; } - switch (blockType) - { + switch (blockType) { // TODO re-add stained glass, stained glass pane, logs, leaves, beds, signs, fences // Low priority as this is mostly unused anyway, with vanilla world border. case GLASS: // The glass isn't a transparent block for the `isTransparent` method. @@ -147,19 +158,17 @@ protected Boolean isBlockTransparentOrNatural(Material blockType) /** * Gets the block left to the given block inside the border. * - * @param block The reference block. + * @param block The reference block. * @param position The position of the wall currently build. */ - protected Block getInnerBlock(Block block, WallPosition position) - { + protected Block getInnerBlock(Block block, WallPosition position) { // Just for readability. final World world = block.getWorld(); final int x = block.getX(); final int y = block.getY(); final int z = block.getZ(); - switch (position) - { + switch (position) { case EAST: return world.getBlockAt(x - 1, y, z); case NORTH: @@ -173,34 +182,7 @@ protected Block getInnerBlock(Block block, WallPosition position) } } - public int getBlocksSet() - { + public int getBlocksSet() { return blocksSet; } - - /** - * Returns a new instance of the wall generator for the given shape. - * - * @param shape The shape. - * @param wallBlockAir The block to use to replace air. - * @param wallBlockSolid The block to use to replace solid blocks. - * - * @return The instance. - * @see WallGenerator#WallGenerator(Material, Material) - */ - public static WallGenerator fromShape(final MapShape shape, final Material wallBlockAir, final Material wallBlockSolid) - { - Validate.notNull(shape, "Map shape must not be null."); - - switch (shape) - { - case CIRCULAR: - return new CircularWallGenerator(wallBlockAir, wallBlockSolid); - - case SQUARED: - return new SquaredWallGenerator(wallBlockAir, wallBlockSolid); - } - - return null; - } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java index 0455203..d0be294 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/walls/generators/WallPosition.java @@ -34,14 +34,13 @@ /** * Used to determine in witch wall we are, to get the "inner" block. - * + * <p> * North: small Z * South: big Z * East: big X * West: small X */ -public enum WallPosition -{ +public enum WallPosition { NORTH, SOUTH, EAST, diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java index 7283d95..1a2c4e4 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/BorderWarningTask.java @@ -29,6 +29,7 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; @@ -39,14 +40,12 @@ import org.bukkit.scheduler.BukkitRunnable; -public class BorderWarningTask extends BukkitRunnable -{ +public class BorderWarningTask extends BukkitRunnable { private final BorderModule borderModule = QSG.module(BorderModule.class); private final WarningModule warningModule = QSG.module(WarningModule.class); @Override - public void run() - { + public void run() { // final FreezerModule freezer = UR.module(FreezerModule.class); // if (freezer != null && freezer.getGlobalFreezeState()) // { @@ -54,20 +53,20 @@ public void run() // } // Message sent to all players outside the border - for (Player player : borderModule.getPlayersOutside(warningModule.getWarningSize())) - { + for (Player player : borderModule.getPlayersOutside(warningModule.getWarningSize())) { double distance = borderModule.getDistanceToBorder(player.getLocation(), warningModule.getWarningSize()); - if (borderModule.getMapShape() == MapShape.CIRCULAR) - { - player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", "{ce}You are currently out of the future border (diameter of {0} blocks).", warningModule.getWarningSize())); - } - else - { - player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", warningModule.getWarningSize())); + if (borderModule.getMapShape() == MapShape.CIRCULAR) { + player.sendMessage(I.tn("{ce}You are currently out of the future border (diameter of {0} block).", + "{ce}You are currently out of the future border (diameter of {0} blocks).", + warningModule.getWarningSize())); + } else { + player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", + warningModule.getWarningSize())); } - player.sendMessage(I.tn("{ci}You have {0} block to go before being inside.", "{ci}You have {0} blocks to go before being inside.", (int) distance)); + player.sendMessage(I.tn("{ci}You have {0} block to go before being inside.", + "{ci}You have {0} blocks to go before being inside.", (int) distance)); } } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java index 8047325..e24b77c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/Config.java @@ -31,22 +31,21 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; - import java.io.File; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; +public class Config extends ConfigurationInstance { + public static final ConfigurationItem<TimeDelta> WARNING_INTERVAL = + item("warning-interval", new TimeDelta(0, 1, 30)); -public class Config extends ConfigurationInstance -{ - public Config(File file) - { + public Config(File file) { super(file); } - - public static final ConfigurationItem<TimeDelta> WARNING_INTERVAL = item("warning-interval", new TimeDelta(0, 1, 30)); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java index ffc873f..0f1f76d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningCommand.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; @@ -39,30 +40,25 @@ import fr.zcraft.quartzlib.components.commands.CommandException; import fr.zcraft.quartzlib.components.commands.CommandInfo; import fr.zcraft.quartzlib.components.i18n.I; - import java.util.List; -@CommandInfo ( +@CommandInfo( name = "border-warning", usageParameters = "<future border size | cancel> [time delta (minutes or mm:ss or hh:mm:ss) until border reduction]", aliases = {"borderwarning", "borderwarn", "bw"} ) -public class WarningCommand extends Command -{ +public class WarningCommand extends Command { @Override - protected void run() throws CommandException - { + protected void run() throws CommandException { final WarningModule warnings = QSG.module(WarningModule.class); // /uh border warning - if (args.length == 0) - { + if (args.length == 0) { throwInvalidArgument(I.t("Missing future border size.")); } // /uh border warning cancel - else if (args[0].equalsIgnoreCase("cancel")) - { + else if (args[0].equalsIgnoreCase("cancel")) { warnings.cancelWarning(); success(I.t("{cs}Warning canceled.")); } @@ -70,33 +66,31 @@ else if (args[0].equalsIgnoreCase("cancel")) // /uh border warning <?> // or // /uh border warning <?> <?> - else - { - try - { + else { + try { final int warnDiameter = Integer.parseInt(args[0]); TimeDelta warnTime = null; // /uh border warning <?> <?> - if (args.length >= 2) - { + if (args.length >= 2) { warnTime = new TimeDelta(args[1]); } warnings.setWarningSize(warnDiameter, warnTime, sender); - success(I.tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", (int) Config.WARNING_INTERVAL.get().getSeconds())); + success(I + .tn("{cs}Future size saved. All players outside this future border will be warned every {0} second.", + "{cs}Future size saved. All players outside this future border will be warned every {0} seconds.", + (int) Config.WARNING_INTERVAL.get().getSeconds())); } - catch (NumberFormatException e) - { + catch (NumberFormatException e) { error(I.t("{ce}“{0}” is not a number...", args[0])); } } } @Override - protected List<String> complete() throws CommandException - { + protected List<String> complete() throws CommandException { return args.length == 1 ? getMatchingSubset(args[0], "cancel") : null; } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java index 74e3f30..24e6188 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/warning/WarningModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.utilities.warning; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -45,15 +46,14 @@ import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.Collections; +import java.util.List; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; import org.bukkit.scheduler.BukkitRunnable; -import java.util.Collections; -import java.util.List; - -@ModuleInfo ( +@ModuleInfo( name = "Border Warning", description = "Warns players about the future border size.", when = ModuleLoadTime.ON_GAME_START, @@ -61,34 +61,30 @@ icon = Material.NETHER_BRICK_FENCE, settings = Config.class ) -public class WarningModule extends QSGModule -{ +public class WarningModule extends QSGModule { private Integer warningSize = 0; private BukkitRunnable warningTask = null; - private Boolean warningFinalTimeEnabled = false; + private final Boolean warningFinalTimeEnabled = false; private Timer warningTimer = null; private String warningTimerName = null; private CommandSender warningSender = null; @Override - protected void onEnable() - { + protected void onEnable() { /// The name of the warning timer displaying the time left before the next border warningTimerName = I.t("Border shrinking"); } @Override - protected void onDisable() - { + protected void onDisable() { cancelWarning(); } @Override - public List<Class<? extends Command>> getCommands() - { + public List<Class<? extends Command>> getCommands() { return Collections.singletonList(WarningCommand.class); } @@ -98,49 +94,57 @@ public List<Class<? extends Command>> getCommands() * * @return the future border diameter. */ - public int getWarningSize() - { + public int getWarningSize() { return this.warningSize; } + /** + * Sets the size of the future border, used in the warning messages sent to the + * players out of this future border. + * <p> + * This also starts the display of the warning messages, every 90 seconds by default + * (configurable, see config.yml, map.border.warningInterval). + * + * @param diameter The diameter of the future border. + */ + public void setWarningSize(final int diameter) { + setWarningSize(diameter, null, null); + } + /** * @return true if there is currently a warning with a time left displayed. */ - public boolean getWarningFinalTimeEnabled() - { + public boolean getWarningFinalTimeEnabled() { return this.warningFinalTimeEnabled; } /** * @return the sender of the last warning configured. */ - public CommandSender getWarningSender() - { + public CommandSender getWarningSender() { return this.warningSender; } /** * Sets the size of the future border, used in the warning messages sent to the * players out of this future border. - * + * <p> * This also starts the display of the warning messages, every 90 seconds by default * (configurable, see config.yml, map.border.warningInterval). - * + * <p> * If timeLeft is not null, the time available for the players to go inside the future * border is displayed in the warning message. * * @param diameter The future diameter. * @param timeLeft The time available for the players to go inside the future border. - * @param sender The user who requested this change. + * @param sender The user who requested this change. */ - public void setWarningSize(final int diameter, final TimeDelta timeLeft, final CommandSender sender) - { + public void setWarningSize(final int diameter, final TimeDelta timeLeft, final CommandSender sender) { cancelWarning(); this.warningSize = diameter; - if (timeLeft != null) - { + if (timeLeft != null) { warningTimer = new Timer(this.warningTimerName); warningTimer.setDuration((int) timeLeft.getSeconds()); @@ -149,8 +153,7 @@ public void setWarningSize(final int diameter, final TimeDelta timeLeft, final C warningTimer.start(); } - if (sender != null) - { + if (sender != null) { this.warningSender = sender; } @@ -161,36 +164,19 @@ public void setWarningSize(final int diameter, final TimeDelta timeLeft, final C ); } - /** - * Sets the size of the future border, used in the warning messages sent to the - * players out of this future border. - * - * This also starts the display of the warning messages, every 90 seconds by default - * (configurable, see config.yml, map.border.warningInterval). - * - * @param diameter The diameter of the future border. - */ - public void setWarningSize(final int diameter) - { - setWarningSize(diameter, null, null); - } - /** * Stops the display of the warning messages. */ - public void cancelWarning() - { - if (warningTask != null) - { - try - { + public void cancelWarning() { + if (warningTask != null) { + try { warningTask.cancel(); } - catch (IllegalStateException ignored) {} + catch (IllegalStateException ignored) { + } } - if (warningTimer != null) - { + if (warningTimer != null) { warningTimer.stop(); QSG.module(TimersModule.class).unregisterTimer(warningTimer); } @@ -198,8 +184,7 @@ public void cancelWarning() @EventHandler - public void onBorderChanged(final BorderChangedEvent ev) - { + public void onBorderChanged(final BorderChangedEvent ev) { cancelWarning(); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java index b512e67..f4cb530 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/Config.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait; import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; @@ -42,41 +43,32 @@ import java.io.File; import org.bukkit.Material; -public class Config extends ConfigurationInstance -{ - public Config(File file) - { +public class Config extends ConfigurationInstance { + static public final ConfigurationItem<Boolean> TELEPORT_TO_SPAWN_IF_NOT_STARTED = + item("teleport-to-spawn-if-not-started", true); + public static final InventorySection INVENTORY = section("inventory", InventorySection.class); + public static final TeamSelectorSection TEAM_SELECTOR = section("teams-selector", TeamSelectorSection.class); + public static final ConfigAccessorSection CONFIG_ACCESSOR = section("config-accessor", ConfigAccessorSection.class); + public static final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("team-in-action-bar", true); + public static final ConfigurationItem<Boolean> ENABLE_PVP = item("enable-pvp", false); + + public Config(File file) { super(file); } - static public final ConfigurationItem<Boolean> TELEPORT_TO_SPAWN_IF_NOT_STARTED = item("teleport-to-spawn-if-not-started", true); - - public static final InventorySection INVENTORY = section("inventory", InventorySection.class); - - static public class InventorySection extends ConfigurationSection - { + static public class InventorySection extends ConfigurationSection { public final ConfigurationItem<Boolean> CLEAR = item("clear", true); public final ConfigurationItem<Boolean> PREVENT_USAGE = item("prevent-usage", true); public final ConfigurationItem<Boolean> ALLOW_FOR_BUILDERS = item("allow-for-builders", true); } - public static final TeamSelectorSection TEAM_SELECTOR = section("teams-selector", TeamSelectorSection.class); - - static public class TeamSelectorSection extends ConfigurationSection - { + static public class TeamSelectorSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); public final ConfigurationItem<Material> ITEM = item("item", Material.NETHER_STAR); } - public static final ConfigAccessorSection CONFIG_ACCESSOR = section("config-accessor", ConfigAccessorSection.class); - - static public class ConfigAccessorSection extends ConfigurationSection - { + static public class ConfigAccessorSection extends ConfigurationSection { public final ConfigurationItem<Boolean> ENABLED = item("enabled", true); public final ConfigurationItem<Material> ITEM = item("item", Material.COMPARATOR); } - - public static final ConfigurationItem<Boolean> TEAM_IN_ACTION_BAR = item("team-in-action-bar", true); - - public static final ConfigurationItem<Boolean> ENABLE_PVP = item("enable-pvp", false); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java index 9c215e9..bb26c07 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/waitingPhase/wait/WaitModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.waitingPhase.wait; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -60,7 +61,15 @@ import fr.zcraft.quartzteams.events.TeamUnregisteredEvent; import fr.zcraft.quartzteams.events.TeamUpdatedEvent; import fr.zcraft.quartzteams.guis.TeamsSelectorGUI; -import org.bukkit.*; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -70,17 +79,17 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permissible; import org.bukkit.scheduler.BukkitTask; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -@ModuleInfo ( +@ModuleInfo( name = "Waiting phase", description = "Manages the waiting phase: inventory, effects, modes, teleportation, etc.", category = ModuleCategory.WAITING_PHASE, @@ -88,26 +97,22 @@ settings = Config.class, can_be_loaded_late = false ) -public class WaitModule extends QSGModule -{ +public class WaitModule extends QSGModule { private final static UUID ACTIONABLE_ITEM_UUID = UUID.fromString("3f65c4a9-e1ae-437e-b8b4-57d80a831480"); private final Map<UUID, String> playerInventoriesStates = new HashMap<>(); private BukkitTask inventoriesUpdateTask = null; @Override - protected void onEnable() - { + protected void onEnable() { Bukkit.getOnlinePlayers().forEach(this::handleNewPlayer); inventoriesUpdateTask = RunTask.timer(() -> Bukkit.getOnlinePlayers().forEach(this::updateInventory), 20L, 20L); } @Override - protected void onDisable() - { - if (inventoriesUpdateTask != null) - { + protected void onDisable() { + if (inventoriesUpdateTask != null) { inventoriesUpdateTask.cancel(); inventoriesUpdateTask = null; } @@ -116,37 +121,34 @@ protected void onDisable() /** * Writes an action into an Item Stack. * - * @param item The item. This must be a CraftItemStack. + * @param item The item. This must be a CraftItemStack. * @param action The action to store. * @see #readAction(ItemStack) to read a previously stored action. */ - private void writeAction(final ItemStack item, final String action) - { + private void writeAction(final ItemStack item, final String action) { final Attribute attribute = new Attribute(); attribute.setUUID(ACTIONABLE_ITEM_UUID); attribute.setCustomData(action); - try - { + try { Attributes.set(item, attribute); } - catch (final NMSException e) - { - PluginLogger.error("Unable to store item action into attribute. Inventory tools won't work before the game."); + catch (final NMSException e) { + PluginLogger + .error("Unable to store item action into attribute. Inventory tools won't work before the game."); } } /** * Reads an action previously written into this ItemStack. + * * @param item The item. * @return The action, or en empty string if nothing stored. * @see #writeAction(ItemStack, String) to write an action. */ - private String readAction(final ItemStack item) - { - try - { + private String readAction(final ItemStack item) { + try { final Attribute attribute = Attributes.get(item, ACTIONABLE_ITEM_UUID); return attribute != null && attribute.getCustomData() != null ? attribute.getCustomData() : ""; } @@ -159,14 +161,14 @@ private String readAction(final ItemStack item) * Opens the teams selector GUI, if needed (enabled, game not started, needed item). * * @param player The player who right-clicked an item. - * @param item The right-clicked item. + * @param item The right-clicked item. */ - private boolean openGUI(Player player, ItemStack item) - { - if (isGameStarted() || item == null) return false; + private boolean openGUI(Player player, ItemStack item) { + if (isGameStarted() || item == null) { + return false; + } - switch (readAction(item)) - { + switch (readAction(item)) { case "teams": Gui.open(player, new TeamsSelectorGUI()); return true; @@ -176,8 +178,9 @@ private boolean openGUI(Player player, ItemStack item) { Gui.open(player, new MainConfigGUI()); return true; + } else { + return false; } - else return false; } return false; @@ -188,19 +191,15 @@ private boolean openGUI(Player player, ItemStack item) * * @param player The player to setup. */ - private void handleNewPlayer(final Player player) - { - if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get() && QSG.game().getPhase() != GamePhase.STARTING) - { + private void handleNewPlayer(final Player player) { + if (Config.TELEPORT_TO_SPAWN_IF_NOT_STARTED.get() && QSG.game().getPhase() != GamePhase.STARTING) { final Location worldSpawn = QSG .get().getWorld(World.Environment.NORMAL).getSpawnLocation().add(0.5, 0.5, 0.5); - if (!QSGUtils.safeTP(player, worldSpawn)) - { + if (!QSGUtils.safeTP(player, worldSpawn)) { player.teleport(worldSpawn.add(0, 1, 0)); } - if (Config.ENABLE_PVP.get()) - { + if (Config.ENABLE_PVP.get()) { player.setBedSpawnLocation(worldSpawn, true); } } @@ -221,16 +220,15 @@ private void handleNewPlayer(final Player player) * * @param player The player to update. */ - private void updateInventory(final Player player) - { + private void updateInventory(final Player player) { final boolean builder = isBuilder(player); final boolean teamsDisplayed = Config.TEAM_SELECTOR.ENABLED.get(); final boolean configDisplayed = Config.CONFIG_ACCESSOR.ENABLED.get() && player.isOp(); // Only updates the inventory when the access state change. final String state = String.format("%b%b%b", builder, teamsDisplayed, configDisplayed); - if (playerInventoriesStates.containsKey(player.getUniqueId()) && playerInventoriesStates.get(player.getUniqueId()).equals(state)) - { + if (playerInventoriesStates.containsKey(player.getUniqueId()) && + playerInventoriesStates.get(player.getUniqueId()).equals(state)) { return; } @@ -238,26 +236,24 @@ private void updateInventory(final Player player) player.setGameMode(builder ? GameMode.CREATIVE : GameMode.ADVENTURE); - if (!builder && Config.INVENTORY.CLEAR.get()) - { + if (!builder && Config.INVENTORY.CLEAR.get()) { player.getInventory().clear(); player.getInventory().setArmorContents(null); } - if (Config.TEAM_SELECTOR.ENABLED.get() || Config.CONFIG_ACCESSOR.ENABLED.get()) - { + if (Config.TEAM_SELECTOR.ENABLED.get() || Config.CONFIG_ACCESSOR.ENABLED.get()) { final ItemStack teamsSelector = new ItemStackBuilder(Config.TEAM_SELECTOR.ITEM.get()) /// The title of the item given before the game to select a team .title(I.t("{green}{bold}Select a team {gray}(Right-Click)")) /// The lore of the item given before the game to select a team .longLore(I.t("{gray}Right-click to select your team for this game")) - .hideAttributes() + .hideAllAttributes() .craftItem(); final ItemStack configAccessor = new ItemStackBuilder(Config.CONFIG_ACCESSOR.ITEM.get()) .title(I.t("{red}{bold}Configure the game {gray}(Right-Click)")) .longLore(I.t("{gray}Right-click to open the game configuration GUI")) - .hideAttributes() + .hideAllAttributes() .craftItem(); writeAction(teamsSelector, "teams"); @@ -271,32 +267,26 @@ private void updateInventory(final Player player) clearIfSimilar(player, configAccessor, 4); clearIfSimilar(player, configAccessor, 6); - if (teamsDisplayed) - { + if (teamsDisplayed) { placeIfPossible(player, teamsSelector, teamsSlot); } - if (configDisplayed) - { + if (configDisplayed) { placeIfPossible(player, configAccessor, configSlot); } } } - private void placeIfPossible(final Player player, final ItemStack item, final int slot) - { + private void placeIfPossible(final Player player, final ItemStack item, final int slot) { final ItemStack previousItem = player.getInventory().getItem(slot); - if (!isBuilder(player) || previousItem == null || previousItem.getType() == org.bukkit.Material.AIR) - { + if (!isBuilder(player) || previousItem == null || previousItem.getType() == org.bukkit.Material.AIR) { player.getInventory().setItem(slot, item); } } - private void clearIfSimilar(final Player player, final ItemStack ifSimilarTo, final int slot) - { + private void clearIfSimilar(final Player player, final ItemStack ifSimilarTo, final int slot) { final ItemStack previousItem = player.getInventory().getItem(slot); - if (previousItem != null && previousItem.getType() == ifSimilarTo.getType()) - { + if (previousItem != null && previousItem.getType() == ifSimilarTo.getType()) { player.getInventory().setItem(slot, new ItemStack(Material.AIR)); } } @@ -307,97 +297,113 @@ private void clearIfSimilar(final Player player, final ItemStack ifSimilarTo, fi * * @param player The player. */ - private void displayTeamInActionBar(final OfflinePlayer player) - { - if (!Config.TEAM_IN_ACTION_BAR.get() || player == null) return; + private void displayTeamInActionBar(final OfflinePlayer player) { + if (!Config.TEAM_IN_ACTION_BAR.get() || player == null) { + return; + } final Player onlinePlayer; - if (player instanceof Player) onlinePlayer = (Player) player; - else onlinePlayer = Bukkit.getPlayer(player.getUniqueId()); + if (player instanceof Player) { + onlinePlayer = (Player) player; + } else { + onlinePlayer = Bukkit.getPlayer(player.getUniqueId()); + } - if (onlinePlayer == null) return; + if (onlinePlayer == null) { + return; + } final QuartzTeam team = QuartzTeams.get().getTeamForPlayer(player); - if (team != null) + if (team != null) { ActionBar.sendPermanentMessage(onlinePlayer, I.t("{gold}Your team: {0}", team.getDisplayName())); - else + } else { ActionBar.removeMessage(onlinePlayer, true); + } } @EventHandler - public void onPlayerJoin(final PlayerJoinEvent ev) - { - if (isGameStarted()) return; + public void onPlayerJoin(final PlayerJoinEvent ev) { + if (isGameStarted()) { + return; + } handleNewPlayer(ev.getPlayer()); } @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerInteract(PlayerInteractEvent ev) - { - if (ev.getAction() != Action.PHYSICAL && openGUI(ev.getPlayer(), ev.getItem())) - { + public void onPlayerInteract(PlayerInteractEvent ev) { + if (ev.getAction() != Action.PHYSICAL && openGUI(ev.getPlayer(), ev.getItem())) { ev.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent ev) - { - if (openGUI(ev.getPlayer(), ev.getPlayer().getItemInHand())) - { + public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent ev) { + if (openGUI(ev.getPlayer(), ev.getPlayer().getItemInHand())) { ev.setCancelled(true); } } @EventHandler - public void onPlayerClick(InventoryClickEvent ev) - { - if (Config.INVENTORY.PREVENT_USAGE.get()) - { - if (isGameStarted()) return; - if (isBuilder(ev.getWhoClicked())) return; - if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; + public void onPlayerClick(InventoryClickEvent ev) { + if (Config.INVENTORY.PREVENT_USAGE.get()) { + if (isGameStarted()) { + return; + } + if (isBuilder(ev.getWhoClicked())) { + return; + } + if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) { + return; + } ev.setCancelled(true); } } @EventHandler - public void onPlayerDrag(InventoryDragEvent ev) - { - if (Config.INVENTORY.PREVENT_USAGE.get()) - { - if (isGameStarted()) return; - if (isBuilder(ev.getWhoClicked())) return; - if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) return; + public void onPlayerDrag(InventoryDragEvent ev) { + if (Config.INVENTORY.PREVENT_USAGE.get()) { + if (isGameStarted()) { + return; + } + if (isBuilder(ev.getWhoClicked())) { + return; + } + if (!ev.getInventory().equals(ev.getWhoClicked().getInventory())) { + return; + } ev.setCancelled(true); } } @EventHandler - public void onPlayerDrop(PlayerDropItemEvent ev) - { - if (Config.INVENTORY.PREVENT_USAGE.get()) - { - if (isGameStarted()) return; - if (isBuilder(ev.getPlayer())) return; + public void onPlayerDrop(PlayerDropItemEvent ev) { + if (Config.INVENTORY.PREVENT_USAGE.get()) { + if (isGameStarted()) { + return; + } + if (isBuilder(ev.getPlayer())) { + return; + } ev.setCancelled(true); } } @EventHandler - public void onPlayerPickup(PlayerPickupItemEvent ev) - { - if (isGameStarted()) return; - if (isBuilder(ev.getPlayer())) return; + public void onPlayerPickup(PlayerPickupItemEvent ev) { + if (isGameStarted()) { + return; + } + if (isBuilder(ev.getPlayer())) { + return; + } - if (Config.INVENTORY.PREVENT_USAGE.get()) - { + if (Config.INVENTORY.PREVENT_USAGE.get()) { ev.setCancelled(true); } } @@ -406,13 +412,10 @@ public void onPlayerPickup(PlayerPickupItemEvent ev) * Used to disable all damages if the game is not started. */ @EventHandler - public void onEntityDamage(final EntityDamageEvent ev) - { - if (ev.getEntity() instanceof Player) - { + public void onEntityDamage(final EntityDamageEvent ev) { + if (ev.getEntity() instanceof Player) { if (!isGameStarted() - || (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT && !Config.ENABLE_PVP.get())) - { + || (QSG.module(GameModule.class).getPhase() == GamePhase.WAIT && !Config.ENABLE_PVP.get())) { ev.setCancelled(true); } } @@ -425,12 +428,10 @@ public void onEntityDamage(final EntityDamageEvent ev) * (the difficulty is not correctly updated client-side when the game starts). */ @EventHandler - public void onCreatureSpawn(CreatureSpawnEvent ev) - { + public void onCreatureSpawn(CreatureSpawnEvent ev) { if (!isGameStarted() && EntitiesUtils.isNaturalSpawn(ev.getSpawnReason()) - && EntitiesUtils.isHostile(ev.getEntityType())) - { + && EntitiesUtils.isHostile(ev.getEntityType())) { ev.setCancelled(true); } } @@ -439,12 +440,12 @@ public void onCreatureSpawn(CreatureSpawnEvent ev) * Used to prevent the food level from dropping if the game has not started. */ @EventHandler - public void onFoodUpdate(final FoodLevelChangeEvent ev) - { - if (isGameStarted()) return; + public void onFoodUpdate(final FoodLevelChangeEvent ev) { + if (isGameStarted()) { + return; + } - if (ev.getEntity() instanceof Player) - { + if (ev.getEntity() instanceof Player) { ((Player) ev.getEntity()).setFoodLevel(20); ((Player) ev.getEntity()).setSaturation(20f); } @@ -457,8 +458,7 @@ public void onFoodUpdate(final FoodLevelChangeEvent ev) * Used to display the team in the action bar (if needed). */ @EventHandler - public void onTeamJoin(final PlayerJoinedTeamEvent ev) - { + public void onTeamJoin(final PlayerJoinedTeamEvent ev) { displayTeamInActionBar(ev.getPlayer()); } @@ -466,8 +466,7 @@ public void onTeamJoin(final PlayerJoinedTeamEvent ev) * Used to display the team in the action bar (if needed). */ @EventHandler - public void onTeamUpdated(final TeamUpdatedEvent ev) - { + public void onTeamUpdated(final TeamUpdatedEvent ev) { ev.getTeam().getOnlinePlayers().forEach(this::displayTeamInActionBar); } @@ -475,8 +474,7 @@ public void onTeamUpdated(final TeamUpdatedEvent ev) * Used to display the team in the action bar (if needed). */ @EventHandler - public void onTeamDeleted(final TeamUnregisteredEvent ev) - { + public void onTeamDeleted(final TeamUnregisteredEvent ev) { ev.getTeam().getOnlinePlayers().forEach(this::displayTeamInActionBar); } @@ -484,8 +482,7 @@ public void onTeamDeleted(final TeamUnregisteredEvent ev) * Used to display the team in the action bar (if needed). */ @EventHandler - public void onTeamLeft(final PlayerLeftTeamEvent ev) - { + public void onTeamLeft(final PlayerLeftTeamEvent ev) { displayTeamInActionBar(ev.getPlayer()); } @@ -495,10 +492,8 @@ public void onTeamLeft(final PlayerLeftTeamEvent ev) * This listener will self-disable when the game starts. */ @EventHandler - public void onGameStarts(final GamePhaseChangedEvent ev) - { - switch (ev.getNewPhase()) - { + public void onGameStarts(final GamePhaseChangedEvent ev) { + switch (ev.getNewPhase()) { case STARTING: Bukkit.getOnlinePlayers().forEach(player -> { ActionBar.removeMessage(player); @@ -512,8 +507,7 @@ public void onGameStarts(final GamePhaseChangedEvent ev) case IN_GAME: QuartzLib.unregisterEvents(this); - if (inventoriesUpdateTask != null) - { + if (inventoriesUpdateTask != null) { inventoriesUpdateTask.cancel(); inventoriesUpdateTask = null; } @@ -526,16 +520,14 @@ public void onGameStarts(final GamePhaseChangedEvent ev) * @param player A player * @return True if an inventory action should not be done because he is a builder. */ - private boolean isBuilder(final Permissible player) - { + private boolean isBuilder(final Permissible player) { return Config.INVENTORY.ALLOW_FOR_BUILDERS.get() && player.hasPermission("uh.build"); } /** * @return If we are in the right game phase (wait). */ - private boolean isGameStarted() - { + private boolean isGameStarted() { final GamePhase phase = QSG.module(GameModule.class).getPhase(); return phase != GamePhase.WAIT && phase != GamePhase.STARTING; } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java index 3b8a041..7027b51 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/Config.java @@ -31,22 +31,20 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.worldgen.creatures; +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; + import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; import fr.zcraft.quartzlib.components.configuration.ConfigurationList; - import java.io.File; import java.util.Map; -import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.list; +public class Config extends ConfigurationInstance { + public static final ConfigurationList<Map> SPAWN_RULES = list("spawn_rules", Map.class); -public class Config extends ConfigurationInstance -{ - public Config(File file) - { + public Config(File file) { super(file); } - - public static final ConfigurationList<Map> SPAWN_RULES = list("spawn_rules", Map.class); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java index e9f6a90..73e34ed 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/worldgen/creatures/CreaturesModule.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.modules.worldgen.creatures; import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; @@ -42,18 +43,23 @@ import fr.zcraft.quartzlib.exceptions.IncompatibleMinecraftVersionException; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; -import org.bukkit.Material; -import org.bukkit.block.Biome; -import org.bukkit.entity.EntityType; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; +import org.bukkit.Material; +import org.bukkit.block.Biome; +import org.bukkit.entity.EntityType; -@ModuleInfo ( +@ModuleInfo( name = "Creatures Spawn Control", description = "Alters creatures spawn rules for all or some biomes. " + "This include disabling spawn of some creatures completely.\n\n" + @@ -63,39 +69,30 @@ icon = Material.SPAWNER, settings = Config.class ) -public class CreaturesModule extends QSGModule -{ - /** - * {@code true} if successfully hooked into NMS. - */ - private static boolean hooked; - - private static Class<?> WEIGHTED_RANDOM_CHOICE_CLASS; - private static Class<?> CREATURE_TYPE_ENUM; - - private static Field CREATURE_TYPE_ENUM_CLASS_FIELD; - private static Constructor<?> BIOME_META_CONSTRUCTOR; - +public class CreaturesModule extends QSGModule { /** * Map {@link EntityType} -> {@code Class<? extends net.minecraft.server.Entity>} */ private final static Map<EntityType, Class<?>> NMS_ENTITY_CLASSES = new HashMap<>(); - /** * Map {@link EntityType} -> {@code net.minecraft.server.EntityTypes} */ private final static Map<EntityType, Object> NMS_ENTITY_TYPES = new HashMap<>(); - /** * Map {@link Biome} -> {@code net.minecraft.server.BiomeBase} */ private final static Map<Biome, Object> NMS_BIOMES = new HashMap<>(); + /** + * {@code true} if successfully hooked into NMS. + */ + private static boolean hooked; + private static Class<?> WEIGHTED_RANDOM_CHOICE_CLASS; + private static Class<?> CREATURE_TYPE_ENUM; + private static Field CREATURE_TYPE_ENUM_CLASS_FIELD; + private static Constructor<?> BIOME_META_CONSTRUCTOR; - - static - { - try - { + static { + try { final Class<?> ENTITY_TYPES_CLASS = Reflection.getMinecraftClassByName("EntityTypes"); final Class<?> BIOME_BASE_BIOME_META_CLASS = Reflection.getMinecraftClassByName("BiomeBase$BiomeMeta"); @@ -104,17 +101,18 @@ public class CreaturesModule extends QSGModule CREATURE_TYPE_ENUM_CLASS_FIELD = Arrays.stream(CREATURE_TYPE_ENUM.getDeclaredFields()) .filter(field -> field.getType().equals(Class.class)).findFirst() - .orElseThrow(() -> new IncompatibleMinecraftVersionException(new Exception("Cannot find the field containing the super class in EnumCreatureType"))); + .orElseThrow(() -> new IncompatibleMinecraftVersionException( + new Exception("Cannot find the field containing the super class in EnumCreatureType"))); CREATURE_TYPE_ENUM_CLASS_FIELD.setAccessible(true); - try - { - BIOME_META_CONSTRUCTOR = BIOME_BASE_BIOME_META_CLASS.getConstructor(Class.class, int.class, int.class, int.class); + try { + BIOME_META_CONSTRUCTOR = + BIOME_BASE_BIOME_META_CLASS.getConstructor(Class.class, int.class, int.class, int.class); } - catch (final NoSuchMethodException | SecurityException e) - { - BIOME_META_CONSTRUCTOR = BIOME_BASE_BIOME_META_CLASS.getConstructor(ENTITY_TYPES_CLASS, int.class, int.class, int.class); + catch (final NoSuchMethodException | SecurityException e) { + BIOME_META_CONSTRUCTOR = + BIOME_BASE_BIOME_META_CLASS.getConstructor(ENTITY_TYPES_CLASS, int.class, int.class, int.class); } BIOME_META_CONSTRUCTOR.setAccessible(true); @@ -125,54 +123,55 @@ public class CreaturesModule extends QSGModule EntityTypesClassVersion version = null; boolean hadMaps = false; - for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) - { - if (field.getType().equals(ENTITY_TYPES_CLASS)) - { + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) { + if (field.getType().equals(ENTITY_TYPES_CLASS)) { version = EntityTypesClassVersion.STATIC_ATTRIBUTES; break; - } - else if (field.getType().getSimpleName().equals("RegistryMaterials")) - { + } else if (field.getType().getSimpleName().equals("RegistryMaterials")) { version = EntityTypesClassVersion.MINECRAFT_KEYS; break; - } - else if (Map.class.isAssignableFrom(field.getType())) - { + } else if (Map.class.isAssignableFrom(field.getType())) { hadMaps = true; } } - if (version == null && hadMaps) version = EntityTypesClassVersion.MAPS; - if (version == null) throw new IncompatibleMinecraftVersionException(new Exception("EntityTypes class version unsupported")); + if (version == null && hadMaps) { + version = EntityTypesClassVersion.MAPS; + } + if (version == null) { + throw new IncompatibleMinecraftVersionException(new Exception("EntityTypes class version unsupported")); + } - switch (version) - { + switch (version) { // FIXME UNTESTED case MAPS: // We loop over all maps to check the values inside. // We want to find the map String -> Class<? extends net.minecraft.server.Entity> - for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) - { - if (!Map.class.isAssignableFrom(field.getType())) continue; + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) { + if (!Map.class.isAssignableFrom(field.getType())) { + continue; + } field.setAccessible(true); final Map<?, ?> map = (Map) field.get(null); final Map.Entry entry = map.entrySet().stream().findFirst().orElse(null); - if (entry == null) continue; + if (entry == null) { + continue; + } - if (entry.getKey().getClass().equals(String.class) && entry.getValue().getClass().equals(Class.class)) - { + if (entry.getKey().getClass().equals(String.class) && + entry.getValue().getClass().equals(Class.class)) { // We found the one, let's save all of this. // We can't extract EntityTypes for this version because the instances doesn't even exist, // and we don't need them anyway. final Map<String, Class<?>> keyToClass = (Map<String, Class<?>>) map; - for (final EntityType entityType : EntityType.values()) - { + for (final EntityType entityType : EntityType.values()) { final String name = (String) Reflection.getFieldValue(entityType, "name"); - if (name == null) continue; + if (name == null) { + continue; + } NMS_ENTITY_CLASSES.put(entityType, keyToClass.get(name)); } @@ -188,29 +187,29 @@ else if (Map.class.isAssignableFrom(field.getType())) final Class<?> MINECRAFT_KEY_CLASS = Reflection.getMinecraftClassByName("MinecraftKey"); Object registry = null; - for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) - { - if (field.getType().equals(REGISTRY_CLASS)) - { + for (final Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) { + if (field.getType().equals(REGISTRY_CLASS)) { registry = field.get(null); break; } } // Should be impossible - if (registry == null) - { - throw new IncompatibleMinecraftVersionException(new NoSuchFieldException("Cannot retrieve the EntityTypes registry.")); + if (registry == null) { + throw new IncompatibleMinecraftVersionException( + new NoSuchFieldException("Cannot retrieve the EntityTypes registry.")); } - for (final EntityType entityType : EntityType.values()) - { + for (final EntityType entityType : EntityType.values()) { // We can't extract EntityTypes for this version because the instances doesn't even exist, // and we don't need them anyway. final String name = (String) Reflection.getFieldValue(entityType, "name"); - if (name == null) continue; + if (name == null) { + continue; + } - NMS_ENTITY_CLASSES.put(entityType, (Class<?>) REGISTRY_METHOD_GET.invoke(registry, Reflection.instantiate(MINECRAFT_KEY_CLASS, name))); + NMS_ENTITY_CLASSES.put(entityType, (Class<?>) REGISTRY_METHOD_GET + .invoke(registry, Reflection.instantiate(MINECRAFT_KEY_CLASS, name))); } break; @@ -220,12 +219,11 @@ else if (Map.class.isAssignableFrom(field.getType())) // Intermediate map key -> bukkit entity type final Map<String, EntityType> BY_KEY = Arrays.stream(EntityType.values()) .map(entityType -> { - try - { - return new AbstractMap.SimpleEntry<>((String) Reflection.getFieldValue(entityType, "name"), entityType); + try { + return new AbstractMap.SimpleEntry<>( + (String) Reflection.getFieldValue(entityType, "name"), entityType); } - catch (NoSuchFieldException | IllegalAccessException e) - { + catch (NoSuchFieldException | IllegalAccessException e) { return null; } }) @@ -233,16 +231,20 @@ else if (Map.class.isAssignableFrom(field.getType())) .filter(entry -> entry.getKey() != null) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - for (Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) - { - if (!field.getType().equals(ENTITY_TYPES_CLASS)) continue; + for (Field field : ENTITY_TYPES_CLASS.getDeclaredFields()) { + if (!field.getType().equals(ENTITY_TYPES_CLASS)) { + continue; + } final Object type = field.get(null); final String key = (String) Reflection.call(type, "d"); // Returns the key (String) - final Class<?> clazz = (Class<?>) Reflection.call(type, "c"); // Returns the class (Class<? extends Entity>) + final Class<?> clazz = + (Class<?>) Reflection.call(type, "c"); // Returns the class (Class<? extends Entity>) final EntityType bukkitType = BY_KEY.get(key); - if (bukkitType == null) continue; + if (bukkitType == null) { + continue; + } NMS_ENTITY_CLASSES.put(bukkitType, clazz); NMS_ENTITY_TYPES.put(bukkitType, type); @@ -254,29 +256,23 @@ else if (Map.class.isAssignableFrom(field.getType())) // We also build a map from Bukkit's to NMS' biomes. final Class<?> CRAFT_BLOCK_CLASS = Reflection.getBukkitClassByName("block.CraftBlock"); - for (final Biome biome : Biome.values()) - { + for (final Biome biome : Biome.values()) { NMS_BIOMES.put(biome, Reflection.call(CRAFT_BLOCK_CLASS, "biomeToBiomeBase", biome)); } hooked = true; } - catch (final Exception e) - { + catch (final Exception e) { PluginLogger.error("Unable to hook into NMS to patch creatures spawn.", e); hooked = false; } } @Override - protected void onEnable() - { - for (final Map rule : Config.SPAWN_RULES) - { - try - { - if (!rule.containsKey("entity")) - { + protected void onEnable() { + for (final Map rule : Config.SPAWN_RULES) { + try { + if (!rule.containsKey("entity")) { log().warning("Skipping spawn rule without entity."); continue; } @@ -284,47 +280,38 @@ protected void onEnable() final EntityType entity = ConfigurationValueHandlers.handleValue(rule.get("entity"), EntityType.class); final int weight = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("weight", -1)); - final int minPackSize = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("minimal_pack_size", -1)); - final int maxPackSize = ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("maximal_pack_size", -1)); + final int minPackSize = + ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("minimal_pack_size", -1)); + final int maxPackSize = + ConfigurationValueHandlers.handleIntValue(rule.getOrDefault("maximal_pack_size", -1)); final Biome[] biomes; final boolean onlyIfPresent; - if (!rule.containsKey("biomes")) - { + if (!rule.containsKey("biomes")) { biomes = null; onlyIfPresent = true; - } - else - { + } else { final Object rawBiomes = rule.get("biomes"); - if (rawBiomes instanceof String && ((String) rawBiomes).trim().equalsIgnoreCase("ALL")) - { + if (rawBiomes instanceof String && ((String) rawBiomes).trim().equalsIgnoreCase("ALL")) { biomes = null; onlyIfPresent = false; - } - else if (rawBiomes instanceof List) - { + } else if (rawBiomes instanceof List) { final List<Biome> biomesList = new ArrayList<>(((List) rawBiomes).size()); - for (final Object biome : ((List) rawBiomes)) - { - try - { + for (final Object biome : ((List) rawBiomes)) { + try { biomesList.add(ConfigurationValueHandlers.handleValue(biome, Biome.class)); } - catch (ConfigurationParseException e) - { + catch (ConfigurationParseException e) { log().warning("Ignoring unknown biome {0} in spawn rules.", e.getValue()); } } biomes = biomesList.toArray(new Biome[0]); onlyIfPresent = false; - } - else - { + } else { log().warning("Invalid `biomes` key in spawn rule (neither a string nor a list); ignoring."); biomes = null; @@ -334,9 +321,9 @@ else if (rawBiomes instanceof List) patchAnimalsSpawn(entity, weight, minPackSize, maxPackSize, onlyIfPresent, biomes); } - catch (ConfigurationParseException e) - { - log().warning("Invalid spawn rule, skipping. {0} (erroneous value: {1}).", e.getMessage(), e.getValue()); + catch (ConfigurationParseException e) { + log().warning("Invalid spawn rule, skipping. {0} (erroneous value: {1}).", e.getMessage(), + e.getValue()); } } } @@ -367,104 +354,116 @@ to get the class and compare it (maybe add this into a cache class -> type). /** * Patches the Minecraft Server to update spawning rules for the given entity, in all biomes where the given entity * already spawn. - * + * <p> * If integer values (weight, min & max) are negative, their values will be left untouched (excepted if a new rule * is created from scratch if {@code onlyIfPresent = false}, then 1 will be used for all of them). * - * @param entity The entity to alter the spawning rules of. - * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability - * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the * minimal size of these spawn groups. * During natural generation, entities are spawned alone, and these parameters are ignored. * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). */ - public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax) - { + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, + final int spawnPackMax) { patchAnimalsSpawn(entity, weight, spawnPackMin, spawnPackMax, true, (Biome[]) null); } /** * Patches the Minecraft Server to update spawning rules for the given entity, in all biomes. * - * @param entity The entity to alter the spawning rules of. - * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability - * of this entity to be selected for spawn is. This is also true while generating the chunks. - * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the - * minimal size of these spawn groups. - * During natural generation, entities are spawned alone, and these parameters are ignored. - * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the + * minimal size of these spawn groups. + * During natural generation, entities are spawned alone, and these parameters are ignored. + * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). * @param onlyIfPresent If true, the entity spawning rule will only be altered if the creature spawns in the biome. * Else, if the creature doesn't already spawn in the given biome, it will be added to the * biome's entities. This is especially useful for all-biomes alterations. */ - public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax, final boolean onlyIfPresent) - { + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, + final int spawnPackMax, final boolean onlyIfPresent) { patchAnimalsSpawn(entity, weight, spawnPackMin, spawnPackMax, onlyIfPresent, (Biome[]) null); } /** * Patches the Minecraft Server to update spawning rules for the given entity, in the given biome(s). - * + * <p> * If integer values (weight, min & max) are negative, their values will be left untouched (excepted if a new rule * is created from scratch if {@code onlyIfPresent = false}, then 1 will be used for all of them). * - * @param entity The entity to alter the spawning rules of. - * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability - * of this entity to be selected for spawn is. This is also true while generating the chunks. - * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the - * minimal size of these spawn groups. - * During natural generation, entities are spawned alone, and these parameters are ignored. - * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). + * @param entity The entity to alter the spawning rules of. + * @param weight The spawn weight. At each spawn tentative, the higher this number is, the higher the probability + * of this entity to be selected for spawn is. This is also true while generating the chunks. + * @param spawnPackMin While generating the chunks, the server spawns entities in them in groups. This is the + * minimal size of these spawn groups. + * During natural generation, entities are spawned alone, and these parameters are ignored. + * @param spawnPackMax This is the maximal size of a group while generating the chunks (see spawnPackMin). * @param onlyIfPresent If true, the entity spawning rule will only be altered if the creature spawns in the biome. * Else, if the creature doesn't already spawn in the given biome, it will be added to the * biome's entities. This is especially useful for all-biomes alterations. - * @param biomes The biomes to alter. Spawning rules are specific to biomes and only these biomes will be patched. - * If {@code null} or empty, all biomes will be patched. + * @param biomes The biomes to alter. Spawning rules are specific to biomes and only these biomes will be patched. + * If {@code null} or empty, all biomes will be patched. */ - public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, final int spawnPackMax, final boolean onlyIfPresent, final Biome... biomes) - { - if (!hooked) return; // Incompatible Minecraft version + public void patchAnimalsSpawn(final EntityType entity, final int weight, final int spawnPackMin, + final int spawnPackMax, final boolean onlyIfPresent, final Biome... biomes) { + if (!hooked) { + return; // Incompatible Minecraft version + } final Class<?> nmsEntityClass = NMS_ENTITY_CLASSES.get(entity); final Object nmsEntityType = NMS_ENTITY_TYPES.get(entity); - if (nmsEntityClass == null) return; // Unsupported entity + if (nmsEntityClass == null) { + return; // Unsupported entity + } final Enum creatureType = getCreatureType(nmsEntityClass); - if (creatureType == null) return; // Non-naturally-spawnable entity + if (creatureType == null) { + return; // Non-naturally-spawnable entity + } final Biome[] patchedBiomes = biomes != null && biomes.length > 0 ? biomes : Biome.values(); - for (final Biome biome : patchedBiomes) - { + for (final Biome biome : patchedBiomes) { final Object base = NMS_BIOMES.get(biome); - if (base == null) continue; + if (base == null) { + continue; + } - try - { + try { final List<Object> metas = (List<Object>) Reflection.call(base, "getMobs", creatureType); boolean found = false; - for (final Object meta : metas) - { + for (final Object meta : metas) { final Object entityClassOrType = Reflection.getFieldValue(meta, "b"); - if (!Objects.equals(entityClassOrType, nmsEntityClass) && !Objects.equals(entityClassOrType, nmsEntityType)) continue; // Not the meta we're looking for + if (!Objects.equals(entityClassOrType, nmsEntityClass) && + !Objects.equals(entityClassOrType, nmsEntityType)) { + continue; // Not the meta we're looking for + } - if (weight >= 0) Reflection.setFieldValue(WEIGHTED_RANDOM_CHOICE_CLASS, meta, "a", weight); - if (spawnPackMin >= 0) Reflection.setFieldValue(meta, "c", spawnPackMin); - if (spawnPackMax >= 0) Reflection.setFieldValue(meta, "d", spawnPackMax); + if (weight >= 0) { + Reflection.setFieldValue(WEIGHTED_RANDOM_CHOICE_CLASS, meta, "a", weight); + } + if (spawnPackMin >= 0) { + Reflection.setFieldValue(meta, "c", spawnPackMin); + } + if (spawnPackMax >= 0) { + Reflection.setFieldValue(meta, "d", spawnPackMax); + } found = true; } // If the entity meta was not present and we want it to be added in this case - if (!found && !onlyIfPresent) - { + if (!found && !onlyIfPresent) { Object meta; - try - { + try { meta = BIOME_META_CONSTRUCTOR.newInstance( nmsEntityClass, weight >= 0 ? weight : 1, @@ -472,21 +471,21 @@ public void patchAnimalsSpawn(final EntityType entity, final int weight, final i spawnPackMax >= 0 ? spawnPackMax : 1 ); } - catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e) - { - try - { - - if (nmsEntityType == null) - { - throw new IncompatibleMinecraftVersionException(new Exception("Unknown entity type for " + entity)); + catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e) { + try { + + if (nmsEntityType == null) { + throw new IncompatibleMinecraftVersionException( + new Exception("Unknown entity type for " + entity)); } - meta = BIOME_META_CONSTRUCTOR.newInstance(nmsEntityType, weight, spawnPackMin, spawnPackMax); + meta = BIOME_META_CONSTRUCTOR + .newInstance(nmsEntityType, weight, spawnPackMin, spawnPackMax); } - catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e1) - { - log().warning("Unable to construct a new BiomeBase.BiomeMeta (tested two constructors). Nag UHCReloaded authors about this.", e1); + catch (final IllegalArgumentException | InstantiationException | InvocationTargetException | IllegalAccessException e1) { + log().warning( + "Unable to construct a new BiomeBase.BiomeMeta (tested two constructors). Nag UHCReloaded authors about this.", + e1); log().warning("Previous exception was:", e); continue; } @@ -495,27 +494,24 @@ public void patchAnimalsSpawn(final EntityType entity, final int weight, final i metas.add(meta); } } - catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) - { + catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) { log().error("Unable to patch entities spawn rules for entity {0} and biome {1}", e, entity, biome); } } } - private Enum getCreatureType(final Class<?> nmsEntityClass) - { - try - { - for (final Object creatureType : CREATURE_TYPE_ENUM.getEnumConstants()) - { + private Enum getCreatureType(final Class<?> nmsEntityClass) { + try { + for (final Object creatureType : CREATURE_TYPE_ENUM.getEnumConstants()) { final Class<?> clazz = (Class<?>) CREATURE_TYPE_ENUM_CLASS_FIELD.get(creatureType); - if (clazz.isAssignableFrom(nmsEntityClass)) return (Enum) creatureType; + if (clazz.isAssignableFrom(nmsEntityClass)) { + return (Enum) creatureType; + } } return null; } - catch (IllegalAccessException e) - { + catch (IllegalAccessException e) { return null; } } @@ -525,8 +521,7 @@ private Enum getCreatureType(final Class<?> nmsEntityClass) * Represents the version of the class storing the entity types, used to access * the NMS' entity base class from a Bukkit's EntityType. */ - private enum EntityTypesClassVersion - { + private enum EntityTypesClassVersion { /** * Entity types stored in maps in the `EntityTypes` class. * Covers 1.8 -> 1.10. diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java index 2d18c72..434df01 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/shortcuts/QSG.java @@ -31,6 +31,7 @@ * pris connaissance de la licence CeCILL, et que vous en avez accepté les * termes. */ + package eu.carrade.amaury.quartzsurvivalgames.shortcuts; import com.google.common.reflect.ClassPath; @@ -41,28 +42,25 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.game.GameModule; import fr.zcraft.quartzlib.tools.PluginLogger; import fr.zcraft.quartzlib.tools.reflection.Reflection; -import org.apache.commons.lang.ArrayUtils; - import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.function.Consumer; +import org.apache.commons.lang.ArrayUtils; /** * Useful shortcuts. */ -public final class QSG -{ +public final class QSG { private static final Map<Class<?>, Class<? extends QSGModule>> classesModules = new HashMap<>(); private static final Map<String, Class<? extends QSGModule>> packagesModules = new HashMap<>(); /** * Returns the plugin's instance. */ - public static QuartzSurvivalGames get() - { + public static QuartzSurvivalGames get() { return QuartzSurvivalGames.get(); } @@ -71,43 +69,44 @@ public static QuartzSurvivalGames get() * loaded. * * @param moduleClass The module's class. - * @param <M> The module's type. - * + * @param <M> The module's type. * @return The module's instance. */ - public static <M extends QSGModule> M module(final Class<M> moduleClass) - { + public static <M extends QSGModule> M module(final Class<M> moduleClass) { return ModulesManager.getModule(moduleClass); } /** * Returns the module for the caller class' module. - * + * <p> * This works by looking up for the module class in the caller class' * package or “parent” packages. Throws an exception if no module class can * be found. * * @return The module's instance. * @throws IllegalArgumentException if no module can be found for the caller - * class. + * class. */ - public static QSGModule module() - { + public static QSGModule module() { final Class<?> caller = Reflection.getCallerClass(); - if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in module()"); + if (caller == null) { + throw new IllegalArgumentException("Cannot extract caller class in module()"); + } final Class<? extends QSGModule> moduleClass = getModuleFromClass(caller); - if (moduleClass != null) return module(moduleClass); + if (moduleClass != null) { + return module(moduleClass); + } - throw new IllegalArgumentException("The class " + caller.getCanonicalName() + " is not inside a module's package."); + throw new IllegalArgumentException( + "The class " + caller.getCanonicalName() + " is not inside a module's package."); } /** * @return The game module, because it is heavily used through the codebase. */ - public static GameModule game() - { + public static GameModule game() { return module(GameModule.class); } @@ -117,12 +116,10 @@ public static GameModule game() * non-null and available. * * @param moduleClass The module's class. - * @param <M> The module's type. - * + * @param <M> The module's type. * @return {@code true} if the given module is loaded. */ - public static <M extends QSGModule> boolean loaded(Class<M> moduleClass) - { + public static <M extends QSGModule> boolean loaded(Class<M> moduleClass) { return get().getModulesManager().isLoaded(moduleClass); } @@ -131,13 +128,14 @@ public static <M extends QSGModule> boolean loaded(Class<M> moduleClass) * instance as argument. * * @param moduleClass The module's class. - * @param consumer The module's instance consumer. - * @param <M> The module's type. + * @param consumer The module's instance consumer. + * @param <M> The module's type. */ - public static <M extends QSGModule> void ifLoaded(final Class<M> moduleClass, Consumer<M> consumer) - { + public static <M extends QSGModule> void ifLoaded(final Class<M> moduleClass, Consumer<M> consumer) { final M module = module(moduleClass); - if (module != null) consumer.accept(module); + if (module != null) { + consumer.accept(module); + } } /** @@ -147,14 +145,11 @@ public static <M extends QSGModule> void ifLoaded(final Class<M> moduleClass, Co * @param moduleClass The module's class. * @return The module's logger. */ - public static ModuleLogger log(final Class<? extends QSGModule> moduleClass) - { - try - { + public static ModuleLogger log(final Class<? extends QSGModule> moduleClass) { + try { return module(moduleClass).log(); } - catch (final NullPointerException e) - { + catch (final NullPointerException e) { // Ensures no NPE so IDEs are happy. return new ModuleLogger(UnknownModule.class); } @@ -162,66 +157,69 @@ public static ModuleLogger log(final Class<? extends QSGModule> moduleClass) /** * Returns the logger for the caller class' module. - * + * <p> * This works by looking up for the module class in the caller class' * package or “parent” packages. Throws an exception if no module class can * be found. * * @return The module's logger. * @throws IllegalArgumentException if no module can be found for the caller - * class. + * class. */ - public static ModuleLogger log() - { + public static ModuleLogger log() { final Class<?> caller = Reflection.getCallerClass(); - if (caller == null) throw new IllegalArgumentException("Cannot extract caller class in log()"); + if (caller == null) { + throw new IllegalArgumentException("Cannot extract caller class in log()"); + } final Class<? extends QSGModule> moduleClass = getModuleFromClass(caller); - if (moduleClass != null) return log(moduleClass); + if (moduleClass != null) { + return log(moduleClass); + } - throw new IllegalArgumentException("The class " + caller.getCanonicalName() + " is not inside a module's package."); + throw new IllegalArgumentException( + "The class " + caller.getCanonicalName() + " is not inside a module's package."); } /** * Tries to retrieve the module of a given class. - * + * <p> * It will lookup for a class extending {@link QSGModule} in the class's * package, then in the “parent” package, etc., until the “root” package is * reached. {@code null} will be returned if no package can be found. - * + * <p> * The result of this method is cached at runtime. * * @param clazz The class to search the module of. * @return The module class, or {@code null} if not found. */ - private static Class<? extends QSGModule> getModuleFromClass(final Class<?> clazz) - { - if (classesModules.containsKey(clazz)) return classesModules.get(clazz); + private static Class<? extends QSGModule> getModuleFromClass(final Class<?> clazz) { + if (classesModules.containsKey(clazz)) { + return classesModules.get(clazz); + } - try - { + try { final ClassPath classPath = ClassPath.from(clazz.getClassLoader()); final Set<String> analyzedPackages = new HashSet<>(); String packaj = clazz.getPackage().getName(); - while (packaj != null) - { + while (packaj != null) { // Cached? - if (packagesModules.containsKey(packaj)) return packagesModules.get(packaj); + if (packagesModules.containsKey(packaj)) { + return packagesModules.get(packaj); + } analyzedPackages.add(packaj); // We try to find a class in this package extending UHModule - for (final ClassPath.ClassInfo packajClazzInfo : classPath.getTopLevelClasses(packaj)) - { + for (final ClassPath.ClassInfo packajClazzInfo : classPath.getTopLevelClasses(packaj)) { final Class<?> packajClazz = packajClazzInfo.load(); - if (QSGModule.class.isAssignableFrom(packajClazz)) - { + if (QSGModule.class.isAssignableFrom(packajClazz)) { // We found the One™. - @SuppressWarnings("unchecked") - final Class<? extends QSGModule> moduleClazz = (Class<? extends QSGModule>) packajClazz; + @SuppressWarnings("unchecked") final Class<? extends QSGModule> moduleClazz = + (Class<? extends QSGModule>) packajClazz; // We cache as hard as we can as these operations can be heavy. analyzedPackages.forEach(analyzed -> packagesModules.put(analyzed, moduleClazz)); @@ -232,14 +230,11 @@ private static Class<? extends QSGModule> getModuleFromClass(final Class<?> claz } // If we fail, we try with the “parent” package. - if (packaj.contains(".")) - { + if (packaj.contains(".")) { final String[] packajParts = packaj.split("\\."); ArrayUtils.remove(packajParts, packajParts.length - 1); packaj = String.join(".", (String[]) ArrayUtils.remove(packajParts, packajParts.length - 1)); - } - else - { + } else { packaj = null; } } @@ -250,13 +245,13 @@ private static Class<? extends QSGModule> getModuleFromClass(final Class<?> claz return null; } - catch (final Throwable e) - { + catch (final Throwable e) { PluginLogger.error("Unable to find module for class {0}", e, clazz.getCanonicalName()); classesModules.put(clazz, null); return null; } } - private static class UnknownModule extends QSGModule {} + private static class UnknownModule extends QSGModule { + } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8795a24..732301b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,9 +5,7 @@ load: STARTUP version: 2.0-beta author: "Amaury Carrade" authors: ["azenet", "João Roda"] - -awareness: - - "!@UTF8" +api-version: "1.13" softdepend: - WorldBorder From 46567b5a06e3c976a8f8a0136a17b31c2953d895 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 15 Apr 2021 14:47:55 +0200 Subject: [PATCH 77/91] Consistant POM Removed BrettFlan WorldBorder support - The plugin is abandoned. - There is a maintained fork but no Maven repo to depend on it. - This commit could be reverted if this change. --- pom.xml | 5 - .../modules/core/border/BorderModule.java | 8 - .../core/border/WorldBorderDependency.java | 65 ----- .../core/border/commands/BorderCommand.java | 5 +- .../worldborders/BrettflanWorldBorder.java | 226 ------------------ .../core/border/worldborders/WorldBorder.java | 26 +- 6 files changed, 6 insertions(+), 329 deletions(-) delete mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java delete mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java diff --git a/pom.xml b/pom.xml index fe9671d..f314713 100644 --- a/pom.xml +++ b/pom.xml @@ -183,11 +183,6 @@ <artifactId>Hawk</artifactId> <version>1.0-SNAPSHOT</version> </dependency> - <dependency> - <groupId>com.wimbli.WorldBorder</groupId> - <artifactId>WorldBorder</artifactId> - <version>1.8.0</version> - </dependency> <dependency> <groupId>com.pgcraft</groupId> <artifactId>SpectatorPlus</artifactId> diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java index ed27e28..7e43f6d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/BorderModule.java @@ -48,7 +48,6 @@ import eu.carrade.amaury.quartzsurvivalgames.utils.QSGUtils; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; -import fr.zcraft.quartzlib.core.QuartzLib; import fr.zcraft.quartzlib.tools.runners.RunTask; import fr.zcraft.quartzlib.tools.text.Titles; import java.util.ArrayList; @@ -81,12 +80,9 @@ public class BorderModule extends QSGModule { private final List<String> sidebar = new ArrayList<>(); private MapShape mapShape = null; private WorldBorder border = null; - private WorldBorderDependency worldBorderDependency = null; @Override public void onEnable() { - worldBorderDependency = QuartzLib.loadComponent(WorldBorderDependency.class); - mapShape = Config.SHAPE.get(); final World world = QuartzSurvivalGames.get().getWorld(World.Environment.NORMAL); @@ -192,10 +188,6 @@ public WorldBorder getBorderProxy() { return border; } - public WorldBorderDependency getWorldBorderDependency() { - return worldBorderDependency; - } - /** * Checks if a given location is inside the border with the given diameter. * The check is performed for a circular or squared border, following the configuration. diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java deleted file mode 100644 index 6c6d4d6..0000000 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/WorldBorderDependency.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.quartzsurvivalgames.modules.core.border; - -import com.wimbli.WorldBorder.WorldBorder; -import fr.zcraft.quartzlib.external.ExternalPluginComponent; -import fr.zcraft.quartzlib.tools.PluginLogger; - - -public class WorldBorderDependency extends ExternalPluginComponent<WorldBorder> { - public WorldBorderDependency() { - super("WorldBorder"); - } - - @Override - protected void onLoad() { - try { - Class.forName("com.wimbli.WorldBorder.BorderData"); - Class.forName("com.wimbli.WorldBorder.Config"); - } - catch (ClassNotFoundException e) { - PluginLogger.warning("WorldBorder is available, but the version you are using is too old."); - PluginLogger.warning("This plugin is tested and works with WorldBorder 1.8.0 or later."); - - setEnabled(false); - return; - } - - PluginLogger.info("Successfully hooked into WorldBorder."); - } - - public WorldBorder getWorldBorder() { - return get(); - } -} diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java index cb1bf56..db44e37 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/commands/BorderCommand.java @@ -73,10 +73,7 @@ protected void run() throws CommandException { I.t("{ci}Use {cc}/uh border set {0} force{ci} to resize the border regardless to this point.", args[0])); - if (!QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - sender.sendMessage( - I.t("{ce}WARNING: {ci}because WorldBorder is not installed, players out of the border will not be teleported!")); - } + sender.sendMessage(I.t("{ce}WARNING: {ci}players out of the border will not be teleported!")); border.sendCheckMessage(sender, newDiameter); } else { diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java deleted file mode 100644 index 684b336..0000000 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/BrettflanWorldBorder.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright or © or Copr. Amaury Carrade (2014 - 2016) - * - * http://amaury.carrade.eu - * - * This software is governed by the CeCILL-B license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL-B - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-B license and that you accept its terms. - */ - -package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; - -import com.wimbli.WorldBorder.BorderData; -import com.wimbli.WorldBorder.Config; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; -import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; -import fr.zcraft.quartzlib.tools.runners.RunTask; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.scheduler.BukkitTask; - - -/** - * Represents a Brettflan world border, from the WorldBorder Bukkit plugin. - * - * <p>These methods are not supported as the border cannot be bypassed and does not have - * warnings:</p> - * <ul> - * <li>{@link #setDamageBuffer(double)};</li> - * <li>{@link #setDamageAmount(double)};</li> - * <li>{@link #setWarningDistance(int)};</li> - * <li>{@link #setWarningTime(int)}.</li> - * </ul> - */ -public class BrettflanWorldBorder extends WorldBorder { - private final World world; - private BorderData border; - - private Double diameter = 0d; - - private BukkitTask slowReductionTask = null; - - - public BrettflanWorldBorder(final World world) { - this.world = world; - - if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - border = QSG.module(BorderModule.class).getWorldBorderDependency().getWorldBorder() - .getWorldBorder(world.getName()); - - if (border == null) { - border = new BorderData(world.getSpawnLocation().getX(), world.getSpawnLocation().getZ(), 3000000); - Config.setBorder(world.getName(), border); - } - } - } - - @Override - public void init() { - Config.setPortalRedirection(true); - } - - @Override - public World getWorld() { - return world; - } - - @Override - public double getDiameter() { - // If squared, the size is not changed - if (!border.getShape()) { - return diameter; - } - - - Double realDiameter = (double) (border.getRadiusX() * 2); - - // Returns the stored diameter, except if it was changed - // manually with /wb (see #setDiameterInternal(Double) for - // details). - if (realDiameter - diameter >= 8) { - diameter = realDiameter; - } - - return diameter; - } - - @Override - public void setDiameter(final double diameter) { - setDiameterInternal(diameter); - - if (slowReductionTask != null) { - slowReductionTask.cancel(); - slowReductionTask = null; - } - } - - @Override - public void setDiameter(final double diameter, final long time) { - // The behavior of the vanilla reduction is emulated. - final double currentDiameter = getDiameter(); - - final long ticksPerBlockRemoved = (int) Math.rint(time / (currentDiameter - diameter)) * 20L; - final long movement = (diameter >= currentDiameter) ? 1 : -1; - - if (slowReductionTask != null) { - slowReductionTask.cancel(); - slowReductionTask = null; - } - - slowReductionTask = RunTask.timer(() -> { - double newDiameter = getDiameter() + movement; - - // If the final size is achieved, we set the exact requested size and we stop here. - // Calling setDiameter cancels this task. - if ((movement < 0 && newDiameter <= diameter) || (movement > 0 && newDiameter >= diameter)) { - setDiameter(diameter); - } else { - setDiameterInternal(newDiameter); - } - }, ticksPerBlockRemoved, ticksPerBlockRemoved); - } - - private void setDiameterInternal(final double diameter) { - this.diameter = diameter; - - // If the wall is circular, the diameter used to check must be bigger to avoid false positives - // if a player is in an angle of the circular wall. The original diameter set is stored and - // returned by the getDiameter value (except if the diameter was changed using /wb), for nicer - // display (avoids rounding errors). - // “+3” ? Experimental. - int offset = (getShape() == MapShape.CIRCULAR) ? 3 : 0; - - border.setRadius((int) Math.floor((diameter + offset) / 2)); - } - - @Override - public Location getCenter() { - return new Location(world, border.getX(), 0, border.getZ()); - } - - @Override - public void setCenter(final Location center) { - setCenter(center.getX(), center.getZ()); - } - - @Override - public void setCenter(final double x, final double z) { - border.setX(x); - border.setZ(z); - } - - @Override - public double getDamageBuffer() { - return 0; - } - - @Override - public void setDamageBuffer(final double distance) { - } - - @Override - public double getDamageAmount() { - return 0; - } - - @Override - public void setDamageAmount(final double damageAmount) { - } - - @Override - public int getWarningTime() { - return 0; - } - - @Override - public void setWarningTime(final int seconds) { - } - - @Override - public int getWarningDistance() { - return 0; - } - - @Override - public void setWarningDistance(final int blocks) { - } - - @Override - public MapShape getShape() { - return border.getShape() ? MapShape.CIRCULAR : MapShape.SQUARED; - } - - @Override - public void setShape(final MapShape shape) { - border.setShape(shape == MapShape.CIRCULAR); - } - - @Override - public boolean supportsProgressiveResize() { - return true; - } -} diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java index 2c702c0..a7e511f 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/border/worldborders/WorldBorder.java @@ -32,10 +32,9 @@ package eu.carrade.amaury.quartzsurvivalgames.modules.core.border.worldborders; -import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.BorderModule; import eu.carrade.amaury.quartzsurvivalgames.modules.core.border.MapShape; import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; -import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import fr.zcraft.quartzlib.tools.PluginLogger; import org.bukkit.Location; import org.bukkit.World; @@ -56,18 +55,10 @@ public static WorldBorder getInstance(final World world, final WorldBorderMotor // For circular shapes, the vanilla motor cannot be used. // Without the WorldBorder plugin, a fake world border is used (i.e., no border control). if (shape == MapShape.CIRCULAR) { - if (QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - return new BrettflanWorldBorder(world); - } else { - return new FakeWorldBorder(world); - } + PluginLogger.error("Circular world borders are no longer supported due to Brettflan world border plugin being abandoned."); + return new FakeWorldBorder(world); } else { - if (motor == WorldBorderMotor.VANILLA || - !QSG.module(BorderModule.class).getWorldBorderDependency().isEnabled()) { - return new VanillaWorldBorder(world); - } else { - return new BrettflanWorldBorder(world); - } + return new VanillaWorldBorder(world); } } @@ -191,13 +182,6 @@ public enum WorldBorderMotor { /** * Uses the vanilla world border (for squared borders only). */ - VANILLA, - - /** - * Uses the Brettflan's WorldBorder plugin (for both squared and circular). - * <p> - * If set for squared world borders and WorldBorder is not installed, fallbacks to vanilla. - */ - BRETTFLAN + VANILLA } } From 53b0673c4f4ab461f168d6c8ce14e6cdada03af0 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 15 Apr 2021 15:28:20 +0200 Subject: [PATCH 78/91] Fixed recipes and updated to QuartzLib 0.0.4 --- pom.xml | 6 +- .../gameplay/OnerousGlisteringMelon.java | 6 +- .../gameplay/compass/CompassRecipes.java | 1 + .../goldenHeads/GoldenHeadsModule.java | 55 ++++++++----------- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index f314713..8023e3d 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4</version> + <version>3.2.4</version> <configuration> <minimizeJar>true</minimizeJar> <artifactSet> @@ -146,7 +146,7 @@ <repository> <id>pgmann-repo</id> <name>PGMann repository (SpectatorPlus)</name> - <url>https://mvn.pgmann.cf/</url> + <url>https://repo.repsy.io/mvn/pgmann/public/</url> </repository> <repository> <id>carrade-repo</id> @@ -171,7 +171,7 @@ <dependency> <groupId>fr.zcraft</groupId> <artifactId>quartzlib</artifactId> - <version>0.0.2</version> + <version>0.0.4</version> </dependency> <dependency> <groupId>fr.zcraft</groupId> diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java index d491df6..ee38f49 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java @@ -56,19 +56,21 @@ ) public class OnerousGlisteringMelon extends QSGModule { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( + "glistering_melon_vanilla", new ItemStack(Material.GLISTERING_MELON_SLICE), "AAA", "ABA", "AAA", - Material.GOLD_NUGGET, Material.MELON // FIXME 1.13 + Material.GOLD_NUGGET, Material.MELON ); private final Recipe ONEROUS_RECIPE = CraftingRecipes.shaped( + "glistering_melon_with_ingots", new ItemStack(Material.GLISTERING_MELON_SLICE), "AAA", "ABA", "AAA", - Material.GOLD_INGOT, Material.MELON // FIXME 1.13 + Material.GOLD_INGOT, Material.MELON ); @Override diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java index 9462413..a1132d3 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/compass/CompassRecipes.java @@ -55,6 +55,7 @@ public class CompassRecipes extends QuartzComponent implements Listener { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( + "compass_vanilla", new ItemStack(Material.COMPASS), " A ", "ABA", diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java index a579009..2ba1a95 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/goldenHeads/GoldenHeadsModule.java @@ -43,6 +43,7 @@ import fr.zcraft.quartzlib.components.attributes.Attributes; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.PluginLogger; +import fr.zcraft.quartzlib.tools.items.CraftingRecipes; import fr.zcraft.quartzlib.tools.items.ItemStackBuilder; import fr.zcraft.quartzlib.tools.items.ItemUtils; import fr.zcraft.quartzlib.tools.reflection.NMSException; @@ -58,7 +59,6 @@ import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -91,27 +91,28 @@ protected void onEnable() { } if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get()) { - Bukkit.addRecipe(getGoldenHeadRecipe(true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + Bukkit.addRecipe(getGoldenHeadRecipe("golden_player_head", true, false, Config.PLAYER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); } if (Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { - Bukkit.addRecipe(getGoldenHeadRecipe(true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + Bukkit.addRecipe(getGoldenHeadRecipe("enchanted_golden_player_head", true, true, Config.PLAYER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); } if (Config.WITHER_GOLDEN_HEAD.ENABLE.get()) { - Bukkit.addRecipe(getGoldenHeadRecipe(false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + Bukkit.addRecipe(getGoldenHeadRecipe("golden_wither_head", false, false, Config.WITHER_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.AQUA + I.t("Golden head"))); } if (Config.WITHER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { - Bukkit.addRecipe(getGoldenHeadRecipe(false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), + Bukkit.addRecipe(getGoldenHeadRecipe("enchanted_golden_wither_head", false, true, Config.WITHER_ENCHANTED_GOLDEN_HEAD.AMOUNT_CRAFTED.get(), ChatColor.LIGHT_PURPLE + I.t("Golden head"))); } } - private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted, final int amount, + private Recipe getGoldenHeadRecipe(String recipeName, final boolean player, final boolean enchanted, + final int amount, final String resultDisplayName) { final ItemStack goldenApple = new ItemStackBuilder(enchanted ? Material.ENCHANTED_GOLDEN_APPLE : Material.GOLDEN_APPLE) .title(ChatColor.RESET + resultDisplayName) @@ -120,23 +121,21 @@ private Recipe getGoldenHeadRecipe(final boolean player, final boolean enchanted writeHeadType(goldenApple, player ? SkullType.PLAYER : SkullType.WITHER); - final ShapedRecipe goldenAppleFromHeadRecipe = new ShapedRecipe(goldenApple); - - goldenAppleFromHeadRecipe.shape("GGG", "GHG", "GGG"); - goldenAppleFromHeadRecipe.setIngredient('G', enchanted ? Material.GOLD_BLOCK : Material.GOLD_INGOT); - goldenAppleFromHeadRecipe.setIngredient('H', player ? Material.PLAYER_HEAD : Material.WITHER_SKELETON_SKULL); - - return goldenAppleFromHeadRecipe; + return CraftingRecipes.shaped( + recipeName, goldenApple, + "AAA", "ABA", "AAA", + enchanted ? Material.GOLD_BLOCK : Material.GOLD_INGOT, + player ? Material.PLAYER_HEAD : Material.WITHER_SKELETON_SKULL + ); } private Recipe getOldEnchantedGoldenAppleRecipe() { - final ShapedRecipe enchantedGoldenAppleRecipe = - new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); // FIXME 1.13 - enchantedGoldenAppleRecipe.shape("GGG", "GAG", "GGG"); - enchantedGoldenAppleRecipe.setIngredient('G', Material.GOLD_BLOCK); - enchantedGoldenAppleRecipe.setIngredient('A', Material.APPLE); - - return enchantedGoldenAppleRecipe; + return CraftingRecipes.shaped( + "enchanted_golden_apple_old_vanilla", + new ItemStack(Material.ENCHANTED_GOLDEN_APPLE), + "AAA", "ABA", "AAA", + Material.GOLD_BLOCK, Material.APPLE + ); } private void writeHeadType(final ItemStack stack, final SkullType type) { @@ -273,23 +272,17 @@ public void onPreCraft(final PrepareItemCraftEvent ev) { public void onPlayerDeath(final AlivePlayerDeathEvent ev) { if (Config.DROP_HEAD_ON_DEATH.get() && ev.getPlayer().isOnline() && (!Config.DROP_HEAD_ON_DEATH_PVP_ONLY.get() || ev.getPlayer().getPlayer().getKiller() != null)) { - final ItemStackBuilder headBuilder = new ItemStackBuilder(Material.PLAYER_HEAD) - .title(ChatColor.AQUA, I.t("{0}'s head", ev.getPlayer().getName())); + final ItemStackBuilder head = new ItemStackBuilder(Material.PLAYER_HEAD) + .title(ChatColor.AQUA, I.t("{0}'s head", ev.getPlayer().getName())) + .withMeta((SkullMeta meta) -> meta.setOwningPlayer(ev.getPlayer())); if (Config.PLAYER_GOLDEN_HEAD.ENABLE.get() || Config.PLAYER_ENCHANTED_GOLDEN_HEAD.ENABLE.get()) { - headBuilder.longLore(ChatColor.GRAY, ChatColor.ITALIC + + head.longLore(ChatColor.GRAY, ChatColor.ITALIC + I.t("Old legends tell how the heads of the brave fallen warriors can become, through a rich and complex transformation, a precious healing balm..."), 38); } - // TODO update with QLib 0.1's ISB - final ItemStack head = headBuilder.item(); - final SkullMeta meta = (SkullMeta) head.getItemMeta(); - - meta.setOwningPlayer(ev.getPlayer()); - head.setItemMeta(meta); - - ItemUtils.dropNaturally(ev.getPlayer().getPlayer().getLocation(), head); + ItemUtils.dropNaturally(ev.getPlayer().getPlayer().getLocation(), head.item()); } } From 24d9f7ff9f92acc2940981f90499208cd4ae1019 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Thu, 15 Apr 2021 15:45:14 +0200 Subject: [PATCH 79/91] Fixed list header/footer using Spigot APIs (We should deprecate or remove QuartzLib API for that.) --- .../playerListHeaderFooter/PlayerListHeaderFooterModule.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java index 3e93e50..897510b 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/playerListHeaderFooter/PlayerListHeaderFooterModule.java @@ -46,7 +46,6 @@ import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.components.i18n.I; import fr.zcraft.quartzlib.tools.runners.RunTask; -import fr.zcraft.quartzlib.tools.text.ListHeaderFooter; import fr.zcraft.quartzteams.events.PlayerJoinedTeamEvent; import fr.zcraft.quartzteams.events.PlayerLeftTeamEvent; import fr.zcraft.quartzteams.events.TeamRegisteredEvent; @@ -153,7 +152,7 @@ public void update() { receivers = Bukkit.getOnlinePlayers().stream(); } - receivers.forEach(player -> ListHeaderFooter.sendListHeaderFooter(player, header, footer)); + receivers.forEach(player -> player.setPlayerListHeaderFooter(header, footer)); } } From fd712ed02709c04c135c815df75e1e7476893ab1 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 13:42:31 +0200 Subject: [PATCH 80/91] Added support for hidden technical modules --- .../quartzsurvivalgames/core/ModuleCategory.java | 9 +-------- .../amaury/quartzsurvivalgames/core/ModuleInfo.java | 8 +++++++- .../amaury/quartzsurvivalgames/core/ModuleWrapper.java | 10 ++++++++++ .../modules/core/game/GameModule.java | 8 +++++++- .../modules/core/modules/commands/ModulesCommand.java | 3 +++ .../core/modules/gui/modules/ModulesListGUI.java | 1 + 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java index 8e4d63c..89398ce 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleCategory.java @@ -116,14 +116,7 @@ public enum ModuleCategory { OTHER( I.t("Others"), I.t("All uncategorized modules goes there."), - () -> { - // TODO use updated ISB in QuartzLib 0.1 - final ItemStack icon = new ItemStackBuilder(Material.PLAYER_HEAD).item(); - final SkullMeta meta = (SkullMeta) icon.getItemMeta(); - meta.setOwner("MHF_Question"); - icon.setItemMeta(meta); - return icon; - }, + new ItemStackBuilder(Material.PLAYER_HEAD).withMeta((SkullMeta meta) -> meta.setOwner("MHF_Question")), ChatColor.WHITE ); diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java index 1066e53..6359d2d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleInfo.java @@ -122,12 +122,18 @@ */ boolean internal() default false; + /** + * @return {@code true} if this module is a technical core module + * that should not be displayed in the /config gui. + */ + boolean hidden() default false; + /** * @return {@code true} if the module can be unloaded and re-loaded. This reflects the status change * from inside the game, as all modules can always be disabled on the configuration file (or not loaded * at all). * <p> - * If this is {@code true}, when disabled, a module will have its {@link QSGModule#onDisable()} onDisable()} + * If this is {@code true}, when disabled, a module will have its {@link QSGModule#onDisable()} * method called, and after that, its listener will be unregistered and the module instance removed from the system. * <p> * When re-loaded, a whole new instance will be created. diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java index f4fcfbf..1ebbbc8 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleWrapper.java @@ -76,6 +76,7 @@ public class ModuleWrapper { private final String settingsFileName; private final String settingsDefaultFileName; private final boolean internal; + private final boolean hidden; private final boolean canBeUnloaded; private final boolean canBeLoadedLate; private final String[] dependencies; @@ -98,6 +99,7 @@ public ModuleWrapper(final Class<? extends QSGModule> moduleClass, boolean enabl shortDescription = ""; authors = ""; internal = false; + hidden = false; canBeUnloaded = true; canBeLoadedLate = true; when = ModuleLoadTime.POST_WORLD; @@ -112,6 +114,7 @@ public ModuleWrapper(final Class<? extends QSGModule> moduleClass, boolean enabl shortDescription = info.short_description(); authors = info.authors(); internal = info.internal(); + hidden = info.hidden(); canBeUnloaded = info.can_be_unloaded(); canBeLoadedLate = info.can_be_loaded_late(); when = info.when(); @@ -470,6 +473,13 @@ public boolean isInternal() { return internal; } + /** + * @return {@code true} if this module is hidden. + */ + public boolean isHidden() { + return hidden; + } + /** * @return {@code true} if this module can be disabled at runtime. */ diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java index 37b24c4..2c28de9 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/game/GameModule.java @@ -90,6 +90,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.permissions.ServerOperator; import org.bukkit.scheduler.BukkitRunnable; @@ -693,10 +694,15 @@ public void onTeleportationProcessComplete(final AfterTeleportationPhaseEvent ev start(); } + // TODO Use permissions if (Config.BROADCAST_PROGRESS.get()) { /// Displayed in the action bar when the slow teleportation is finished but the game not started. - Bukkit.getOnlinePlayers().forEach(player -> ActionBar.sendPermanentMessage(player, + Bukkit.getOnlinePlayers().stream().filter(p -> !p.isOp()).forEach(player -> ActionBar.sendPermanentMessage(player, I.tl(player, "{lightpurple}Teleportation complete. {gray}The game will start soon..."))); + + /// Displayed in the action bar when the slow teleportation is finished but the game not started, for ops. + Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).forEach(player -> ActionBar.sendPermanentMessage(player, + I.tl(player, "{lightpurple}Teleportation complete. {gray}Use {cc}/uh start{gray} to start the game."))); } } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java index a179f9e..e24cd45 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/commands/ModulesCommand.java @@ -150,6 +150,9 @@ protected void run() throws CommandException { tooltip.then(module.isInternal() ? " - " : "\n\n").color(ChatColor.DARK_GRAY) .then(I.t("Cannot be disabled")).color(ChatColor.DARK_GRAY); } + if (module.isHidden()) { + tooltip.then("\n").then(I.t("Technical module (hidden)")).style(ChatColor.DARK_GRAY); + } send(new RawText().hover(tooltip) .then("• ") diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java index 69d94d0..ad9b9ca 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/modules/gui/modules/ModulesListGUI.java @@ -75,6 +75,7 @@ protected void onUpdate() { setKeepHorizontalScrollingSpace(true); final ModuleWrapper[] modules = QSG.get().getModulesManager().getModules().stream() + .filter(module -> !module.isHidden()) .filter(module -> filterCategory == null || module.getCategory() == filterCategory) .filter(module -> { switch (filterState) { From 1188a54e6e216a4e5516c5dbe97b184980923d5e Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 13:42:56 +0200 Subject: [PATCH 81/91] Added module to tag player drops --- .../modules/utilities/TagPlayerDrops.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/TagPlayerDrops.java diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/TagPlayerDrops.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/TagPlayerDrops.java new file mode 100644 index 0000000..0dd2f43 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/utilities/TagPlayerDrops.java @@ -0,0 +1,68 @@ +/* + * Plugin UHCReloaded + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ + +package eu.carrade.amaury.quartzsurvivalgames.modules.utilities; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.shortcuts.QSG; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.metadata.FixedMetadataValue; + + +@ModuleInfo( + name = "Tag Player Drops", + description = "Adds a metadata to player drops so we can detect them if needed", + when = ModuleLoadTime.POST_WORLD, + category = ModuleCategory.UTILITIES, + internal = true, + hidden = true, + can_be_unloaded = false +) +public class TagPlayerDrops extends QSGModule { + + /** + * Adds a metadata to items thrown by a player. + */ + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerItemDrop(PlayerDropItemEvent event) + { + if (!event.getItemDrop().hasMetadata("playerDrop")) + event.getItemDrop().setMetadata("playerDrop", new FixedMetadataValue(QSG.get(), true)); + } +} From b70e42998d057ce009603a5d68e7a87f6e04ebdc Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 13:43:11 +0200 Subject: [PATCH 82/91] Added module to increase apples spawn rate --- .../modules/gameplay/moarApples/Config.java | 48 ++++++++++++ .../gameplay/moarApples/MoarApplesModule.java | 78 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/Config.java create mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/MoarApplesModule.java diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/Config.java new file mode 100644 index 0000000..14a648a --- /dev/null +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/Config.java @@ -0,0 +1,48 @@ +/* + * Plugin UHCReloaded + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ + +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.moarApples; + +import static fr.zcraft.quartzlib.components.configuration.ConfigurationItem.item; + +import fr.zcraft.quartzlib.components.configuration.ConfigurationInstance; +import fr.zcraft.quartzlib.components.configuration.ConfigurationItem; +import java.io.File; + +public class Config extends ConfigurationInstance { + static public final ConfigurationItem<Double> REPLACEMENT_PERCENTAGE = item("replacement-percentage", 0.12); + public Config(File file) { + super(file); + } +} diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/MoarApplesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/MoarApplesModule.java new file mode 100644 index 0000000..3937e2e --- /dev/null +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/moarApples/MoarApplesModule.java @@ -0,0 +1,78 @@ +/* + * Plugin UHCReloaded + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ + +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay.moarApples; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import java.util.Random; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.inventory.ItemStack; + + +@ModuleInfo( + name = "Moar Apples", + description = "Increases apples rate spawn", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.APPLE, + settings = Config.class +) +public class MoarApplesModule extends QSGModule { + private final Random random = new Random(); + + /** + * We replace a configurable percentage of saplings with apples. + */ + @EventHandler(priority = EventPriority.HIGHEST) + public void onSaplingSpawn(final ItemSpawnEvent ev) { + if (ev.getEntityType() != EntityType.DROPPED_ITEM) + return; + + if (ev.getEntity().hasMetadata("playerDrop")) + return; + + if (ev.getEntity().getItemStack().getType() == Material.OAK_SAPLING || ev.getEntity().getItemStack().getType() == Material.DARK_OAK_SAPLING) { + if (random.nextDouble() < Config.REPLACEMENT_PERCENTAGE.get()) { + ev.getEntity().setItemStack(new ItemStack(Material.APPLE, ev.getEntity().getItemStack().getAmount())); + } + } + } +} From c816132144580a12059c98fdc0ef0b9e0b19ce38 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 14:15:18 +0200 Subject: [PATCH 83/91] Fixed Hawk dependency & tweaked reports configuration --- pom.xml | 12 ++++++++---- .../modules/external/hawk/Config.java | 7 ++++++- .../modules/external/hawk/HawkModule.java | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 8023e3d..d7c1552 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,10 @@ <description>Survival games plugin, able to handle most Minecraft survival games (like UHC) through combined modules</description> <url>https://github.com/zDevelopers/UHPlugin/</url> + <properties> + <shaded.package>eu.carrade.amaury.quartzsurvivalgames.libs</shaded.package> + </properties> + <issueManagement> <system>GitHub</system> <url>https://github.com/zDevelopers/UHPlugin/issues</url> @@ -100,21 +104,21 @@ <includes> <include>fr.zcraft:quartzlib</include> <include>fr.zcraft:quartzteams</include> - <include>me.cassayre.florian:Hawk</include> + <include>me.cassayre.florian:hawk</include> </includes> </artifactSet> <relocations> <relocation> <pattern>fr.zcraft.quartzlib</pattern> - <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzlib</shadedPattern> + <shadedPattern>${shaded.package}.quartzlib</shadedPattern> </relocation> <relocation> <pattern>fr.zcraft.quartzteams</pattern> - <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.quartzteams</shadedPattern> + <shadedPattern>${shaded.package}.quartzteams</shadedPattern> </relocation> <relocation> <pattern>me.cassayre.florian.hawk</pattern> - <shadedPattern>eu.carrade.amaury.quartzsurvivalgames.hawk</shadedPattern> + <shadedPattern>${shaded.package}.hawk</shadedPattern> </relocation> </relocations> </configuration> diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java index 0e85f65..f5f2731 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/Config.java @@ -68,10 +68,15 @@ public Config(File file) { static public List<Statistic> defaultStatsHighlight() { return Arrays.asList( Statistic.DAMAGE_DEALT, + Statistic.DAMAGE_TAKEN, + Statistic.DAMAGE_RESISTED, + Statistic.DAMAGE_ABSORBED, Statistic.CRAFT_ITEM, Statistic.ITEM_ENCHANTED, Statistic.BREWINGSTAND_INTERACTION, - Statistic.SPRINT_ONE_CM + Statistic.SPRINT_ONE_CM, + Statistic.HORSE_ONE_CM, + Statistic.SNEAK_TIME ); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java index 9d5191d..97cb66c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/external/hawk/HawkModule.java @@ -213,7 +213,7 @@ protected void onEnable() { .withTheseInMinedStatisticsWhitelist(Config.PLAYERS.MINED_WHITELIST) .withTheseInPickedUpStatisticsWhitelist(Config.PLAYERS.PICKED_UP_WHITELIST) .withGenerator( - "UHC Reloaded", + "Quartz Survival Games", "https://www.spigotmc.org/resources/ultrahardcore-reloaded.1622/" ) .done(); @@ -230,7 +230,7 @@ protected void onEnable() { updateReportTeams(); - RunTask.nextTick(() -> log().info("The reports tracker started successfully.")); + RunTask.nextTick(() -> log().info("Hawk is now recording the game.")); } public Report getReport() { From 5f9577f7c243653dd7e8d15b4a24696de21b2d92 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 14:15:35 +0200 Subject: [PATCH 84/91] Improved module loggers display --- .../carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java index c38ae84..8beb3fd 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModuleLogger.java @@ -56,7 +56,7 @@ public ModuleLogger(Class<? extends QSGModule> module) { setLevel(Level.ALL); moduleName = ModuleWrapper.computeModuleName(module); - loggerName = "[" + QuartzLib.getPlugin().getName() + "] [" + moduleName + "] "; + loggerName = "[" + moduleName + "] "; } @Override @@ -67,7 +67,7 @@ public void log(LogRecord logRecord) { public void log(Level level, String message, Throwable ex, Object... args) { log(level, message, args); - log(level, "Exception : ", ex); + log(level, "Exception: ", ex); } public void info(String message, Object... args) { From 6e01ea6dd72a1d1346a85e723deba50697091d15 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 16:25:10 +0200 Subject: [PATCH 85/91] Updated default game title --- .../java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java index 3b98067..06df7e8 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/QSGConfig.java @@ -16,7 +16,7 @@ public class QSGConfig extends Configuration { static public final ConfigurationItem<Locale> LANG = item("lang", Locale.class); static public final ConfigurationItem<String> TITLE = - item("title", ChatColor.GREEN + "" + ChatColor.BOLD + "UHC Reloaded"); + item("title", ChatColor.WHITE + "" + ChatColor.BOLD + "Quartz" + ChatColor.RED + "" + ChatColor.BOLD + "SurvivalGames"); static public final ConfigurationItem<Boolean> BUILT_IN_MODULES = item("built-in-modules", true); static public final ConfigurationMap<String, Boolean> MODULES = map("modules", String.class, Boolean.class); From b36cbf8fd359e8b68e995ba368f56f74f57de988 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Wed, 21 Apr 2021 16:28:11 +0200 Subject: [PATCH 86/91] Small fixes --- .../core/ModulesManager.java | 19 +++++++++++-------- .../modules/core/timers/TimersModule.java | 15 ++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java index 422624f..487d460 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java @@ -73,7 +73,7 @@ public class ModulesManager extends QuartzComponent implements Listener { /** * The package were all built-in modules are stored. */ - private final static String MODULES_PACKAGE = "eu.carrade.amaury.UHCReloaded.modules"; + private final static String MODULES_PACKAGE = "eu.carrade.amaury.quartzsurvivalgames.modules"; /** * These built-in modules will not be enabled by default. It includes all scenarii and world generation modules, @@ -131,16 +131,19 @@ public void registerBuiltInModules() { try { for (final ClassPath.ClassInfo classInfo : ClassPath.from(getClass().getClassLoader()) .getTopLevelClassesRecursive(MODULES_PACKAGE)) { - final Class<?> potentialModuleClass = classInfo.load(); + try { + final Class<?> potentialModuleClass = classInfo.load(); - if (QSGModule.class.isAssignableFrom(potentialModuleClass)) { - registerModule((Class<? extends QSGModule>) potentialModuleClass, - !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); - i++; + if (QSGModule.class.isAssignableFrom(potentialModuleClass)) { + registerModule((Class<? extends QSGModule>) potentialModuleClass, + !DISABLED_BY_DEFAULT.contains(potentialModuleClass)); + i++; + } + } catch (final Throwable e) { + PluginLogger.error("Unable to load built-in module {0}: {1}", classInfo.getName(), e.getMessage()); } } - } - catch (final IOException e) { + } catch (final IOException e) { PluginLogger.error("Unable to load built-in modules.", e); } diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java index 55a8b38..05a4b41 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/core/timers/TimersModule.java @@ -39,6 +39,7 @@ import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.commands.TimersCommand; import fr.zcraft.quartzlib.components.commands.Command; import fr.zcraft.quartzlib.tools.runners.RunTask; +import java.util.AbstractMap; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -47,14 +48,13 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; -import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Material; import org.bukkit.entity.Player; @ModuleInfo( name = "Timers", - description = "The timekeeper of the whole UHCReloaded plugin & companions.", + description = "The timekeeper of the whole Quartz Survival Games plugin & companions.", category = ModuleCategory.CORE, icon = Material.CLOCK, internal = true, @@ -78,7 +78,7 @@ public class TimersModule extends QSGModule { /** * Sidebar cache. */ - private List<Pair<String, String>> sidebarInjection = new LinkedList<>(); + private List<AbstractMap.SimpleImmutableEntry<String, String>> sidebarInjection = new LinkedList<>(); @Override @@ -98,7 +98,8 @@ public void prepareInjectionIntoSidebar() { sidebarInjection.clear(); sidebarInjection = timers.stream() .filter(Timer::isDisplayed) - .map(timer -> Pair.of(timer.isNameDisplayed() ? timer.getDisplayName() : null, timer.toString())) + .map(timer -> new AbstractMap.SimpleImmutableEntry<>( + timer.isNameDisplayed() ? timer.getDisplayName() : null, timer.toString())) .collect(Collectors.toList()); } @@ -107,10 +108,10 @@ public void injectIntoSidebar(Player player, SidebarInjector injector) { sidebarInjection.forEach(timer -> { final List<String> lines; - if (timer.getLeft() == null) { - lines = Collections.singletonList(timer.getRight()); + if (timer.getKey() == null) { + lines = Collections.singletonList(timer.getValue()); } else { - lines = Arrays.asList(timer.getLeft(), timer.getRight()); + lines = Arrays.asList(timer.getKey(), timer.getValue()); } injector.injectLines(SidebarInjector.SidebarPriority.VERY_BOTTOM, true, lines); From 6f9e2eba5e80050f366b9afb77f45abe58c97e7d Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 24 Apr 2021 12:51:38 +0200 Subject: [PATCH 87/91] Fixed Maven repos (??) --- pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d7c1552..8ca0a13 100644 --- a/pom.xml +++ b/pom.xml @@ -161,8 +161,12 @@ <url>https://maven.zcraft.fr/QuartzLib</url> </repository> <repository> - <id>zdevelpers-quartQuartzTeams</id> - <url>https://maven.zcraft.fr/QuartQuartzTeams</url> + <id>zdevelpers-quartzteams</id> + <url>https://maven.zcraft.fr/QuartzTeams</url> + </repository> + <repository> + <id>zdevelpers-hawk</id> + <url>https://maven.zcraft.fr/Hawk</url> </repository> </repositories> <dependencies> From fb1ef16487c595f6333f1c596c180f33c34904ef Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 24 Apr 2021 13:10:05 +0200 Subject: [PATCH 88/91] Fixed Hawk dependency --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8ca0a13..1173c7a 100644 --- a/pom.xml +++ b/pom.xml @@ -188,8 +188,8 @@ </dependency> <dependency> <groupId>me.cassayre.florian</groupId> - <artifactId>Hawk</artifactId> - <version>1.0-SNAPSHOT</version> + <artifactId>hawk</artifactId> + <version>2.0.0</version> </dependency> <dependency> <groupId>com.pgcraft</groupId> From 0c96d8a439ab319392413d6521181ae53b9d3e74 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 24 Apr 2021 18:55:43 +0200 Subject: [PATCH 89/91] Fixed onerous glistering melons - Used old names --- .../modules/gameplay/OnerousGlisteringMelon.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java index ee38f49..837844d 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/OnerousGlisteringMelon.java @@ -52,7 +52,7 @@ description = "Changes the vanilla recipe for glistering melon, replacing gold nuggets by gold ingots, to make healing potions harder to get.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.GAMEPLAY, - icon = Material.GLISTERING_MELON_SLICE // FIXME 1.13 + icon = Material.GLISTERING_MELON_SLICE ) public class OnerousGlisteringMelon extends QSGModule { private final Recipe VANILLA_RECIPE = CraftingRecipes.shaped( @@ -61,7 +61,7 @@ public class OnerousGlisteringMelon extends QSGModule { "AAA", "ABA", "AAA", - Material.GOLD_NUGGET, Material.MELON + Material.GOLD_NUGGET, Material.MELON_SLICE ); private final Recipe ONEROUS_RECIPE = CraftingRecipes.shaped( @@ -70,7 +70,7 @@ public class OnerousGlisteringMelon extends QSGModule { "AAA", "ABA", "AAA", - Material.GOLD_INGOT, Material.MELON + Material.GOLD_INGOT, Material.MELON_SLICE ); @Override From d5a75971775e1e3e1fb199a2f90998e14a8afab5 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 24 Apr 2021 19:25:44 +0200 Subject: [PATCH 90/91] Disabled regeneration suspicious stews --- .../NoOverpoweredSuspiciousStews.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoOverpoweredSuspiciousStews.java diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoOverpoweredSuspiciousStews.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoOverpoweredSuspiciousStews.java new file mode 100644 index 0000000..76a17e9 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/gameplay/NoOverpoweredSuspiciousStews.java @@ -0,0 +1,68 @@ +/* + * Plugin UHCReloaded + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ + +package eu.carrade.amaury.quartzsurvivalgames.modules.gameplay; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SuspiciousStewMeta; +import org.bukkit.potion.PotionEffectType; + + +@ModuleInfo( + name = "No Overpowered Suspicious Stews", + description = "Disables suspicious stews giving regeneration status effect.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.GAMEPLAY, + icon = Material.SUSPICIOUS_STEW +) +public class NoOverpoweredSuspiciousStews extends QSGModule { + @EventHandler + private void onPreCraft(final PrepareItemCraftEvent ev) { + if (ev.getInventory().getResult() != null && ev.getInventory().getResult().getType() == Material.SUSPICIOUS_STEW) { + final SuspiciousStewMeta stewMeta = (SuspiciousStewMeta) ev.getInventory().getResult().getItemMeta(); + if (stewMeta == null) return; + + if (stewMeta.hasCustomEffect(PotionEffectType.REGENERATION)) { + ev.getInventory().setResult(new ItemStack(Material.AIR)); + } + } + } +} From db6f13e08597ced5efebe9ffb35f7bad865a3ef8 Mon Sep 17 00:00:00 2001 From: Amaury Carrade <amaury@carrade.eu> Date: Sat, 24 Apr 2021 20:06:12 +0200 Subject: [PATCH 91/91] Added game duration module and disabled episodes by default --- .../core/ModulesManager.java | 5 +- .../modules/cosmetics/GameDurationModule.java | 69 +++++++++++++++++++ .../cosmetics/episodes/EpisodesModule.java | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/GameDurationModule.java diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java index 487d460..57c546c 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/core/ModulesManager.java @@ -38,6 +38,7 @@ import eu.carrade.amaury.quartzsurvivalgames.core.events.AllModulesLoadedEvent; import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleLoadedEvent; import eu.carrade.amaury.quartzsurvivalgames.core.events.ModuleUnloadedEvent; +import eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics.episodes.EpisodesModule; import eu.carrade.amaury.quartzsurvivalgames.modules.end.kick.KickModule; import eu.carrade.amaury.quartzsurvivalgames.modules.other.PomfModule; import eu.carrade.amaury.quartzsurvivalgames.modules.scenarii.alliances.AlliancesModule; @@ -77,10 +78,12 @@ public class ModulesManager extends QuartzComponent implements Listener { /** * These built-in modules will not be enabled by default. It includes all scenarii and world generation modules, - * so the default game is a standard one, and the kick module, as spectators are better for most admins. + * so the default game is a standard one, the kick module, as spectators are better for most admins, and + * the episodes modules, as not everyone is a youtuber. */ private final static List<Class<? extends QSGModule>> DISABLED_BY_DEFAULT = Arrays.asList( KickModule.class, + EpisodesModule.class, PomfModule.class, // Scenarii diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/GameDurationModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/GameDurationModule.java new file mode 100644 index 0000000..9b54042 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/GameDurationModule.java @@ -0,0 +1,69 @@ +/* + * Plugin UHCReloaded : Alliances + * + * Copyright ou © ou Copr. Amaury Carrade (2016) + * Idées et réflexions : Alexandre Prokopowicz, Amaury Carrade, "Vayan". + * + * Ce logiciel est régi par la licence CeCILL soumise au droit français et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilité au code source et des droits de copie, + * de modification et de redistribution accordés par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, + * seule une responsabilité restreinte pèse sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les concédants successifs. + * + * A cet égard l'attention de l'utilisateur est attirée sur les risques + * associés au chargement, à l'utilisation, à la modification et/ou au + * développement et à la reproduction du logiciel par l'utilisateur étant + * donné sa spécificité de logiciel libre, qui peut le rendre complexe à + * manipuler et qui le réserve donc à des développeurs et des professionnels + * avertis possédant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invités à charger et tester l'adéquation du + * logiciel à leurs besoins dans des conditions permettant d'assurer la + * sécurité de leurs systèmes et ou de leurs données et, plus généralement, + * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + * + * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accepté les + * termes. + */ + +package eu.carrade.amaury.quartzsurvivalgames.modules.cosmetics; + +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleCategory; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleInfo; +import eu.carrade.amaury.quartzsurvivalgames.core.ModuleLoadTime; +import eu.carrade.amaury.quartzsurvivalgames.core.QSGModule; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.sidebar.SidebarInjector; +import eu.carrade.amaury.quartzsurvivalgames.modules.core.timers.TimeDelta; +import org.bukkit.Material; +import org.bukkit.entity.Player; + + +@ModuleInfo( + name = "Game Duration", + description = "Displays the game duration in the sidebar.", + when = ModuleLoadTime.ON_GAME_START, + category = ModuleCategory.COSMETICS, + icon = Material.CLOCK +) +public class GameDurationModule extends QSGModule { + private long beginning = 0; + + @Override + protected void onEnable() { + this.beginning = System.currentTimeMillis(); + } + + @Override + public void injectIntoSidebar(final Player player, final SidebarInjector injector) { + injector.injectLines( + SidebarInjector.SidebarPriority.BOTTOM, true, + new TimeDelta((System.currentTimeMillis() - beginning) / 1000).toString() + ); + } +} diff --git a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java index 862807b..eb2ed28 100644 --- a/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java +++ b/src/main/java/eu/carrade/amaury/quartzsurvivalgames/modules/cosmetics/episodes/EpisodesModule.java @@ -68,7 +68,7 @@ description = "Displays time marks every 20 minutes (by default), e.g. to divide a recording for diffusion.", when = ModuleLoadTime.ON_GAME_START, category = ModuleCategory.COSMETICS, - icon = Material.BIRCH_SIGN, + icon = Material.BELL, settings = Config.class, can_be_loaded_late = false )