├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── TODO ├── pom.xml └── src └── main ├── java └── eu │ └── carrade │ └── amaury │ └── UHCReloaded │ ├── UHCReloaded.java │ ├── UHConfig.java │ ├── borders │ ├── BorderManager.java │ ├── MapShape.java │ ├── exceptions │ │ ├── CannotGenerateWallsException.java │ │ └── UnknownWallGenerator.java │ ├── generators │ │ ├── CircularWallGenerator.java │ │ ├── SquaredWallGenerator.java │ │ ├── WallGenerator.java │ │ └── WallPosition.java │ ├── shapes │ │ ├── CircularMapShape.java │ │ ├── MapShapeDescriptor.java │ │ └── SquaredMapShape.java │ └── worldborders │ │ ├── BrettflanWorldBorder.java │ │ ├── FakeWorldBorder.java │ │ ├── VanillaWorldBorder.java │ │ └── WorldBorder.java │ ├── commands │ ├── UHCommandExecutor.java │ ├── commands │ │ ├── GlobalMessageCommand.java │ │ ├── JoinCommand.java │ │ ├── LeaveCommand.java │ │ ├── TeamMessageCommand.java │ │ ├── TeamsCommand.java │ │ ├── ToggleChatCommand.java │ │ ├── UHRootCommand.java │ │ ├── categories │ │ │ └── Category.java │ │ └── uh │ │ │ ├── UHAboutCommand.java │ │ │ ├── UHBorderCommand.java │ │ │ ├── UHFeedAllCommand.java │ │ │ ├── UHFeedCommand.java │ │ │ ├── UHFinishCommand.java │ │ │ ├── UHFreezeCommand.java │ │ │ ├── UHGenerateWallsCommand.java │ │ │ ├── UHHealAllCommand.java │ │ │ ├── UHHealCommand.java │ │ │ ├── UHInfosCommand.java │ │ │ ├── UHKillCommand.java │ │ │ ├── UHLoadPlayersCommand.java │ │ │ ├── UHResurrectCommand.java │ │ │ ├── UHRulesCommand.java │ │ │ ├── UHShiftCommand.java │ │ │ ├── UHSpawnsCommand.java │ │ │ ├── UHSpectatorsCommand.java │ │ │ ├── UHStartCommand.java │ │ │ ├── UHTPBackCommand.java │ │ │ ├── UHTPCommand.java │ │ │ ├── UHTPSpawnCommand.java │ │ │ ├── UHTeamCommand.java │ │ │ ├── UHTimersCommand.java │ │ │ ├── border │ │ │ ├── UHBorderCheckCommand.java │ │ │ ├── UHBorderGetCommand.java │ │ │ ├── UHBorderSetCommand.java │ │ │ └── UHBorderWarningCommand.java │ │ │ ├── spawns │ │ │ ├── UHSpawnsAddCommand.java │ │ │ ├── UHSpawnsDumpCommand.java │ │ │ ├── UHSpawnsGenerateCommand.java │ │ │ ├── UHSpawnsListCommand.java │ │ │ ├── UHSpawnsRemoveCommand.java │ │ │ └── UHSpawnsResetCommand.java │ │ │ ├── team │ │ │ ├── UHTeamAddCommand.java │ │ │ ├── UHTeamBannerCommand.java │ │ │ ├── UHTeamBannerResetCommand.java │ │ │ ├── UHTeamGUICommand.java │ │ │ ├── UHTeamJoinCommand.java │ │ │ ├── UHTeamLeaveCommand.java │ │ │ ├── UHTeamListCommand.java │ │ │ ├── UHTeamRemoveCommand.java │ │ │ ├── UHTeamResetCommand.java │ │ │ └── UHTeamSpyCommand.java │ │ │ └── timers │ │ │ ├── UHTimersAddCommand.java │ │ │ ├── UHTimersDisplayCommand.java │ │ │ ├── UHTimersHideCommand.java │ │ │ ├── UHTimersListCommand.java │ │ │ ├── UHTimersPauseCommand.java │ │ │ ├── UHTimersRemoveCommand.java │ │ │ ├── UHTimersResumeCommand.java │ │ │ ├── UHTimersSetCommand.java │ │ │ ├── UHTimersStartCommand.java │ │ │ └── UHTimersStopCommand.java │ └── core │ │ ├── AbstractCommand.java │ │ ├── AbstractCommandExecutor.java │ │ ├── annotations │ │ └── Command.java │ │ ├── exceptions │ │ └── CannotExecuteCommandException.java │ │ └── utils │ │ └── CommandUtils.java │ ├── events │ ├── EpisodeChangedCause.java │ ├── TimerEndsEvent.java │ ├── TimerStartsEvent.java │ ├── UHEpisodeChangedEvent.java │ ├── UHGameEndsEvent.java │ ├── UHGameStartsEvent.java │ ├── UHPlayerDeathEvent.java │ ├── UHPlayerResurrectedEvent.java │ └── UHTeamDeathEvent.java │ ├── game │ ├── Cage.java │ ├── TeleportationRunnable.java │ ├── Teleporter.java │ └── UHGameManager.java │ ├── gui │ └── teams │ │ ├── TeamsSelectorGUI.java │ │ ├── builder │ │ ├── TeamBuilderBaseGUI.java │ │ ├── TeamBuilderStepColorGUI.java │ │ ├── TeamBuilderStepNameGUI.java │ │ └── TeamBuilderStepPlayersGUI.java │ │ └── editor │ │ ├── TeamActionGUI.java │ │ ├── TeamEditColorGUI.java │ │ ├── TeamEditDeleteGUI.java │ │ ├── TeamEditGUI.java │ │ └── TeamEditMembersGUI.java │ ├── integration │ ├── UHDynmapIntegration.java │ ├── UHProtocolLibIntegration.java │ ├── UHProtocolLibIntegrationWrapper.java │ ├── UHSpectatorPlusIntegration.java │ └── UHWorldBorderIntegration.java │ ├── listeners │ ├── BeforeGameListener.java │ ├── CraftingListener.java │ ├── FreezerListener.java │ ├── GameListener.java │ ├── GameplayListener.java │ ├── PacketsListener.java │ └── SpawnsListener.java │ ├── misc │ ├── Freezer.java │ ├── MOTDManager.java │ ├── OfflinePlayersLoader.java │ ├── PlayerListHeaderFooterManager.java │ ├── RulesManager.java │ └── RuntimeCommandsExecutor.java │ ├── protips │ ├── ProTip.java │ └── ProTips.java │ ├── recipes │ ├── RecipeUtil.java │ └── RecipesManager.java │ ├── scoreboard │ ├── GameSidebar.java │ ├── ScoreboardListener.java │ ├── ScoreboardManager.java │ └── SidebarPlayerCache.java │ ├── spawns │ ├── Generator.java │ ├── SpawnsManager.java │ ├── exceptions │ │ ├── CannotGenerateSpawnPointsException.java │ │ └── UnknownGeneratorException.java │ └── generators │ │ ├── CircularSpawnPointsGenerator.java │ │ ├── GridSpawnPointsGenerator.java │ │ ├── RandomSpawnPointsGenerator.java │ │ └── SpawnPointsGenerator.java │ ├── spectators │ ├── SPlusSpectatorsManager.java │ ├── SpectatorsManager.java │ └── VanillaSpectatorsManager.java │ ├── task │ ├── BorderWarningTask.java │ ├── CancelBrewTask.java │ ├── FireworksOnWinnersTask.java │ ├── ScheduledCommandsExecutorTask.java │ └── UpdateTimerTask.java │ ├── teams │ ├── TeamChatManager.java │ ├── TeamColor.java │ ├── TeamManager.java │ └── UHTeam.java │ ├── timers │ ├── TimerManager.java │ └── UHTimer.java │ └── utils │ ├── ColorsUtils.java │ ├── OfflinePlayersComparator.java │ ├── TextUtils.java │ ├── UHSound.java │ └── UHUtils.java └── resources ├── config.yml ├── i18n ├── cs_CZ.po ├── en_US.po ├── fr_FR.po ├── pt_BR.po ├── pt_PT.po ├── zh_CN.po └── zh_CN.yml └── plugin.yml /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *The following template is required if you report a bug. For a suggestion, you can clear this, but don't forget to open one issue per suggestion!* 2 | 3 | #### Environment 4 | 5 | * **Minecraft version**: 6 | * **Plateform used**: CraftBukkit / Spigot 7 | * **Bukkit or Spigot version**: 8 | * **Plugin version**: 9 | * **Plugin build number**: (Check out the CONTRIBUTING file linked above the form to see where this number is) 10 | 11 | 12 | #### Problem description 13 | 14 | Write here a description of the problem you encounter. Remember to also use a descriptive title for your issue! 15 | 16 | 17 | #### Steps to reproduce 18 | 19 | Write here how we can reproduce this bug, if applicable. This help us to understand the problem and fix it quicker. 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | target 4 | .settings 5 | bin/ 6 | screenshots/ 7 | *~ 8 | *.iml 9 | .idea/ 10 | dependency-reduced-pom.xml 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to contribute 2 | 3 | ### Bugs 4 | 5 | 1. Check if the bug exists in the [latest development build](http://jenkins.carrade.eu/job/UltraHardcoreReloaded/). 6 | 1. Check if you're using **Bukkit 1.7.9 or later** (older versions are not supported). 7 | 1. Please choose **a descriptive title.** 8 | *Bad: « Error »* 9 | *Good: « Crash when the plugin starts: “Invalid plugin.yml” »* 10 | 1. Write the **steps to reproduce** the bug. 11 | 1. **Join the version *and* the build number** (displayed in the `/uh about` command) to your issue. 12 | *If there isn't any line for the build number, you're not using the latest version. In this case, provide only the version number.* 13 | 14 | ``` 15 | > uh about 16 | Ultra Hardcore plugin - version 1.1.3 dev ———— This 17 | Plugin made with love by... 18 | Build number: 02edb555d3. ———— And this 19 | ``` 20 | 21 | ### Suggestions 22 | 23 | 1. Please **check if the feature is not already implemented** in the [latest development build](http://jenkins.carrade.eu/job/UltraHardcoreReloaded/), **or [planned in the future](https://github.com/AmauryCarrade/UHPlugin/labels/enhancement)**. 24 | 2. Open **one issue per suggestion**, not one issue with multiple ideas. 25 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | This TOTO file is outdated. Please see the issues. 2 | 3 | 4 | ======================================================================================= 5 | 6 | 7 | - [OK] Synchroniser l'horloge des épisodes avec une vraie horloge (évite le décalage 8 | à cause du lag). 9 | 10 | - [OK] Prendre en compte les cœurs d'absorption en cas de pommes d'or. 11 | 12 | - [OK] Optimiser la vérification de position des joueurs (ou se reposer uniquement 13 | sur WorldBorder, via son API). 14 | 15 | - [Partiel] Mettre à jour le code pour considérer les UUID (si besoin est). 16 | 17 | - [Supprimée] Mettre à jour le code : l'interface de gestion des équipes ne marche 18 | pas en 1.7.9. (Ou suppression ? Elle est jolie mais peu efficace en pratique.) 19 | 20 | - Ajouter des commandes : 21 | [OK] /uh team add 22 | [OK] /uh team addplayer <équipe> 23 | → (ajoute un joueur dans une équipe ET le retire de toutes les autres) 24 | [OK] /uh team removeplayer 25 | [OK] /uh heal 26 | [OK] /uh hellall 27 | [OK] /uh resurrect 28 | [OK] /uh tpback 29 | 30 | - [OK] Désactiver le spawn de mobs nocifs avant le début de la partie 31 | 32 | - [OK] Ajouter un mode de démarrage progressif : 33 | /uh start slow : freeze les joueurs et TP les équipes progressivement, les 34 | joueurs ont le fly et restent en l'air 35 | /uh start slow go : démarre, défreeze, active les mobs, donne l'immunité pour 30s 36 | 37 | - [OK] Autocomplétion des commandes 38 | 39 | - [OK] Permissions 40 | 41 | - [OK] Option pour annuler les dégâts des ender pearls 42 | 43 | - [OK] Option pour annuler le spawn des sorcières (non utilisée par moi mais peut être utile) 44 | 45 | - [OK] Mettre les restrictions en option (notamment celle des potions II, des 46 | ghasts qui ne dropent pas des larmes) 47 | 48 | - [OK] Corriger le bug d'affichage des joueurs vivants (actuellement compte les 49 | joueurs en ligne, pas uniquement les vivants) 50 | → [OK] Liste des joueurs vivants 51 | → [OK] /uh resurrect pour reprendre en compte un joueur 52 | - [OK+MIEUX] Enregistrer périodiquement les positions des joueurs pour pouvoir 53 | faire /uh revive et les re-TP même en cas de solo. 54 | (Quid des morts dans la lave ? Donner 30 sec d'invulnérabilité au joueur en question ?) 55 | 56 | - [OK 32c.]Ne pas couper le titre du jeu (actuellement coupé à 16 caractères) si possible. 57 | 58 | - [OK] Corriger le bug d'arrondi des cœurs. 59 | 60 | - [OK] Remplacer « team » par « équipe ». PARTOUT. 61 | 62 | - [OK] Ne pas perdre de la faim avant le début du jeu. 63 | 64 | - [OK] Les OPs peuvent placer des blocs même avant le début 65 | 66 | - [OK] Commenter le code 67 | 68 | - [OK] Réorganiser le code 69 | 70 | - [OK] Ajouter un moyen de spécifier un temps laissé pour que les joueurs aillent dans 71 | les nouvelles limites. 72 | → Ajoute le temps restant au message disant que le joueur est hors des futures 73 | limites. 74 | « Vous avez 157 blocs à parcourir pour y être, et 12 minutes pour le faire. » 75 | → À l'expiration du temps imparti, un message est envoyé à celui qui a lancé 76 | l'avertissement précisant que le temps est écoulé et affichant les joueurs 77 | hors de la future bordure (comme /uh border check). 78 | 79 | - [OK] Ajouter un moyen de générer des murs ronds, et non uniquement carrés. 80 | 81 | - [OK] Optimiser la manière dont le blockage des potions est fait (empêcher de mettre 82 | la glowstone plutôt qu'annuler la fabrication de la potion, l'annulation étant 83 | faite après l'attente d'infusion). 84 | 85 | - Ajouter un moyen de configurer le nombre de cœurs régénérés par une pomme d'or 86 | classique/une pomme d'or faite depuis une tête 87 | → [OK] Se baser sur le nom de la pomme d'or faite à partir d'une tête 88 | → [OK] Modifier le craft anti-lore pour qu'il ne change pas le nom 89 | → [OK] Empêcher le renommage d'une pomme d'or en le nom d'une pomme d'or de tête 90 | 91 | - [OK] Ajouter un moyen de désactiver les pommes de Notch (désactivé par défaut) 92 | 93 | - [OK] Ajouter un moyen de mettre le jeu en pause (immobilise les joueurs, les mobs, le timer). 94 | → [OK] Passer par une classe dédiée pour gérer l'immobilisation (que ce soit celui du début ou celui-là). 95 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/MapShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders; 33 | 34 | import eu.carrade.amaury.UHCReloaded.borders.generators.CircularWallGenerator; 35 | import eu.carrade.amaury.UHCReloaded.borders.generators.SquaredWallGenerator; 36 | import eu.carrade.amaury.UHCReloaded.borders.generators.WallGenerator; 37 | import eu.carrade.amaury.UHCReloaded.borders.shapes.CircularMapShape; 38 | import eu.carrade.amaury.UHCReloaded.borders.shapes.MapShapeDescriptor; 39 | import eu.carrade.amaury.UHCReloaded.borders.shapes.SquaredMapShape; 40 | import fr.zcraft.zlib.tools.PluginLogger; 41 | import org.bukkit.Material; 42 | 43 | import java.lang.reflect.Constructor; 44 | import java.lang.reflect.InvocationTargetException; 45 | 46 | 47 | public enum MapShape 48 | { 49 | CIRCULAR(new CircularMapShape(), CircularWallGenerator.class), 50 | SQUARED(new SquaredMapShape(), SquaredWallGenerator.class); 51 | 52 | 53 | private MapShapeDescriptor shape; 54 | private Class generatorClass; 55 | 56 | /** 57 | * @param generator The wall generator class associated with this shape. 58 | */ 59 | MapShape(MapShapeDescriptor shape, Class generator) 60 | { 61 | this.shape = shape; 62 | this.generatorClass = generator; 63 | } 64 | 65 | /** 66 | * Returns a new instance of the wall generator for this shape. 67 | * 68 | * @return The instance. 69 | */ 70 | public WallGenerator getWallGeneratorInstance(Material wallBlockAir, Material wallBlockSolid) 71 | { 72 | try 73 | { 74 | Constructor constructor = generatorClass.getConstructor(Material.class, Material.class); 75 | return (WallGenerator) constructor.newInstance(wallBlockAir, wallBlockSolid); 76 | 77 | } 78 | catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) 79 | { 80 | PluginLogger.error("Cannot instantiate the walls generator: invalid class.", e); 81 | return null; 82 | } 83 | } 84 | 85 | /** 86 | * Returns the shape descriptor. 87 | * 88 | * @return The shape. 89 | */ 90 | public MapShapeDescriptor getShape() 91 | { 92 | return shape; 93 | } 94 | 95 | /** 96 | * Returns a shape based on his name. 97 | * 98 | *

Not case sensitive.

99 | * 100 | * @param name The name. 101 | * @return The MapShape, or {@code null} if not found. 102 | */ 103 | public static MapShape fromString(String name) 104 | { 105 | try 106 | { 107 | return MapShape.valueOf(name.trim().toUpperCase()); 108 | } 109 | catch (IllegalArgumentException e) 110 | { 111 | return null; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/CannotGenerateWallsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.exceptions; 33 | 34 | public class CannotGenerateWallsException extends Exception 35 | { 36 | public CannotGenerateWallsException(String message) 37 | { 38 | super(message); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/exceptions/UnknownWallGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.exceptions; 33 | 34 | public class UnknownWallGenerator extends Exception 35 | { 36 | public UnknownWallGenerator(String message) 37 | { 38 | super(message); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/SquaredWallGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.generators; 33 | 34 | import org.bukkit.Material; 35 | import org.bukkit.World; 36 | 37 | 38 | public class SquaredWallGenerator extends WallGenerator 39 | { 40 | public SquaredWallGenerator(Material wallBlockAir, Material wallBlockSolid) 41 | { 42 | super(wallBlockAir, wallBlockSolid); 43 | } 44 | 45 | /** 46 | * Builds a wall in the world. 47 | * 48 | * @param world The world the wall will be built in. 49 | * @param diameter The diameter of the wall. 50 | * @param wallHeight The height of the wall. 51 | */ 52 | @Override 53 | public void build(World world, int diameter, int wallHeight) 54 | { 55 | final int halfDiameter = (int) Math.floor(diameter / 2); 56 | 57 | final int limitXInf = world.getSpawnLocation().add(-halfDiameter, 0, 0).getBlockX(); 58 | final int limitXSup = world.getSpawnLocation().add(halfDiameter, 0, 0).getBlockX(); 59 | final int limitZInf = world.getSpawnLocation().add(0, 0, -halfDiameter).getBlockZ(); 60 | final int limitZSup = world.getSpawnLocation().add(0, 0, halfDiameter).getBlockZ(); 61 | 62 | for (int x = limitXInf; x <= limitXSup; x++) 63 | { 64 | world.getBlockAt(x, 1, limitZInf).setType(Material.BEDROCK); 65 | world.getBlockAt(x, 1, limitZSup).setType(Material.BEDROCK); 66 | 67 | for (int y = 2; y <= wallHeight; y++) 68 | { 69 | setBlock(world.getBlockAt(x, y, limitZInf), WallPosition.NORTH); 70 | setBlock(world.getBlockAt(x, y, limitZSup), WallPosition.SOUTH); 71 | } 72 | } 73 | 74 | for (int z = limitZInf + 1; z <= limitZSup - 1; z++) 75 | { 76 | world.getBlockAt(limitXInf, 1, z).setType(Material.BEDROCK); 77 | world.getBlockAt(limitXSup, 1, z).setType(Material.BEDROCK); 78 | 79 | for (int y = 2; y <= wallHeight; y++) 80 | { 81 | setBlock(world.getBlockAt(limitXInf, y, z), WallPosition.WEST); 82 | setBlock(world.getBlockAt(limitXSup, y, z), WallPosition.EAST); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/generators/WallPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.borders.generators; 34 | 35 | /** 36 | * Used to determine in witch wall we are, to get the "inner" block. 37 | * 38 | * North: small Z 39 | * South: big Z 40 | * East: big X 41 | * West: small X 42 | */ 43 | public enum WallPosition 44 | { 45 | NORTH, 46 | SOUTH, 47 | EAST, 48 | WEST 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/CircularMapShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.shapes; 33 | 34 | import org.bukkit.Location; 35 | import org.bukkit.World; 36 | 37 | 38 | public class CircularMapShape implements MapShapeDescriptor 39 | { 40 | /** 41 | * Returns true if the given location is inside the map. 42 | * 43 | * @param location The location to check. 44 | * @param diameter The diameter of the map. 45 | * @param center The center of the map. 46 | * 47 | * @return {@code true} if the given location is inside the map. 48 | */ 49 | @Override 50 | public boolean isInsideBorder(final Location location, final Double diameter, final Location center) 51 | { 52 | final Location centerRef = center.clone(); 53 | centerRef.setY(location.getY()); 54 | 55 | return (location.distance(centerRef) <= Math.floor(diameter / 2)); 56 | } 57 | 58 | /** 59 | * Returns the distance between the given location and the border with this diameter. 60 | * 61 | * @param location The distance will be calculated between this location and the closest point of the border. 62 | * @param diameter The diameter of the border. 63 | * @param center The center of the border. 64 | * 65 | * @return The distance between the given {@code location} and the closest point of the border.
66 | * {@code -1} if the location is inside the border. 67 | */ 68 | @Override 69 | public double getDistanceToBorder(final Location location, final Double diameter, final Location center) 70 | { 71 | // The nether/end are not limited. 72 | if (!location.getWorld().getEnvironment().equals(World.Environment.NORMAL)) 73 | { 74 | return -1; 75 | } 76 | 77 | if (isInsideBorder(location, diameter, center)) 78 | { 79 | return -1; 80 | } 81 | 82 | final Location centerRef = center.clone(); 83 | centerRef.setY(location.getY()); 84 | 85 | return (location.distance(centerRef) - Math.floor(diameter / 2)); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/shapes/MapShapeDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.shapes; 33 | 34 | import org.bukkit.Location; 35 | 36 | 37 | /** 38 | * Represents a shape of the map. 39 | */ 40 | public interface MapShapeDescriptor 41 | { 42 | /** 43 | * Returns true if the given location is inside the map. 44 | * 45 | * @param location The location to check. 46 | * @param diameter The diameter of the map. 47 | * @param center The center of the map. 48 | * 49 | * @return {@code true} if the given location is inside the map. 50 | */ 51 | boolean isInsideBorder(final Location location, final Double diameter, final Location center); 52 | 53 | /** 54 | * Returns the distance between the given location and the border with this diameter. 55 | * 56 | * @param location The distance will be calculated between this location and the closest point of the border. 57 | * @param diameter The diameter of the border. 58 | * @param center The center of the border. 59 | * 60 | * @return The distance between the given {@code location} and the closest point of the border.
61 | * {@code -1} if the location is inside the border. 62 | */ 63 | double getDistanceToBorder(final Location location, final Double diameter, final Location center); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/borders/worldborders/FakeWorldBorder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.borders.worldborders; 33 | 34 | import eu.carrade.amaury.UHCReloaded.borders.MapShape; 35 | import org.bukkit.Location; 36 | import org.bukkit.World; 37 | 38 | 39 | /** 40 | * A fake world border, it does nothing. 41 | * 42 | *

Used when a circular world border is requested without the WorldBorder plugin.

43 | */ 44 | public class FakeWorldBorder extends WorldBorder 45 | { 46 | private final World world; 47 | 48 | private Location center; 49 | private Double diameter; 50 | private MapShape shape; 51 | 52 | public FakeWorldBorder(World world) 53 | { 54 | this.world = world; 55 | 56 | init(); 57 | } 58 | 59 | @Override 60 | public World getWorld() 61 | { 62 | return world; 63 | } 64 | 65 | @Override 66 | public double getDiameter() 67 | { 68 | return diameter; 69 | } 70 | 71 | @Override 72 | public void setDiameter(double diameter) 73 | { 74 | this.diameter = diameter; 75 | } 76 | 77 | @Override 78 | public void setDiameter(double diameter, long time) 79 | { 80 | this.diameter = diameter; 81 | } 82 | 83 | @Override 84 | public Location getCenter() 85 | { 86 | return center; 87 | } 88 | 89 | @Override 90 | public void setCenter(double x, double z) 91 | { 92 | this.center = new Location(world, x, 0, z); 93 | } 94 | 95 | @Override 96 | public void setCenter(Location center) 97 | { 98 | setCenter(center.getX(), center.getZ()); 99 | } 100 | 101 | @Override 102 | public double getDamageBuffer() { return 0; } 103 | 104 | @Override 105 | public void setDamageBuffer(double distance) {} 106 | 107 | @Override 108 | public double getDamageAmount() { return 0; } 109 | 110 | @Override 111 | public void setDamageAmount(double damageAmount) {} 112 | 113 | @Override 114 | public int getWarningTime() { return 0; } 115 | 116 | @Override 117 | public void setWarningTime(int seconds) {} 118 | 119 | @Override 120 | public int getWarningDistance() { return 0; } 121 | 122 | @Override 123 | public void setWarningDistance(int blocks) {} 124 | 125 | @Override 126 | public MapShape getShape() 127 | { 128 | return shape; 129 | } 130 | 131 | @Override 132 | public void setShape(MapShape shape) 133 | { 134 | this.shape = shape; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/UHCommandExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.GlobalMessageCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.commands.JoinCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.commands.LeaveCommand; 38 | import eu.carrade.amaury.UHCReloaded.commands.commands.TeamMessageCommand; 39 | import eu.carrade.amaury.UHCReloaded.commands.commands.TeamsCommand; 40 | import eu.carrade.amaury.UHCReloaded.commands.commands.ToggleChatCommand; 41 | import eu.carrade.amaury.UHCReloaded.commands.commands.UHRootCommand; 42 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommandExecutor; 43 | 44 | 45 | public class UHCommandExecutor extends AbstractCommandExecutor 46 | { 47 | public UHCommandExecutor(UHCReloaded p) 48 | { 49 | super(p); 50 | 51 | registerCommand(new UHRootCommand(p)); // /uh 52 | 53 | registerCommand(new JoinCommand(p)); // /join 54 | registerCommand(new LeaveCommand(p)); // /leave 55 | registerCommand(new TeamsCommand(p)); // /teams 56 | 57 | registerCommand(new TeamMessageCommand(p)); // /t 58 | registerCommand(new GlobalMessageCommand(p)); // /g 59 | registerCommand(new ToggleChatCommand(p)); // /togglechat 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/JoinCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamJoinCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import org.bukkit.command.CommandSender; 39 | import org.bukkit.entity.Player; 40 | 41 | 42 | // The permissions are too complex, we need to manage them manually. 43 | @Command (name = "join", noPermission = true, inheritPermission = false) 44 | public class JoinCommand extends UHTeamJoinCommand 45 | { 46 | private UHCReloaded p; 47 | 48 | public JoinCommand(UHCReloaded plugin) 49 | { 50 | super(plugin); 51 | p = plugin; 52 | } 53 | 54 | @Override 55 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 56 | { 57 | if (args.length == 0 && sender instanceof Player 58 | && sender.hasPermission("uh.player.join.self")) 59 | { 60 | p.getTeamManager().displayTeamChooserChatGUI((Player) sender); 61 | } 62 | 63 | else 64 | { 65 | super.run(sender, args); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/LeaveCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamLeaveCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | 38 | 39 | // The permissions are too complex, we need to manage them manually. 40 | @Command (name = "leave", noPermission = true, inheritPermission = false) 41 | public class LeaveCommand extends UHTeamLeaveCommand 42 | { 43 | public LeaveCommand(UHCReloaded plugin) 44 | { 45 | super(plugin); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamMessageCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.commands.commands; 34 | 35 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 39 | import fr.zcraft.zlib.components.i18n.I; 40 | import org.bukkit.command.CommandSender; 41 | import org.bukkit.entity.Player; 42 | 43 | import java.util.Collections; 44 | import java.util.List; 45 | 46 | 47 | /** 48 | * This command, /t , is used to send a team-message. 49 | */ 50 | @Command (name = "t", noPermission = true) 51 | public class TeamMessageCommand extends AbstractCommand 52 | { 53 | private UHCReloaded p; 54 | 55 | public TeamMessageCommand(UHCReloaded p) 56 | { 57 | this.p = p; 58 | } 59 | 60 | /** 61 | * Runs the command. 62 | * 63 | * @param sender The sender of the command. 64 | * @param args The arguments passed to the command. 65 | * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. 66 | */ 67 | @Override 68 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 69 | { 70 | if (!(sender instanceof Player)) 71 | { 72 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER); 73 | } 74 | 75 | // /t 76 | if (args.length == 0) 77 | { 78 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 79 | } 80 | 81 | StringBuilder message = new StringBuilder(); 82 | for (final String arg : args) 83 | { 84 | message.append(arg).append(" "); 85 | } 86 | 87 | p.getTeamChatManager().sendTeamMessage((Player) sender, message.toString()); 88 | } 89 | 90 | /** 91 | * Tab-completes this command. 92 | * 93 | * @param sender The sender. 94 | * @param args The arguments passed to the command. 95 | * @return A list of suggestions. 96 | */ 97 | @Override 98 | public List tabComplete(CommandSender sender, String[] args) 99 | { 100 | return null; 101 | } 102 | 103 | 104 | @Override 105 | public List help(CommandSender sender) 106 | { 107 | /// Usage of the /g and /t commands 108 | return Collections.singletonList(I.t("{ce}Usage: /{0} ", "t")); 109 | } 110 | 111 | @Override 112 | public List onListHelp(CommandSender sender) 113 | { 114 | return null; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/TeamsCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.team.UHTeamGUICommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | 38 | 39 | @Command (name = "teams", noPermission = true, inheritPermission = false) 40 | public class TeamsCommand extends UHTeamGUICommand 41 | { 42 | public TeamsCommand(UHCReloaded plugin) 43 | { 44 | super(plugin); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/categories/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.categories; 33 | 34 | import fr.zcraft.zlib.components.i18n.I; 35 | 36 | 37 | public enum Category 38 | { 39 | GAME(I.t("{aqua}------ Game-related commands ------")), 40 | BUGS(I.t("{aqua}------ Bugs-related commands ------")), 41 | MISC(I.t("{aqua}------ Miscellaneous commands ------")); 42 | 43 | 44 | private String title; 45 | 46 | Category(String title) 47 | { 48 | this.title = title; 49 | } 50 | 51 | public String getTitle() 52 | { 53 | return title; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHBorderCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; 36 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderCheckCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderGetCommand; 38 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderSetCommand; 39 | import eu.carrade.amaury.UHCReloaded.commands.commands.uh.border.UHBorderWarningCommand; 40 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 41 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 42 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 43 | import fr.zcraft.zlib.components.i18n.I; 44 | import org.bukkit.command.CommandSender; 45 | 46 | import java.util.Collections; 47 | import java.util.List; 48 | 49 | 50 | /** 51 | * This command manages borders (gets current, checks if players are out, sets a new size, warns players 52 | * about the future size). 53 | * 54 | * Usage: /uh border (doc) 55 | * Usage: /uh border 56 | */ 57 | @Command (name = "border") 58 | public class UHBorderCommand extends AbstractCommand 59 | { 60 | public UHBorderCommand(UHCReloaded p) 61 | { 62 | registerSubCommand(new UHBorderGetCommand(p)); 63 | registerSubCommand(new UHBorderSetCommand(p)); 64 | registerSubCommand(new UHBorderWarningCommand(p)); 65 | registerSubCommand(new UHBorderCheckCommand(p)); 66 | } 67 | 68 | @Override 69 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 70 | { 71 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.NEED_DOC, this); 72 | } 73 | 74 | @Override 75 | public List tabComplete(CommandSender sender, String[] args) 76 | { 77 | return null; 78 | } 79 | 80 | @Override 81 | public List help(CommandSender sender) 82 | { 83 | return Collections.singletonList(I.t("{aqua}------ Border commands ------")); 84 | } 85 | 86 | @Override 87 | public List onListHelp(CommandSender sender) 88 | { 89 | return Collections.singletonList(I.t("{cc}/uh border {ci}: manages borders. Execute /uh border for details.")); 90 | } 91 | 92 | @Override 93 | public String getCategory() 94 | { 95 | return Category.GAME.getTitle(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHFinishCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh; 34 | 35 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 36 | import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 39 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 40 | import eu.carrade.amaury.UHCReloaded.game.UHGameManager; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.Collections; 45 | import java.util.List; 46 | 47 | /** 48 | * This commands broadcast the winner(s) of the game and sends some fireworks at these players. 49 | * It fails if there is more than one team alive. 50 | * 51 | * Usage: /uh finish 52 | */ 53 | @Command (name = "finish") 54 | public class UHFinishCommand extends AbstractCommand 55 | { 56 | private UHCReloaded p; 57 | 58 | public UHFinishCommand(UHCReloaded plugin) 59 | { 60 | this.p = plugin; 61 | } 62 | 63 | @Override 64 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 65 | { 66 | try 67 | { 68 | p.getGameManager().finishGame(); 69 | 70 | } 71 | catch (IllegalStateException e) 72 | { 73 | switch (e.getMessage()) 74 | { 75 | case UHGameManager.FINISH_ERROR_NOT_STARTED: 76 | sender.sendMessage(I.t("{ce}The game is not started!")); 77 | break; 78 | 79 | case UHGameManager.FINISH_ERROR_NOT_FINISHED: 80 | sender.sendMessage(I.t("{ce}There's not one team alive!")); 81 | break; 82 | 83 | default: 84 | throw e; 85 | } 86 | } 87 | } 88 | 89 | @Override 90 | public List tabComplete(CommandSender sender, String[] args) 91 | { 92 | return null; 93 | } 94 | 95 | @Override 96 | public List help(CommandSender sender) 97 | { 98 | return null; 99 | } 100 | 101 | @Override 102 | public List onListHelp(CommandSender sender) 103 | { 104 | return Collections.singletonList(I.t("{cc}/uh finish {ci}: displays the name of the winner(s) and launches some fireworks.")); 105 | } 106 | 107 | @Override 108 | public String getCategory() 109 | { 110 | return Category.MISC.getTitle(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 39 | import fr.zcraft.zlib.components.i18n.I; 40 | import org.bukkit.Bukkit; 41 | import org.bukkit.command.CommandSender; 42 | import org.bukkit.entity.Player; 43 | 44 | import java.util.Collections; 45 | import java.util.List; 46 | 47 | @Command (name = "rules") 48 | public class UHRulesCommand extends AbstractCommand 49 | { 50 | private UHCReloaded p; 51 | 52 | public UHRulesCommand(UHCReloaded plugin) 53 | { 54 | p = plugin; 55 | } 56 | 57 | 58 | @Override 59 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 60 | { 61 | if (!p.getRulesManager().isEnabled()) 62 | { 63 | sender.sendMessage(I.t("{ce}No rules are set in the config file.")); 64 | return; 65 | } 66 | 67 | if (args.length >= 1) 68 | { 69 | Player player = Bukkit.getPlayer(args[0]); 70 | if (player != null) 71 | { 72 | p.getRulesManager().displayRulesTo(player); 73 | 74 | if (!sender.equals(player)) 75 | sender.sendMessage(I.t("{cs}Rules sent to {0}.", player.getName())); 76 | } 77 | else 78 | { 79 | sender.sendMessage(I.t("{ce}Cannot display the rules to {0} because he (or she) is offline.", args[0])); 80 | } 81 | } 82 | else 83 | { 84 | p.getRulesManager().broadcastRules(); 85 | } 86 | } 87 | 88 | @Override 89 | public List tabComplete(CommandSender sender, String[] args) 90 | { 91 | return null; 92 | } 93 | 94 | @Override 95 | public List help(CommandSender sender) 96 | { 97 | return null; 98 | } 99 | 100 | @Override 101 | public List onListHelp(CommandSender sender) 102 | { 103 | return Collections.singletonList(I.t("{cc}/uh rules [player] {ci}: sends the server rules to the server or the given player.")); 104 | } 105 | 106 | @Override 107 | public String getCategory() 108 | { 109 | return Category.MISC.getTitle(); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHShiftCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 39 | import fr.zcraft.zlib.components.i18n.I; 40 | import org.bukkit.command.CommandSender; 41 | import org.bukkit.entity.Player; 42 | 43 | import java.util.Collections; 44 | import java.util.List; 45 | 46 | @Command (name = "shift") 47 | public class UHShiftCommand extends AbstractCommand 48 | { 49 | private UHCReloaded p; 50 | 51 | public UHShiftCommand(UHCReloaded p) 52 | { 53 | this.p = p; 54 | } 55 | 56 | @Override 57 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 58 | { 59 | if (p.getGameManager().isGameRunning()) 60 | { 61 | if (sender instanceof Player) 62 | { 63 | p.getGameManager().shiftEpisode(sender.getName()); 64 | } 65 | else 66 | { 67 | p.getGameManager().shiftEpisode(I.t("the console")); 68 | } 69 | } 70 | else 71 | { 72 | sender.sendMessage(I.t("{ce}You can't shift the current episode because the game is not started.")); 73 | } 74 | } 75 | 76 | @Override 77 | public List tabComplete(CommandSender sender, String[] args) 78 | { 79 | return null; 80 | } 81 | 82 | @Override 83 | public List help(CommandSender sender) 84 | { 85 | return null; 86 | } 87 | 88 | @Override 89 | public List onListHelp(CommandSender sender) 90 | { 91 | return Collections.singletonList(I.t("{cc}/uh shift {ci}: shifts an episode.")); 92 | } 93 | 94 | @Override 95 | public String getCategory() 96 | { 97 | return Category.GAME.getTitle(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderCheckCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import fr.zcraft.zlib.components.i18n.I; 39 | import org.bukkit.command.CommandSender; 40 | 41 | import java.util.Collections; 42 | import java.util.List; 43 | 44 | @Command (name = "check") 45 | public class UHBorderCheckCommand extends AbstractCommand 46 | { 47 | private UHCReloaded p; 48 | 49 | public UHBorderCheckCommand(UHCReloaded p) 50 | { 51 | this.p = p; 52 | } 53 | 54 | @Override 55 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 56 | { 57 | // /uh border check 58 | if (args.length == 0) 59 | { 60 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 61 | } 62 | // /uh border check 63 | else 64 | { 65 | try 66 | { 67 | p.getBorderManager().sendCheckMessage(sender, Integer.valueOf(args[0])); 68 | 69 | } 70 | catch (NumberFormatException e) 71 | { 72 | sender.sendMessage(I.t("{ce}“{0}” is not a number...", args[0])); 73 | } 74 | } 75 | } 76 | 77 | @Override 78 | public List tabComplete(CommandSender sender, String[] args) 79 | { 80 | return null; 81 | } 82 | 83 | @Override 84 | public List help(CommandSender sender) 85 | { 86 | return null; 87 | } 88 | 89 | @Override 90 | public List onListHelp(CommandSender sender) 91 | { 92 | return Collections.singletonList(I.t("{cc}/uh border check {ci}: returns a list of the players outside the given border size.")); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/border/UHBorderGetCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.border; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.borders.MapShape; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 39 | import fr.zcraft.zlib.components.i18n.I; 40 | import org.bukkit.command.CommandSender; 41 | 42 | import java.util.Collections; 43 | import java.util.List; 44 | 45 | @Command (name = "get") 46 | public class UHBorderGetCommand extends AbstractCommand 47 | { 48 | private UHCReloaded p; 49 | 50 | public UHBorderGetCommand(UHCReloaded p) 51 | { 52 | this.p = p; 53 | } 54 | 55 | @Override 56 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 57 | { 58 | if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) 59 | { 60 | 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())); 61 | } 62 | else 63 | { 64 | sender.sendMessage(I.t("{ci}The current map size is {0}×{0}.", p.getBorderManager().getCurrentBorderDiameter())); 65 | } 66 | } 67 | 68 | @Override 69 | public List tabComplete(CommandSender sender, String[] args) 70 | { 71 | return null; 72 | } 73 | 74 | @Override 75 | public List help(CommandSender sender) 76 | { 77 | return null; 78 | } 79 | 80 | @Override 81 | public List onListHelp(CommandSender sender) 82 | { 83 | return Collections.singletonList(I.t("{cc}/uh border get{ci}: returns the current size of the map.")); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/spawns/UHSpawnsResetCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.spawns; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import fr.zcraft.zlib.components.i18n.I; 39 | import org.bukkit.command.CommandSender; 40 | 41 | import java.util.Collections; 42 | import java.util.List; 43 | 44 | 45 | @Command (name = "reset") 46 | public class UHSpawnsResetCommand extends AbstractCommand 47 | { 48 | private UHCReloaded p; 49 | 50 | public UHSpawnsResetCommand(UHCReloaded plugin) 51 | { 52 | p = plugin; 53 | } 54 | 55 | /** 56 | * Runs the command. 57 | * 58 | * @param sender The sender of the command. 59 | * @param args The arguments passed to the command. 60 | * 61 | * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. 62 | */ 63 | @Override 64 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 65 | { 66 | p.getSpawnsManager().reset(); 67 | sender.sendMessage(I.t("{cs}All the spawn points were removed.")); 68 | } 69 | 70 | /** 71 | * Tab-completes this command. 72 | * 73 | * @param sender The sender. 74 | * @param args The arguments passed to the command. 75 | * 76 | * @return A list of suggestions. 77 | */ 78 | @Override 79 | public List tabComplete(CommandSender sender, String[] args) 80 | { 81 | return null; 82 | } 83 | 84 | @Override 85 | public List help(CommandSender sender) 86 | { 87 | return null; 88 | } 89 | 90 | @Override 91 | public List onListHelp(CommandSender sender) 92 | { 93 | return Collections.singletonList(I.t("{cc}/uh spawns reset {ci}: removes all registered spawn points.")); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamGUICommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; 39 | import fr.zcraft.zlib.components.gui.Gui; 40 | import fr.zcraft.zlib.components.i18n.I; 41 | import org.bukkit.command.CommandSender; 42 | import org.bukkit.entity.Player; 43 | 44 | import java.util.Collections; 45 | import java.util.List; 46 | 47 | 48 | @Command (name = "gui", noPermission = true, inheritPermission = false) 49 | public class UHTeamGUICommand extends AbstractCommand 50 | { 51 | public UHTeamGUICommand(UHCReloaded plugin) {} 52 | 53 | 54 | @Override 55 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 56 | { 57 | if (!(sender instanceof Player)) 58 | { 59 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.ONLY_AS_A_PLAYER, this); 60 | } 61 | 62 | Gui.open((Player) sender, new TeamsSelectorGUI()); 63 | } 64 | 65 | @Override 66 | public List tabComplete(CommandSender sender, String[] args) 67 | { 68 | return null; 69 | } 70 | 71 | @Override 72 | public List help(CommandSender sender) 73 | { 74 | return null; 75 | } 76 | 77 | @Override 78 | public List onListHelp(CommandSender sender) 79 | { 80 | return Collections.singletonList(I.t("{cc}/uh team gui {ci}: opens a GUI to join and manage the teams.")); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/team/UHTeamResetCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.team; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import fr.zcraft.zlib.components.i18n.I; 39 | import org.bukkit.command.CommandSender; 40 | 41 | import java.util.Collections; 42 | import java.util.List; 43 | 44 | 45 | @Command (name = "reset") 46 | public class UHTeamResetCommand extends AbstractCommand 47 | { 48 | private UHCReloaded p; 49 | 50 | public UHTeamResetCommand(UHCReloaded plugin) 51 | { 52 | p = plugin; 53 | } 54 | 55 | /** 56 | * Runs the command. 57 | * 58 | * @param sender The sender of the command. 59 | * @param args The arguments passed to the command. 60 | * 61 | * @throws eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException If the command cannot be executed. 62 | */ 63 | @Override 64 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 65 | { 66 | p.getTeamManager().reset(); 67 | sender.sendMessage(I.t("{cs}All teams where removed.")); 68 | } 69 | 70 | /** 71 | * Tab-completes this command. 72 | * 73 | * @param sender The sender. 74 | * @param args The arguments passed to the command. 75 | * 76 | * @return A list of suggestions. 77 | */ 78 | @Override 79 | public List tabComplete(CommandSender sender, String[] args) 80 | { 81 | return null; 82 | } 83 | 84 | @Override 85 | public List help(CommandSender sender) 86 | { 87 | return null; 88 | } 89 | 90 | @Override 91 | public List onListHelp(CommandSender sender) 92 | { 93 | return Collections.singletonList(I.t("{cc}/uh team reset {ci}: removes all teams.")); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersDisplayCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "display") 50 | public class UHTimersDisplayCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersDisplayCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | sender.sendMessage(I.t("{cs}The timer {0}{cs} is now displayed.", timer.getDisplayName())); 77 | } 78 | 79 | @Override 80 | public List tabComplete(CommandSender sender, String[] args) 81 | { 82 | List suggestions = new ArrayList<>(); 83 | 84 | for (UHTimer timer : p.getTimerManager().getTimers()) 85 | { 86 | suggestions.add(timer.getName()); 87 | } 88 | 89 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 90 | } 91 | 92 | @Override 93 | public List help(CommandSender sender) 94 | { 95 | return null; 96 | } 97 | 98 | @Override 99 | public List onListHelp(CommandSender sender) 100 | { 101 | return Collections.singletonList(I.t("{cc}/uh timers display {ci}: displays a timer in the scoreboard. Automatic when a timer is started.")); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersHideCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "hide") 50 | public class UHTimersHideCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersHideCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | 69 | UHTimer timer = p.getTimerManager().getTimer(timerName); 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | sender.sendMessage(I.t("{cs}The timer {0}{cs} is now hidden.", timer.getDisplayName())); 77 | } 78 | 79 | @Override 80 | public List<String> tabComplete(CommandSender sender, String[] args) 81 | { 82 | List<String> suggestions = new ArrayList<>(); 83 | 84 | for (UHTimer timer : p.getTimerManager().getTimers()) 85 | { 86 | suggestions.add(timer.getName()); 87 | } 88 | 89 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 90 | } 91 | 92 | @Override 93 | public List<String> help(CommandSender sender) 94 | { 95 | return null; 96 | } 97 | 98 | @Override 99 | public List<String> onListHelp(CommandSender sender) 100 | { 101 | return Collections.singletonList(I.t("{cc}/uh timers hide <title ...> {ci}: removes a timer from the scoreboard. Don't stops the timer.")); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersPauseCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "pause") 50 | public class UHTimersPauseCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersPauseCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | timer.setPaused(true); 77 | sender.sendMessage(I.t("{cs}The timer {0}{cs} is now paused.", timer.getDisplayName())); 78 | } 79 | 80 | @Override 81 | public List<String> tabComplete(CommandSender sender, String[] args) 82 | { 83 | List<String> suggestions = new ArrayList<>(); 84 | 85 | for (UHTimer timer : p.getTimerManager().getTimers()) 86 | { 87 | suggestions.add(timer.getName()); 88 | } 89 | 90 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 91 | } 92 | 93 | @Override 94 | public List<String> help(CommandSender sender) 95 | { 96 | return null; 97 | } 98 | 99 | @Override 100 | public List<String> onListHelp(CommandSender sender) 101 | { 102 | return Collections.singletonList(I.t("{cc}/uh timers pause <title ...> {ci}: pauses a timer.")); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersRemoveCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "remove") 50 | public class UHTimersRemoveCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersRemoveCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | p.getTimerManager().unregisterTimer(timer); 77 | timer.stop(); 78 | 79 | sender.sendMessage(I.t("{cs}The timer {0}{cs} has been deleted.", timer.getDisplayName())); 80 | } 81 | 82 | @Override 83 | public List<String> tabComplete(CommandSender sender, String[] args) 84 | { 85 | List<String> suggestions = new ArrayList<>(); 86 | 87 | for (UHTimer timer : p.getTimerManager().getTimers()) 88 | { 89 | suggestions.add(timer.getName()); 90 | } 91 | 92 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 93 | } 94 | 95 | @Override 96 | public List<String> help(CommandSender sender) 97 | { 98 | return null; 99 | } 100 | 101 | @Override 102 | public List<String> onListHelp(CommandSender sender) 103 | { 104 | return Collections.singletonList(I.t("{cc}/uh timers remove <title ...> {ci}: deletes a timer.")); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersResumeCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "resume") 50 | public class UHTimersResumeCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersResumeCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | timer.setPaused(false); 77 | sender.sendMessage(I.t("{cs}The timer {0}{cs} was resumed.", timer.getDisplayName())); 78 | } 79 | 80 | @Override 81 | public List<String> tabComplete(CommandSender sender, String[] args) 82 | { 83 | List<String> suggestions = new ArrayList<>(); 84 | 85 | for (UHTimer timer : p.getTimerManager().getTimers()) 86 | { 87 | suggestions.add(timer.getName()); 88 | } 89 | 90 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 91 | } 92 | 93 | @Override 94 | public List<String> help(CommandSender sender) 95 | { 96 | return null; 97 | } 98 | 99 | @Override 100 | public List<String> onListHelp(CommandSender sender) 101 | { 102 | return Collections.singletonList(I.t("{cc}/uh timers resume <title ...> {ci}: resumes a timer.")); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStartCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "start") 50 | public class UHTimersStartCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersStartCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | if (timer.isRunning()) 77 | { 78 | timer.stop(); 79 | } 80 | 81 | timer.start(); 82 | sender.sendMessage(I.t("{cs}The timer {0}{cs} was started.", timer.getDisplayName())); 83 | } 84 | 85 | @Override 86 | public List<String> tabComplete(CommandSender sender, String[] args) 87 | { 88 | List<String> suggestions = new ArrayList<>(); 89 | 90 | for (UHTimer timer : p.getTimerManager().getTimers()) 91 | { 92 | suggestions.add(timer.getName()); 93 | } 94 | 95 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 96 | } 97 | 98 | @Override 99 | public List<String> help(CommandSender sender) 100 | { 101 | return null; 102 | } 103 | 104 | @Override 105 | public List<String> onListHelp(CommandSender sender) 106 | { 107 | return Collections.singletonList(I.t("{cc}/uh timers start <title ...> {ci}: starts a timer.")); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/timers/UHTimersStopCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.commands.uh.timers; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 36 | import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; 37 | import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; 38 | import eu.carrade.amaury.UHCReloaded.commands.core.utils.CommandUtils; 39 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 40 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 41 | import fr.zcraft.zlib.components.i18n.I; 42 | import org.bukkit.command.CommandSender; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Collections; 46 | import java.util.List; 47 | 48 | 49 | @Command (name = "stop") 50 | public class UHTimersStopCommand extends AbstractCommand 51 | { 52 | private UHCReloaded p; 53 | 54 | public UHTimersStopCommand(UHCReloaded p) 55 | { 56 | this.p = p; 57 | } 58 | 59 | @Override 60 | public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException 61 | { 62 | if (args.length == 0) 63 | { 64 | throw new CannotExecuteCommandException(CannotExecuteCommandException.Reason.BAD_USE, this); 65 | } 66 | 67 | String timerName = UHUtils.getStringFromCommandArguments(args, 0); 68 | UHTimer timer = p.getTimerManager().getTimer(timerName); 69 | 70 | if (timer == null) 71 | { 72 | sender.sendMessage(I.t("{ce}This timer is not registered.")); 73 | return; 74 | } 75 | 76 | timer.stop(); 77 | sender.sendMessage(I.t("{cs}The timer {0}{cs} was stopped.", timer.getDisplayName())); 78 | } 79 | 80 | @Override 81 | public List<String> tabComplete(CommandSender sender, String[] args) 82 | { 83 | List<String> suggestions = new ArrayList<>(); 84 | 85 | for (UHTimer timer : p.getTimerManager().getTimers()) 86 | { 87 | suggestions.add(timer.getName()); 88 | } 89 | 90 | return CommandUtils.getAutocompleteSuggestions(UHUtils.getStringFromCommandArguments(args, 0), suggestions, args.length - 1); 91 | } 92 | 93 | @Override 94 | public List<String> help(CommandSender sender) 95 | { 96 | return null; 97 | } 98 | 99 | @Override 100 | public List<String> onListHelp(CommandSender sender) 101 | { 102 | return Collections.singletonList(I.t("{cc}/uh timers stop <title ...> {ci}: stops a timer. The timer will be removed from the scoreboard.")); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/commands/core/exceptions/CannotExecuteCommandException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.commands.core.exceptions; 33 | 34 | import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; 35 | 36 | 37 | /** 38 | * This exception is fired when a command cannot be executed, for whatever reason. 39 | * 40 | * @version 1.0 41 | * @author Amaury Carrade 42 | */ 43 | public class CannotExecuteCommandException extends Exception 44 | { 45 | 46 | public enum Reason 47 | { 48 | /** 49 | * Use this if the player is not allowed to execute the command. 50 | */ 51 | NOT_ALLOWED, 52 | 53 | /** 54 | * Use this if the command can only be executed as a player, and 55 | * the sender is not a player. 56 | */ 57 | ONLY_AS_A_PLAYER, 58 | 59 | /** 60 | * Use this if the sender used the command badly. 61 | * 62 | * <p> 63 | * This will display the documentation and an error message. 64 | * </p> 65 | */ 66 | BAD_USE, 67 | 68 | /** 69 | * Use this to have the documentation of the command displayed. 70 | */ 71 | NEED_DOC, 72 | 73 | /** 74 | * Use this in other cases. 75 | */ 76 | UNKNOWN 77 | } 78 | 79 | private Reason reason; 80 | private AbstractCommand origin; 81 | 82 | public CannotExecuteCommandException(Reason reason, AbstractCommand origin) 83 | { 84 | this.reason = reason; 85 | this.origin = origin; 86 | } 87 | 88 | public CannotExecuteCommandException(Reason reason) 89 | { 90 | this(reason, null); 91 | } 92 | 93 | public Reason getReason() 94 | { 95 | return reason; 96 | } 97 | 98 | public AbstractCommand getOrigin() 99 | { 100 | return origin; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/EpisodeChangedCause.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | public enum EpisodeChangedCause 36 | { 37 | /** 38 | * The episode changed because the previous episode was finished. 39 | */ 40 | FINISHED, 41 | 42 | /** 43 | * The episode changed because the previous episode was shifted by someone using 44 | * the {@code /uh shift} command. 45 | */ 46 | SHIFTED 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerEndsEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 36 | import org.bukkit.event.Event; 37 | import org.bukkit.event.HandlerList; 38 | 39 | 40 | /** 41 | * This event is fired when a timer ends. 42 | * <p> 43 | * It is fired before all the values of the timer are reset. 44 | */ 45 | public final class TimerEndsEvent extends Event 46 | { 47 | private UHTimer timer; 48 | private Boolean timerWasUp = false; 49 | private Boolean restart = false; 50 | 51 | 52 | public TimerEndsEvent(UHTimer timer, Boolean timerUp) 53 | { 54 | this.timer = timer; 55 | 56 | this.timerWasUp = timerUp; 57 | } 58 | 59 | /** 60 | * Returns the timer. 61 | * 62 | * @return the timer. 63 | */ 64 | public UHTimer getTimer() 65 | { 66 | return timer; 67 | } 68 | 69 | /** 70 | * Returns true if the timer was stopped because it was up. 71 | * 72 | * @return true if the timer was stopped because it was up. 73 | */ 74 | public boolean wasTimerUp() 75 | { 76 | return timerWasUp; 77 | } 78 | 79 | /** 80 | * If true, the timer will be restarted. 81 | * 82 | * @param restart true if the timer needs to be restarted. 83 | */ 84 | public void setRestart(boolean restart) 85 | { 86 | this.restart = restart; 87 | } 88 | 89 | /** 90 | * Return true if the timer will be restarted. 91 | * 92 | * @return {@code true} if the timer needs to be restarted. 93 | */ 94 | public boolean getRestart() 95 | { 96 | return this.restart; 97 | } 98 | 99 | 100 | 101 | private static final HandlerList handlers = new HandlerList(); 102 | 103 | @Override 104 | public HandlerList getHandlers() 105 | { 106 | return handlers; 107 | } 108 | 109 | public static HandlerList getHandlerList() 110 | { 111 | return handlers; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/TimerStartsEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 36 | import org.bukkit.event.Event; 37 | import org.bukkit.event.HandlerList; 38 | 39 | 40 | /** 41 | * This event is fired when a timer ends. 42 | * 43 | * @author Amaury Carrade 44 | */ 45 | public final class TimerStartsEvent extends Event 46 | { 47 | private UHTimer timer; 48 | 49 | public TimerStartsEvent(UHTimer timer) 50 | { 51 | this.timer = timer; 52 | } 53 | 54 | /** 55 | * Returns the timer. 56 | * 57 | * @return 58 | */ 59 | public UHTimer getTimer() 60 | { 61 | return timer; 62 | } 63 | 64 | 65 | private static final HandlerList handlers = new HandlerList(); 66 | 67 | @Override 68 | public HandlerList getHandlers() 69 | { 70 | return handlers; 71 | } 72 | 73 | public static HandlerList getHandlerList() 74 | { 75 | return handlers; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHEpisodeChangedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import org.bukkit.event.Event; 36 | import org.bukkit.event.HandlerList; 37 | 38 | 39 | /** 40 | * Called when an episode changes. 41 | */ 42 | public class UHEpisodeChangedEvent extends Event 43 | { 44 | private int newEpisode; 45 | private EpisodeChangedCause cause; 46 | private String shifter; 47 | 48 | public UHEpisodeChangedEvent(int newEpisode, EpisodeChangedCause cause, String shifter) 49 | { 50 | this.newEpisode = newEpisode; 51 | this.cause = cause; 52 | this.shifter = shifter; 53 | } 54 | 55 | /** 56 | * Returns the new episode. 57 | * 58 | * @return The new episode. 59 | */ 60 | public int getNewEpisode() 61 | { 62 | return newEpisode; 63 | } 64 | 65 | /** 66 | * Why the episode changed? 67 | * 68 | * @return The cause. 69 | * 70 | * @see EpisodeChangedCause 71 | */ 72 | public EpisodeChangedCause getCause() 73 | { 74 | return cause; 75 | } 76 | 77 | /** 78 | * Returns the name of the shifter (the one that executed the /uh shift command, or "" if 79 | * the episode was shifted because the previous one was finished). 80 | * 81 | * @return The shifter. 82 | */ 83 | public String getShifter() 84 | { 85 | return shifter; 86 | } 87 | 88 | 89 | 90 | private static final HandlerList handlers = new HandlerList(); 91 | 92 | @Override 93 | public HandlerList getHandlers() 94 | { 95 | return handlers; 96 | } 97 | 98 | public static HandlerList getHandlerList() 99 | { 100 | return handlers; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameEndsEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import eu.carrade.amaury.UHCReloaded.teams.UHTeam; 36 | import org.bukkit.event.Cancellable; 37 | import org.bukkit.event.Event; 38 | import org.bukkit.event.HandlerList; 39 | 40 | 41 | public class UHGameEndsEvent extends Event implements Cancellable 42 | { 43 | private UHTeam winner; 44 | private boolean cancelled = false; 45 | 46 | public UHGameEndsEvent(UHTeam winner) 47 | { 48 | this.winner = winner; 49 | } 50 | 51 | /** 52 | * Returns the last team alive. 53 | * 54 | * @return The team. 55 | */ 56 | public UHTeam getWinnerTeam() 57 | { 58 | return winner; 59 | } 60 | 61 | 62 | @Override 63 | public boolean isCancelled() 64 | { 65 | return cancelled; 66 | } 67 | 68 | /** 69 | * Cancels the game ends. If cancelled, the end message / effects will not be broadcasted. 70 | * 71 | * @param cancelled {@code true} to cancel. 72 | */ 73 | @Override 74 | public void setCancelled(boolean cancelled) 75 | { 76 | this.cancelled = cancelled; 77 | } 78 | 79 | 80 | 81 | private static final HandlerList handlers = new HandlerList(); 82 | 83 | @Override 84 | public HandlerList getHandlers() 85 | { 86 | return handlers; 87 | } 88 | 89 | public static HandlerList getHandlerList() 90 | { 91 | return handlers; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHGameStartsEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import org.bukkit.event.Event; 36 | import org.bukkit.event.HandlerList; 37 | 38 | 39 | /** 40 | * This event is fired when the UHC game is started. 41 | */ 42 | public class UHGameStartsEvent extends Event 43 | { 44 | private static final HandlerList handlers = new HandlerList(); 45 | 46 | @Override 47 | public HandlerList getHandlers() 48 | { 49 | return handlers; 50 | } 51 | 52 | public static HandlerList getHandlerList() 53 | { 54 | return handlers; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerDeathEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import org.bukkit.entity.Player; 36 | import org.bukkit.event.Event; 37 | import org.bukkit.event.HandlerList; 38 | import org.bukkit.event.entity.PlayerDeathEvent; 39 | 40 | 41 | /** 42 | * Fired when a player playing an UHC match is dead. 43 | * <p> 44 | * This event is called before all the action executed on player death (sound, scoreboard updates, etc.). 45 | */ 46 | public class UHPlayerDeathEvent extends Event 47 | { 48 | private Player player; 49 | private PlayerDeathEvent ev; 50 | 51 | public UHPlayerDeathEvent(Player player, PlayerDeathEvent ev) 52 | { 53 | this.player = player; 54 | this.ev = ev; 55 | } 56 | 57 | /** 58 | * Returns the dead player. 59 | * @return The player. 60 | */ 61 | public Player getPlayer() 62 | { 63 | return player; 64 | } 65 | 66 | /** 67 | * Returns the PlayerDeathEvent under this event. 68 | * @return The PlayerDeathEvent. 69 | */ 70 | public PlayerDeathEvent getPlayerDeathEvent() 71 | { 72 | return ev; 73 | } 74 | 75 | 76 | 77 | private static final HandlerList handlers = new HandlerList(); 78 | 79 | @Override 80 | public HandlerList getHandlers() 81 | { 82 | return handlers; 83 | } 84 | 85 | public static HandlerList getHandlerList() 86 | { 87 | return handlers; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHPlayerResurrectedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import org.bukkit.entity.Player; 36 | import org.bukkit.event.Event; 37 | import org.bukkit.event.HandlerList; 38 | 39 | 40 | /** 41 | * Called when a player is resurrected. 42 | * <p> 43 | * This event is called when: 44 | * <ul> 45 | * <li>the command {@code /uh resurrect <player>} is executed, if the target is online;</li> 46 | * <li>the resurrected player logins, else</li> 47 | * </ul> 48 | * (i.e. when the message “the player is resurrected” is broadcasted). 49 | */ 50 | public class UHPlayerResurrectedEvent extends Event 51 | { 52 | private Player resurrectedPlayer; 53 | 54 | public UHPlayerResurrectedEvent(Player player) 55 | { 56 | this.resurrectedPlayer = player; 57 | } 58 | 59 | /** 60 | * Returns the resurrected player. 61 | * 62 | * @return The player. 63 | */ 64 | public Player getPlayer() 65 | { 66 | return resurrectedPlayer; 67 | } 68 | 69 | 70 | 71 | private static final HandlerList handlers = new HandlerList(); 72 | 73 | @Override 74 | public HandlerList getHandlers() 75 | { 76 | return handlers; 77 | } 78 | 79 | public static HandlerList getHandlerList() 80 | { 81 | return handlers; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/events/UHTeamDeathEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.events; 34 | 35 | import eu.carrade.amaury.UHCReloaded.teams.UHTeam; 36 | import org.bukkit.event.Event; 37 | import org.bukkit.event.HandlerList; 38 | 39 | 40 | /** 41 | * Event fired when the last member of a team die. 42 | */ 43 | public class UHTeamDeathEvent extends Event 44 | { 45 | private UHTeam team; 46 | 47 | public UHTeamDeathEvent(UHTeam team) 48 | { 49 | this.team = team; 50 | } 51 | 52 | /** 53 | * Returns the now-dead team. 54 | * 55 | * @return The team. 56 | */ 57 | public UHTeam getTeam() 58 | { 59 | return team; 60 | } 61 | 62 | 63 | 64 | private static final HandlerList handlers = new HandlerList(); 65 | 66 | @Override 67 | public HandlerList getHandlers() 68 | { 69 | return handlers; 70 | } 71 | 72 | public static HandlerList getHandlerList() 73 | { 74 | return handlers; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/game/TeleportationRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.game; 33 | 34 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 35 | import fr.zcraft.zlib.tools.Callback; 36 | import org.bukkit.scheduler.BukkitRunnable; 37 | 38 | import java.util.ArrayDeque; 39 | import java.util.HashSet; 40 | import java.util.NoSuchElementException; 41 | import java.util.Queue; 42 | import java.util.Set; 43 | import java.util.UUID; 44 | 45 | 46 | /** 47 | * @see Teleporter 48 | */ 49 | class TeleportationRunnable extends BukkitRunnable 50 | { 51 | private final Teleporter teleporter; 52 | private final Queue<UUID> teleportationQueue; 53 | 54 | private final Callback<UUID> onTeleportation; 55 | private final Callback<UUID> onTeleportationSuccessful; 56 | private final Callback<UUID> onTeleportationFailed; 57 | private final Callback<Set<UUID>> onTeleportationProcessFinished; 58 | 59 | private final Set<UUID> failed = new HashSet<>(); 60 | 61 | public TeleportationRunnable(Teleporter teleporter, Set<UUID> playersToTeleport, Callback<UUID> onTeleportation, Callback<UUID> onTeleportationSuccessful, Callback<UUID> onTeleportationFailed, Callback<Set<UUID>> onTeleportationProcessFinished) 62 | { 63 | this.teleporter = teleporter; 64 | this.onTeleportation = onTeleportation; 65 | this.onTeleportationSuccessful = onTeleportationSuccessful; 66 | this.onTeleportationFailed = onTeleportationFailed; 67 | this.onTeleportationProcessFinished = onTeleportationProcessFinished; 68 | 69 | this.teleportationQueue = new ArrayDeque<>(playersToTeleport); 70 | } 71 | 72 | @Override 73 | public void run() 74 | { 75 | try 76 | { 77 | UUID player = teleportationQueue.remove(); 78 | 79 | UHUtils.callIfDefined(onTeleportation, player); 80 | 81 | if (teleporter.teleportPlayer(player, false)) 82 | { 83 | UHUtils.callIfDefined(onTeleportationSuccessful, player); 84 | } 85 | else 86 | { 87 | UHUtils.callIfDefined(onTeleportationFailed, player); 88 | failed.add(player); 89 | } 90 | } 91 | catch (NoSuchElementException e) // Queue empty 92 | { 93 | UHUtils.callIfDefined(onTeleportationProcessFinished, failed); 94 | cancel(); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/builder/TeamBuilderStepNameGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.gui.teams.builder; 33 | 34 | import eu.carrade.amaury.UHCReloaded.teams.TeamColor; 35 | import fr.zcraft.zlib.components.gui.Gui; 36 | import fr.zcraft.zlib.components.gui.GuiAction; 37 | import fr.zcraft.zlib.components.gui.GuiUtils; 38 | import fr.zcraft.zlib.components.gui.PromptGui; 39 | import fr.zcraft.zlib.components.i18n.I; 40 | import org.bukkit.Material; 41 | 42 | 43 | public class TeamBuilderStepNameGUI extends TeamBuilderBaseGUI 44 | { 45 | private final TeamColor color; 46 | 47 | public TeamBuilderStepNameGUI(TeamColor color) 48 | { 49 | this.color = color; 50 | } 51 | 52 | @Override 53 | protected void onUpdate() 54 | { 55 | /// The title of the name selector GUI, in the create team GUIs 56 | setTitle(I.t("New team » {black}Name")); 57 | setSize(6 * 9); 58 | 59 | generateBreadcrumbs(BuildingStep.NAME); 60 | 61 | action("name", 22, GuiUtils.makeItem( 62 | Material.BOOK_AND_QUILL, 63 | /// The title of the button opening the sign to write the team name (creator GUIs) 64 | I.t("{white}Name the team"), 65 | /// The legend of the button opening the sign to write the team name (creator GUIs) 66 | GuiUtils.generateLore(I.t("{gray}When clicked, a sign will open; write the name of the team inside.")) 67 | )); 68 | } 69 | 70 | @GuiAction ("name") 71 | protected void name() 72 | { 73 | Gui.open(getPlayer(), new PromptGui(name -> 74 | { 75 | if (name.trim().isEmpty()) 76 | Gui.open(getPlayer(), new TeamBuilderStepNameGUI(getColor())); 77 | else 78 | Gui.open(getPlayer(), new TeamBuilderStepPlayersGUI(getColor(), name)); 79 | })); 80 | } 81 | 82 | 83 | @Override 84 | protected TeamColor getColor() { return color; } 85 | 86 | @Override 87 | protected String getName() { return null; } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamActionGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.gui.teams.editor; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.teams.UHTeam; 36 | import fr.zcraft.zlib.components.gui.ActionGui; 37 | import fr.zcraft.zlib.components.gui.GuiUtils; 38 | import fr.zcraft.zlib.components.i18n.I; 39 | import fr.zcraft.zlib.tools.items.ItemStackBuilder; 40 | import org.bukkit.Material; 41 | import org.bukkit.inventory.ItemStack; 42 | 43 | 44 | public abstract class TeamActionGUI extends ActionGui 45 | { 46 | protected final UHTeam team; 47 | 48 | public TeamActionGUI(UHTeam team) 49 | { 50 | this.team = team; 51 | } 52 | 53 | /** 54 | * Checks if the team still exists. 55 | * @return {@code true} if the team exists. 56 | */ 57 | protected boolean exists() 58 | { 59 | return UHCReloaded.get().getTeamManager().isTeamRegistered(team); 60 | } 61 | 62 | /** 63 | * Generates the item to display if the team was deleted while a player edited the team on a GUI. 64 | * @return the item. 65 | */ 66 | protected ItemStack getDeletedItem() 67 | { 68 | return new ItemStackBuilder(Material.BARRIER) 69 | /// Title of the item displayed if a team was deleted while someone edited it in a GUI. 70 | .title(I.t("{red}Team deleted")) 71 | /// Lore of the item displayed if a team was deleted while someone edited it in a GUI. 72 | .lore(GuiUtils.generateLore(I.t("{gray}The team {0}{gray} was deleted by another player.", team.getDisplayName()))) 73 | .lore("") 74 | /// Lore of the item displayed if a team was deleted while someone edited it in a GUI. 75 | .lore(GuiUtils.generateLore(I.t("{gray}Press {white}Escape{gray} to go back to the teams list."))) 76 | .hideAttributes() 77 | .item(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditColorGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.gui.teams.editor; 33 | 34 | import eu.carrade.amaury.UHCReloaded.gui.teams.builder.TeamBuilderStepColorGUI; 35 | import eu.carrade.amaury.UHCReloaded.teams.TeamColor; 36 | import eu.carrade.amaury.UHCReloaded.teams.UHTeam; 37 | import fr.zcraft.zlib.components.gui.Gui; 38 | import fr.zcraft.zlib.components.i18n.I; 39 | 40 | 41 | public class TeamEditColorGUI extends TeamBuilderStepColorGUI 42 | { 43 | private final UHTeam team; 44 | 45 | public TeamEditColorGUI(UHTeam team) 46 | { 47 | this.team = team; 48 | } 49 | 50 | @Override 51 | protected void onUpdate() 52 | { 53 | /// The title of the edit team color GUI. {0} = team name (raw). 54 | setTitle(I.t("{0} » {black}Color", team.getName())); 55 | setSize(6 * 9); 56 | insertColors(2); 57 | } 58 | 59 | @Override 60 | protected void saveColor(TeamColor color) 61 | { 62 | team.setColor(color); 63 | Gui.open(getPlayer(), new TeamEditGUI(team), getParent().getParent()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/gui/teams/editor/TeamEditDeleteGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.gui.teams.editor; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.gui.teams.TeamsSelectorGUI; 36 | import eu.carrade.amaury.UHCReloaded.teams.UHTeam; 37 | import fr.zcraft.zlib.components.gui.Gui; 38 | import fr.zcraft.zlib.components.gui.GuiAction; 39 | import fr.zcraft.zlib.components.gui.GuiUtils; 40 | import fr.zcraft.zlib.components.i18n.I; 41 | import org.bukkit.DyeColor; 42 | import org.bukkit.Material; 43 | import org.bukkit.inventory.ItemStack; 44 | 45 | 46 | public class TeamEditDeleteGUI extends TeamActionGUI 47 | { 48 | public TeamEditDeleteGUI(UHTeam team) 49 | { 50 | super(team); 51 | } 52 | 53 | 54 | @Override 55 | protected void onUpdate() 56 | { 57 | /// The title of the delete team GUI. {0} = team name (raw). 58 | setTitle(I.t("{0} » {darkred}Delete", team.getName())); 59 | setSize(9); 60 | 61 | if (!exists()) 62 | { 63 | action("", 4, getDeletedItem()); 64 | return; 65 | } 66 | 67 | for (int slot = 0; slot < 3; slot++) 68 | { 69 | action("keep", slot, GuiUtils.makeItem( 70 | new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.LIME.getWoolData()), 71 | /// The title of the "keep" button in the delete team GUI 72 | I.t("{green}Keep this team alive"), 73 | null 74 | )); 75 | } 76 | 77 | action("", 4, team.getBanner()); 78 | 79 | for (int slot = 6; slot < 9; slot++) 80 | { 81 | action("delete", slot, GuiUtils.makeItem( 82 | new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.RED.getWoolData()), 83 | /// The title of the "delete" button in the delete team GUI 84 | I.t("{red}Delete this team {italic}forever"), 85 | null 86 | )); 87 | } 88 | } 89 | 90 | 91 | @GuiAction ("keep") 92 | protected void keep() 93 | { 94 | close(); 95 | } 96 | 97 | @GuiAction ("delete") 98 | protected void delete() 99 | { 100 | UHCReloaded.get().getTeamManager().removeTeam(team); 101 | Gui.open(getPlayer(), new TeamsSelectorGUI()); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.integration; 34 | 35 | import com.comphenix.protocol.ProtocolLibrary; 36 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 37 | import eu.carrade.amaury.UHCReloaded.UHConfig; 38 | import eu.carrade.amaury.UHCReloaded.listeners.PacketsListener; 39 | import fr.zcraft.zlib.tools.PluginLogger; 40 | 41 | 42 | public class UHProtocolLibIntegration 43 | { 44 | public UHProtocolLibIntegration(UHCReloaded p) 45 | { 46 | PacketsListener packetsListener = new PacketsListener(p); 47 | 48 | if (UHConfig.HARDCORE_HEARTS.DISPLAY.get()) 49 | { 50 | ProtocolLibrary.getProtocolManager().addPacketListener(packetsListener); 51 | } 52 | 53 | if (UHConfig.AUTO_RESPAWN.DO.get()) 54 | { 55 | p.getServer().getPluginManager().registerEvents(packetsListener, p); 56 | } 57 | 58 | PluginLogger.info("Successfully hooked into ProtocolLib."); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHProtocolLibIntegrationWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.integration; 34 | 35 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 36 | import eu.carrade.amaury.UHCReloaded.UHConfig; 37 | import fr.zcraft.zlib.components.configuration.ConfigurationItem; 38 | import fr.zcraft.zlib.tools.PluginLogger; 39 | import org.bukkit.Bukkit; 40 | import org.bukkit.plugin.Plugin; 41 | 42 | import java.util.List; 43 | import java.util.stream.Collectors; 44 | import java.util.stream.Stream; 45 | 46 | 47 | public class UHProtocolLibIntegrationWrapper 48 | { 49 | 50 | private UHCReloaded p = null; 51 | private UHProtocolLibIntegration integration = null; 52 | 53 | public UHProtocolLibIntegrationWrapper(UHCReloaded p) 54 | { 55 | this.p = p; 56 | 57 | // Needed to avoid a NoClassDefFoundError. 58 | // I don't like this way of doing this, but else, the plugin will not load without ProtocolLib. 59 | 60 | Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("ProtocolLib"); 61 | if (pl != null && pl.isEnabled()) 62 | { 63 | try 64 | { 65 | integration = new UHProtocolLibIntegration(p); 66 | } 67 | catch (NoClassDefFoundError e) 68 | { 69 | PluginLogger.error("ProtocolLib is present but cannot be loaded (outdated?), so the integration was disabled.", e); 70 | } 71 | } 72 | else 73 | { 74 | PluginLogger.warning("ProtocolLib is not present, so the integration was disabled."); 75 | } 76 | } 77 | 78 | /** 79 | * Returns true if ProtocolLib is installed and integrated into the plugin. 80 | */ 81 | public boolean isProtocolLibIntegrationEnabled() 82 | { 83 | return (this.integration != null); 84 | } 85 | 86 | /** 87 | * Checks if there are some enabled option which require ProtocolLib. 88 | * 89 | * @return A list of enabled options which requires ProtocolLib, or null 90 | * if there isn't any enabled option that requires ProtocolLib. 91 | */ 92 | public List<String> isProtocolLibNeeded() 93 | { 94 | final List<String> enabledOptions = Stream.of(UHConfig.HARDCORE_HEARTS.DISPLAY, UHConfig.AUTO_RESPAWN.DO) 95 | .filter(ConfigurationItem::get) 96 | .map(ConfigurationItem::getFieldName) 97 | .collect(Collectors.toList()); 98 | 99 | return enabledOptions.size() != 0 ? enabledOptions : null; 100 | } 101 | 102 | /** 103 | * Returns the wrapped integration. 104 | */ 105 | public UHProtocolLibIntegration getIntegration() 106 | { 107 | return integration; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHSpectatorPlusIntegration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.integration; 34 | 35 | import com.pgcraft.spectatorplus.SpectateAPI; 36 | import com.pgcraft.spectatorplus.SpectatorPlus; 37 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 38 | import fr.zcraft.zlib.tools.PluginLogger; 39 | import org.bukkit.Bukkit; 40 | import org.bukkit.plugin.Plugin; 41 | 42 | 43 | public class UHSpectatorPlusIntegration 44 | { 45 | private SpectatorPlus sp = null; 46 | private SpectateAPI spAPI = null; 47 | 48 | public UHSpectatorPlusIntegration() 49 | { 50 | Plugin spTest = Bukkit.getServer().getPluginManager().getPlugin("SpectatorPlus"); 51 | if (spTest == null || !spTest.isEnabled()) 52 | { 53 | UHCReloaded.get().getLogger().warning("SpectatorPlus is not present, so the integration was disabled."); 54 | return; 55 | } 56 | 57 | this.sp = (SpectatorPlus) spTest; 58 | 59 | 60 | try 61 | { 62 | Class.forName("com.pgcraft.spectatorplus.SpectateAPI"); 63 | 64 | if (sp.getDescription().getVersion().equals("1.9.1")) 65 | { 66 | // The API of SpectatorPlus 1.9.1 was not working. 67 | throw new ClassNotFoundException(); 68 | } 69 | } 70 | catch (ClassNotFoundException e) 71 | { 72 | PluginLogger.warning("SpectatorPlus is available, but the version you are using is too old."); 73 | PluginLogger.warning("This plugin is tested and works with SpectatorPlus 1.9.2 or later. The SpectateAPI is needed."); 74 | 75 | this.sp = null; 76 | return; 77 | } 78 | 79 | 80 | // All is OK, let's integrate. 81 | try 82 | { 83 | spAPI = sp.getAPI(); 84 | 85 | PluginLogger.info("Successfully hooked into SpectatorPlus."); 86 | } 87 | 88 | // Generic catch block to catch any kind of exception (logged, anyway), including e.g. 89 | // NoSuchMethodError, if the API change, so the plugin is not broken. 90 | catch (Throwable e) 91 | { 92 | PluginLogger.error("Cannot hook into SpectatorPlus, is this version compatible?", e); 93 | 94 | spAPI = null; 95 | sp = null; 96 | } 97 | } 98 | 99 | public boolean isSPIntegrationEnabled() 100 | { 101 | return !(this.sp == null); 102 | } 103 | 104 | public SpectatorPlus getSP() 105 | { 106 | return this.sp; 107 | } 108 | 109 | public SpectateAPI getSPAPI() 110 | { 111 | return this.spAPI; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/integration/UHWorldBorderIntegration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.integration; 34 | 35 | import com.wimbli.WorldBorder.WorldBorder; 36 | import fr.zcraft.zlib.tools.PluginLogger; 37 | import org.bukkit.Bukkit; 38 | import org.bukkit.plugin.Plugin; 39 | 40 | 41 | public class UHWorldBorderIntegration 42 | { 43 | private WorldBorder wb = null; 44 | 45 | public UHWorldBorderIntegration() 46 | { 47 | Plugin wbTest = Bukkit.getServer().getPluginManager().getPlugin("WorldBorder"); 48 | if (wbTest == null || !wbTest.isEnabled()) 49 | { 50 | PluginLogger.warning("WorldBorder is not present, so the integration was disabled."); 51 | return; 52 | } 53 | 54 | this.wb = (WorldBorder) wbTest; 55 | 56 | try 57 | { 58 | Class.forName("com.wimbli.WorldBorder.BorderData"); 59 | Class.forName("com.wimbli.WorldBorder.Config"); 60 | } 61 | catch (ClassNotFoundException e) 62 | { 63 | PluginLogger.warning("WorldBorder is available, but the version you are using is too old."); 64 | PluginLogger.warning("This plugin is tested and works with WorldBorder 1.8.0 or later."); 65 | 66 | this.wb = null; 67 | return; 68 | } 69 | 70 | PluginLogger.info("Successfully hooked into WorldBorder."); 71 | } 72 | 73 | public boolean isWBIntegrationEnabled() 74 | { 75 | return !(this.wb == null); 76 | } 77 | 78 | public WorldBorder getWorldBorder() 79 | { 80 | return wb; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/listeners/PacketsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.listeners; 34 | 35 | import com.comphenix.protocol.PacketType; 36 | import com.comphenix.protocol.ProtocolLibrary; 37 | import com.comphenix.protocol.ProtocolManager; 38 | import com.comphenix.protocol.events.ListenerPriority; 39 | import com.comphenix.protocol.events.PacketAdapter; 40 | import com.comphenix.protocol.events.PacketContainer; 41 | import com.comphenix.protocol.events.PacketEvent; 42 | import com.comphenix.protocol.wrappers.EnumWrappers; 43 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 44 | import eu.carrade.amaury.UHCReloaded.UHConfig; 45 | import fr.zcraft.zlib.tools.runners.RunTask; 46 | import org.bukkit.event.EventHandler; 47 | import org.bukkit.event.Listener; 48 | import org.bukkit.event.entity.PlayerDeathEvent; 49 | 50 | import java.lang.reflect.InvocationTargetException; 51 | 52 | 53 | public class PacketsListener extends PacketAdapter implements Listener 54 | { 55 | private UHCReloaded p; 56 | private ProtocolManager pm = ProtocolLibrary.getProtocolManager(); 57 | 58 | private final PacketContainer respawnPacket; 59 | 60 | public PacketsListener(UHCReloaded p) 61 | { 62 | // This listener needs to listen on login packets only. 63 | super(UHCReloaded.get(), ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN); 64 | 65 | this.p = UHCReloaded.get(); 66 | 67 | // The packet to send to automatically respawn the player. 68 | respawnPacket = pm.createPacket(PacketType.Play.Client.CLIENT_COMMAND); 69 | respawnPacket.getClientCommands().write(0, EnumWrappers.ClientCommand.PERFORM_RESPAWN); 70 | } 71 | 72 | /** 73 | * Used to present the server as an hardcore server, for the clients to display hardcore hearts. 74 | */ 75 | @Override 76 | public void onPacketSending(PacketEvent ev) 77 | { 78 | // If its a login packet, write the hardcore flag (first boolean) to true. 79 | if (ev.getPacketType().equals(PacketType.Play.Server.LOGIN)) 80 | { 81 | ev.getPacket().getBooleans().write(0, true); 82 | } 83 | } 84 | 85 | /** 86 | * Used to automatically respawn the dead players. 87 | */ 88 | @EventHandler 89 | public void onPlayerDeath(final PlayerDeathEvent ev) 90 | { 91 | if (UHConfig.AUTO_RESPAWN.DO.get()) 92 | { 93 | RunTask.later(() -> 94 | { 95 | try 96 | { 97 | pm.recieveClientPacket(ev.getEntity(), respawnPacket); 98 | } 99 | catch (IllegalAccessException | InvocationTargetException e) 100 | { 101 | e.printStackTrace(); 102 | } 103 | }, UHConfig.AUTO_RESPAWN.DELAY.get() * 20L); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/protips/ProTips.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.protips; 33 | 34 | import fr.zcraft.zlib.components.i18n.I; 35 | import org.bukkit.entity.Player; 36 | 37 | import java.util.UUID; 38 | 39 | 40 | public enum ProTips 41 | { 42 | LOCK_CHAT(new ProTip("teamchat.lock", I.tc("protip", "{gray}You can lock and unlock the team chat with {cc}/togglechat{gray}."))), 43 | USE_G_COMMAND(new ProTip("teamchat.useGCommand", I.tc("protip", "{gray}You can send a global message using {cc}/g <message>{gray}."))), 44 | USE_T_COMMAND(new ProTip("teamchat.useTCommand", I.tc("protip", "{gray}You can send a team-chat message with {cc}/t <message>{gray}."))), 45 | 46 | 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)."))), 47 | 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."))), 48 | 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."))), 49 | 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."))), 50 | CRAFT_GLISTERING_MELON(new ProTip("crafts.glisteringMelon", I.tc("protip", "{gray}The glistering melon is crafted with a melon and a gold block."))), 51 | 52 | CRAFT_NO_ENCHANTED_GOLDEN_APPLE(new ProTip("crafts.noEnchGoldenApple", I.tc("protip", "{gray}The enchanted golden apple is disabled for this game."))), 53 | 54 | STARTUP_INVINCIBILITY(new ProTip("start.invincibility", I.tc("protip", "{gray}Fallen on a tree? Jump, you have a few seconds left to remain invincible."))); 55 | 56 | 57 | private final ProTip proTip; 58 | 59 | ProTips(ProTip proTip) 60 | { 61 | this.proTip = proTip; 62 | } 63 | 64 | public ProTip get() 65 | { 66 | return proTip; 67 | } 68 | 69 | 70 | /** 71 | * Sends this ProTip, if it wasn't sent before to this player. 72 | * 73 | * @param player The receiver of this ProTip. 74 | */ 75 | public void sendTo(Player player) 76 | { 77 | proTip.sendTo(player); 78 | } 79 | 80 | /** 81 | * Sends this ProTip, if it wasn't sent before to this player and this player is online. 82 | * 83 | * @param id The receiver of this ProTip. 84 | */ 85 | public void sendTo(UUID id) 86 | { 87 | proTip.sendTo(id); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/CannotGenerateSpawnPointsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.spawns.exceptions; 34 | 35 | 36 | public class CannotGenerateSpawnPointsException extends Exception 37 | { 38 | 39 | public CannotGenerateSpawnPointsException(String message) 40 | { 41 | super(message); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spawns/exceptions/UnknownGeneratorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.spawns.exceptions; 33 | 34 | public class UnknownGeneratorException extends Exception 35 | { 36 | 37 | public UnknownGeneratorException(String message) 38 | { 39 | super(message); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spawns/generators/SpawnPointsGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.spawns.generators; 33 | 34 | import eu.carrade.amaury.UHCReloaded.spawns.exceptions.CannotGenerateSpawnPointsException; 35 | import org.bukkit.Location; 36 | import org.bukkit.World; 37 | 38 | import java.util.Set; 39 | 40 | 41 | /** 42 | * Represents a spawn points generator. 43 | * 44 | * <p> 45 | * A zero-arguments constructor is needed. 46 | * </p> 47 | */ 48 | public interface SpawnPointsGenerator 49 | { 50 | /** 51 | * Generates the spawn points. 52 | * 53 | * @param world The world where the spawn points will be generated. 54 | * @param spawnCount The number of spawn points to generate. 55 | * @param regionDiameter The diameter of the region where the spawn points will be generated.<br> 56 | * This is limited by the size of the map. This will be seen as the diameter of a circular or 57 | * of a squared map, following the shape of the world set in the configuration. 58 | * @param minimalDistanceBetweenTwoPoints The minimal distance between two points. 59 | * @param xCenter The x coordinate of the point in the center of the region where the points will be generated. 60 | * @param zCenter The z coordinate of the point in the center of the region where the points will be generated. 61 | * @param avoidWater True if the generation have to avoid the water. 62 | * 63 | * @return The spawn points generated. 64 | * 65 | * @throws CannotGenerateSpawnPointsException In case of fail. 66 | */ 67 | 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; 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SPlusSpectatorsManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.spectators; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import org.bukkit.entity.Player; 36 | 37 | 38 | /** 39 | * Spectators managed through the SpectatorsPlus Bukkit plugin by PGMann and AmauryPi. 40 | */ 41 | public class SPlusSpectatorsManager extends SpectatorsManager 42 | { 43 | private UHCReloaded p; 44 | 45 | public SPlusSpectatorsManager() 46 | { 47 | p = UHCReloaded.get(); 48 | } 49 | 50 | @Override 51 | public void setSpectating(final Player player, final boolean spectating) 52 | { 53 | if (player != null && p.getSpectatorPlusIntegration().isSPIntegrationEnabled()) 54 | p.getSpectatorPlusIntegration().getSPAPI().setSpectating(player, spectating); 55 | } 56 | 57 | @Override 58 | public boolean isSpectating(Player player) 59 | { 60 | return player != null 61 | && p.getSpectatorPlusIntegration().isSPIntegrationEnabled() 62 | && p.getSpectatorPlusIntegration().getSPAPI().isSpectator(player); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spectators/SpectatorsManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.spectators; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import org.bukkit.Bukkit; 36 | import org.bukkit.entity.Player; 37 | 38 | import java.util.UUID; 39 | 40 | 41 | /** 42 | * Represents a spectator manager, able to put players in or remove players from spectator mode. 43 | */ 44 | public abstract class SpectatorsManager 45 | { 46 | /** 47 | * Changes the spectating mode of a player. 48 | * 49 | * @param player The player. 50 | * @param spectating {@code true} to enable the spectator mode; {@code false} to disable it. 51 | */ 52 | public abstract void setSpectating(final Player player, final boolean spectating); 53 | 54 | /** 55 | * Checks if the given player is currently spectating. 56 | * 57 | * @param player The player. 58 | * 59 | * @return {@code true} if spectating. 60 | */ 61 | public abstract boolean isSpectating(final Player player); 62 | 63 | /** 64 | * Changes the spectating mode of a player. 65 | * 66 | * @param playerID The player's UUID. 67 | * @param spectating {@code true} to enable the spectator mode; {@code false} to disable it. 68 | */ 69 | public void setSpectating(final UUID playerID, final boolean spectating) 70 | { 71 | setSpectating(Bukkit.getPlayer(playerID), spectating); 72 | } 73 | 74 | /** 75 | * Checks if the given player is currently spectating. 76 | * 77 | * @param playerID The player's UUID. 78 | * 79 | * @return {@code true} if spectating. 80 | */ 81 | public boolean isSpectating(final UUID playerID) 82 | { 83 | return isSpectating(Bukkit.getPlayer(playerID)); 84 | } 85 | 86 | 87 | /** 88 | * @return an instance of a {@link SpectatorsManager}: {@link SPlusSpectatorsManager} if the 89 | * SpectatorPlus plugin is available; {@link VanillaSpectatorsManager} else. 90 | */ 91 | public static SpectatorsManager getInstance() 92 | { 93 | if (UHCReloaded.get().getSpectatorPlusIntegration().isSPIntegrationEnabled()) 94 | return new SPlusSpectatorsManager(); 95 | else 96 | return new VanillaSpectatorsManager(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/spectators/VanillaSpectatorsManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.spectators; 33 | 34 | 35 | import org.bukkit.Bukkit; 36 | import org.bukkit.GameMode; 37 | import org.bukkit.entity.Player; 38 | 39 | import java.util.HashMap; 40 | import java.util.Map; 41 | import java.util.UUID; 42 | 43 | 44 | /** 45 | * Vanilla spectator mode 46 | */ 47 | public class VanillaSpectatorsManager extends SpectatorsManager 48 | { 49 | /** 50 | * Stores the previous gamemodes of the players. 51 | */ 52 | private Map<UUID, GameMode> oldGameModes = new HashMap<>(); 53 | 54 | 55 | @Override 56 | public void setSpectating(final Player player, final boolean spectating) 57 | { 58 | if (player == null) 59 | return; 60 | 61 | if (spectating) 62 | { 63 | if (player.getGameMode() != GameMode.SPECTATOR) 64 | { 65 | oldGameModes.put(player.getUniqueId(), player.getGameMode()); 66 | player.setGameMode(GameMode.SPECTATOR); 67 | } 68 | } 69 | else 70 | { 71 | GameMode previousMode = oldGameModes.get(player.getUniqueId()); 72 | player.setGameMode(previousMode != null ? previousMode : Bukkit.getDefaultGameMode()); 73 | 74 | oldGameModes.remove(player.getUniqueId()); 75 | } 76 | } 77 | 78 | @Override 79 | public boolean isSpectating(Player player) 80 | { 81 | return player != null && player.getGameMode() == GameMode.SPECTATOR; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/task/BorderWarningTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.task; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.borders.MapShape; 36 | import fr.zcraft.zlib.components.i18n.I; 37 | import org.bukkit.entity.Player; 38 | import org.bukkit.scheduler.BukkitRunnable; 39 | 40 | 41 | public class BorderWarningTask extends BukkitRunnable 42 | { 43 | private final UHCReloaded p; 44 | 45 | public BorderWarningTask() 46 | { 47 | this.p = UHCReloaded.get(); 48 | } 49 | 50 | @Override 51 | public void run() 52 | { 53 | if (p.getFreezer().getGlobalFreezeState()) 54 | { 55 | return; // No messages are sent if the game is frozen. 56 | } 57 | 58 | // Message sent to all players outside the border 59 | for (Player player : p.getBorderManager().getPlayersOutside(p.getBorderManager().getWarningSize())) 60 | { 61 | double distance = p.getBorderManager().getDistanceToBorder(player.getLocation(), p.getBorderManager().getWarningSize()); 62 | 63 | if (p.getBorderManager().getMapShape() == MapShape.CIRCULAR) 64 | { 65 | 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())); 66 | } 67 | else 68 | { 69 | player.sendMessage(I.t("{ce}You are currently out of the future border of {0}×{0} blocks.", p.getBorderManager().getWarningSize())); 70 | } 71 | 72 | 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)); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/task/FireworksOnWinnersTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.task; 34 | 35 | import eu.carrade.amaury.UHCReloaded.UHConfig; 36 | import eu.carrade.amaury.UHCReloaded.utils.UHUtils; 37 | import org.bukkit.Location; 38 | import org.bukkit.OfflinePlayer; 39 | import org.bukkit.entity.Player; 40 | import org.bukkit.scheduler.BukkitRunnable; 41 | 42 | import java.util.Random; 43 | import java.util.Set; 44 | 45 | 46 | public class FireworksOnWinnersTask extends BukkitRunnable 47 | { 48 | private final Set<OfflinePlayer> winners; 49 | 50 | private Double areaSize; 51 | private Random rand; 52 | 53 | private long startTime; 54 | 55 | public FireworksOnWinnersTask(final Set<OfflinePlayer> listWinners) 56 | { 57 | this.winners = listWinners; 58 | 59 | this.areaSize = UHConfig.FINISH.FIREWORKS.AREA_SIZE.get(); 60 | this.rand = new Random(); 61 | 62 | this.startTime = System.currentTimeMillis(); 63 | } 64 | 65 | @Override 66 | public void run() 67 | { 68 | // The fireworks are launched in a square centered on the player. 69 | final double halfAreaSize = areaSize / 2; 70 | 71 | for (final OfflinePlayer winner : winners) 72 | { 73 | if (winner.isOnline()) 74 | { 75 | Location fireworkLocation = ((Player) winner).getLocation(); 76 | 77 | fireworkLocation.add(rand.nextDouble() * areaSize - halfAreaSize, // a number between -halfAreaSize and halfAreaSize 78 | 2, // y+2 for a clean vision of the winner. 79 | rand.nextDouble() * areaSize - halfAreaSize); 80 | 81 | UHUtils.generateRandomFirework(fireworkLocation.add(0.2, 0d, 0.2), 5, 15); 82 | UHUtils.generateRandomFirework(fireworkLocation.add(-0.2, 0d, 0.2), 5, 15); 83 | } 84 | } 85 | 86 | if ((System.currentTimeMillis() - startTime) / 1000 > UHConfig.FINISH.FIREWORKS.DURATION.get()) 87 | { 88 | this.cancel(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/task/ScheduledCommandsExecutorTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | 33 | package eu.carrade.amaury.UHCReloaded.task; 34 | 35 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 36 | import fr.zcraft.zlib.tools.PluginLogger; 37 | import org.bukkit.command.CommandException; 38 | 39 | import java.util.HashSet; 40 | 41 | 42 | /** 43 | * Schedules a stack of commands executed at the same time. 44 | */ 45 | public class ScheduledCommandsExecutorTask implements Runnable 46 | { 47 | private final UHCReloaded p; 48 | private final HashSet<String> commands; 49 | 50 | public ScheduledCommandsExecutorTask(HashSet<String> commands) 51 | { 52 | this.p = UHCReloaded.get(); 53 | this.commands = commands; 54 | } 55 | 56 | @Override 57 | public void run() 58 | { 59 | for (final String command : commands) 60 | { 61 | try 62 | { 63 | p.getServer().dispatchCommand(p.getServer().getConsoleSender(), command); 64 | } 65 | catch (CommandException e) 66 | { 67 | PluginLogger.error("The scheduled command '{0}' failed.", e, command); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/task/UpdateTimerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.task; 33 | 34 | import eu.carrade.amaury.UHCReloaded.UHCReloaded; 35 | import eu.carrade.amaury.UHCReloaded.timers.UHTimer; 36 | import org.bukkit.scheduler.BukkitRunnable; 37 | 38 | 39 | public class UpdateTimerTask extends BukkitRunnable 40 | { 41 | @Override 42 | public void run() 43 | { 44 | for (UHTimer timer : UHCReloaded.get().getTimerManager().getRunningTimers()) 45 | { 46 | timer.update(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/utils/ColorsUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.utils; 33 | 34 | import org.bukkit.ChatColor; 35 | import org.bukkit.DyeColor; 36 | 37 | 38 | public final class ColorsUtils 39 | { 40 | private ColorsUtils() {} 41 | 42 | public static DyeColor chat2Dye(ChatColor chatColor) 43 | { 44 | switch (chatColor) 45 | { 46 | case BLACK: 47 | return DyeColor.BLACK; 48 | 49 | case BLUE: 50 | case DARK_BLUE: 51 | return DyeColor.BLUE; 52 | 53 | case DARK_GREEN: 54 | return DyeColor.GREEN; 55 | 56 | case DARK_AQUA: 57 | return DyeColor.CYAN; 58 | 59 | case DARK_RED: 60 | return DyeColor.RED; 61 | 62 | case DARK_PURPLE: 63 | return DyeColor.PURPLE; 64 | 65 | case GOLD: 66 | case YELLOW: 67 | return DyeColor.YELLOW; 68 | 69 | case GRAY: 70 | case DARK_GRAY: 71 | return DyeColor.SILVER; 72 | 73 | case GREEN: 74 | return DyeColor.LIME; 75 | 76 | case AQUA: 77 | return DyeColor.LIGHT_BLUE; 78 | 79 | case RED: 80 | return DyeColor.ORANGE; 81 | 82 | case LIGHT_PURPLE: 83 | return DyeColor.PINK; 84 | 85 | // White, reset & formatting 86 | default: 87 | return DyeColor.WHITE; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/eu/carrade/amaury/UHCReloaded/utils/OfflinePlayersComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright or © or Copr. Amaury Carrade (2014 - 2016) 3 | * 4 | * http://amaury.carrade.eu 5 | * 6 | * This software is governed by the CeCILL-B license under French law and 7 | * abiding by the rules of distribution of free software. You can use, 8 | * modify and/ or redistribute the software under the terms of the CeCILL-B 9 | * license as circulated by CEA, CNRS and INRIA at the following URL 10 | * "http://www.cecill.info". 11 | * 12 | * As a counterpart to the access to the source code and rights to copy, 13 | * modify and redistribute granted by the license, users are provided only 14 | * with a limited warranty and the software's author, the holder of the 15 | * economic rights, and the successive licensors have only limited 16 | * liability. 17 | * 18 | * In this respect, the user's attention is drawn to the risks associated 19 | * with loading, using, modifying and/or developing or reproducing the 20 | * software by the user in light of its specific status of free software, 21 | * that may mean that it is complicated to manipulate, and that also 22 | * therefore means that it is reserved for developers and experienced 23 | * professionals having in-depth computer knowledge. Users are therefore 24 | * encouraged to load and test the software's suitability as regards their 25 | * requirements in conditions enabling the security of their systems and/or 26 | * data to be ensured and, more generally, to use and operate it in the 27 | * same conditions as regards security. 28 | * 29 | * The fact that you are presently reading this means that you have had 30 | * knowledge of the CeCILL-B license and that you accept its terms. 31 | */ 32 | package eu.carrade.amaury.UHCReloaded.utils; 33 | 34 | import org.bukkit.OfflinePlayer; 35 | 36 | import java.util.Comparator; 37 | 38 | 39 | public class OfflinePlayersComparator implements Comparator<OfflinePlayer> 40 | { 41 | @Override 42 | public int compare(OfflinePlayer player1, OfflinePlayer player2) 43 | { 44 | if (player1.isOnline() == player2.isOnline()) 45 | return player1.getName().toLowerCase().compareTo(player2.getName().toLowerCase()); 46 | else if (player1.isOnline()) 47 | return -1; 48 | else 49 | return 1; 50 | } 51 | } 52 | --------------------------------------------------------------------------------