diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java index 4c569c5..75436b7 100644 --- a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/UHRootCommand.java @@ -44,6 +44,7 @@ import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHInfosCommand; import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHKillCommand; import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHResurrectCommand; +import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHRulesCommand; import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHShiftCommand; import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHSpawnsCommand; import eu.carrade.amaury.UHCReloaded.commands.commands.uh.UHSpectatorsCommand; @@ -99,6 +100,7 @@ public UHRootCommand(UHCReloaded plugin) registerSubCommand(new UHTimersCommand(p)); registerSubCommand(new UHTPCommand(p)); registerSubCommand(new UHInfosCommand(p)); + registerSubCommand(new UHRulesCommand(p)); registerSubCommand(new UHAboutCommand(p)); } diff --git a/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java b/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java new file mode 100644 index 0000000..f2bb0a1 --- /dev/null +++ b/src/main/java/eu/carrade/amaury/UHCReloaded/commands/commands/uh/UHRulesCommand.java @@ -0,0 +1,114 @@ +/* + * Copyright or © or Copr. Amaury Carrade (2014 - 2016) + * + * http://amaury.carrade.eu + * + * This software is governed by the CeCILL-B license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-B + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-B license and that you accept its terms. + */ +package eu.carrade.amaury.UHCReloaded.commands.commands.uh; + +import eu.carrade.amaury.UHCReloaded.UHCReloaded; +import eu.carrade.amaury.UHCReloaded.commands.commands.categories.Category; +import eu.carrade.amaury.UHCReloaded.commands.core.AbstractCommand; +import eu.carrade.amaury.UHCReloaded.commands.core.annotations.Command; +import eu.carrade.amaury.UHCReloaded.commands.core.exceptions.CannotExecuteCommandException; +import eu.carrade.amaury.UHCReloaded.i18n.I18n; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Collections; +import java.util.List; + + +@Command (name = "rules") +public class UHRulesCommand extends AbstractCommand +{ + private UHCReloaded p; + private I18n i; + + public UHRulesCommand(UHCReloaded plugin) + { + p = plugin; + i = p.getI18n(); + } + + + @Override + public void run(CommandSender sender, String[] args) throws CannotExecuteCommandException + { + if (!p.getRulesManager().isEnabled()) + { + sender.sendMessage(i.t("rules.command.unset")); + return; + } + + if (args.length >= 1) + { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) + { + p.getRulesManager().displayRulesTo(player); + + if (!sender.equals(player)) + sender.sendMessage(i.t("rules.command.sent", player.getName())); + } + else + { + sender.sendMessage(i.t("rules.command.offline", args[0])); + } + } + else + { + p.getRulesManager().broadcastRules(); + } + } + + @Override + public List tabComplete(CommandSender sender, String[] args) + { + return null; + } + + @Override + public List help(CommandSender sender) + { + return null; + } + + @Override + public List onListHelp(CommandSender sender) + { + return Collections.singletonList(i.t("cmd.helpRules")); + } + + @Override + public String getCategory() + { + return Category.MISC.getTitle(); + } +} diff --git a/src/main/resources/i18n/en_US.yml b/src/main/resources/i18n/en_US.yml index 5d0b960..5be9316 100644 --- a/src/main/resources/i18n/en_US.yml +++ b/src/main/resources/i18n/en_US.yml @@ -59,6 +59,7 @@ keys: helpTP: "{cc}/uh tp {ci}: teleports the spectators or an entire team. See /uh tp for details." helpTimers: "{cc}/uh timers {ci}: manages the timers. See /uh timers for details." helpInfos: "{cc}/uh infos {ci}: prints some infos about the current game." + helpRules: "{cc}/uh rules [player] {ci}: sends the server rules to the server or the given player." helpAbout: "{cc}/uh about {ci}: informations about the plugin and the translation." startHelpTitle: "{aqua}------ Beginning of the game ------" @@ -575,3 +576,8 @@ keys: rules: header: "{red}{bold}Rules and informations" bullet: "{darkgray}- {reset}{0}" + + command: + offline: "{ce}Cannot display the rules to {0} because he (or she) is offline." + unset: "{ce}No rules are set in the config file." + sent: "{cs}Rules sent to {0}." diff --git a/src/main/resources/i18n/fr_FR.yml b/src/main/resources/i18n/fr_FR.yml index bd38fe0..3a30f70 100644 --- a/src/main/resources/i18n/fr_FR.yml +++ b/src/main/resources/i18n/fr_FR.yml @@ -59,6 +59,7 @@ keys: helpTP: "{cc}/uh tp {ci}: téléporte les spectateurs ou une équipe. Consultez /uh tp pour plus de détails." helpTimers: "{cc}/uh timers {ci}: gère les comptes à rebours. Consultez /uh timers pour plus de détails." helpInfos: "{cc}/uh infos {ci}: affiche des informations à propos du jeu en cours." + helpRules: "{cc}/uh rules [joueur] {ci}: envoie les règles du jeu au serveur ou au joueur spécifié." helpAbout: "{cc}/uh about {ci}: informations à propos du plugin et des traductions." startHelpTitle: "{aqua}------ Démarrage du jeu ------" @@ -575,3 +576,8 @@ keys: rules: header: "{red}{bold}Règles et informations" bullet: "{darkgray}- {reset}{0}" + + command: + offline: "{ce}Impossible d'afficher les règles à {0} car il ou elle est hors-ligne." + unset: "{ce}Aucune règle n'est enregistrée dans le fichier de configuration." + sent: "{cs}Les règles ont été envoyées à {0}." diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2b8a239..a1ade25 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -64,6 +64,7 @@ permissions: uh.spec: true uh.finish: true uh.infos: true + uh.rules: true uh.timers: true uh.tp: true uh.team.spy: true @@ -138,6 +139,9 @@ permissions: uh.infos: description: Allows an user to get infos about the current game with /uh infos default: true + uh.rules: + description: Allows an user to broadcast or send the rules on-demand + default: op uh.about: description: Prints some informations about the plugin and the translation. default: true