From 1efdf717b5d8d4b69851c6bbeb60f04014445fd8 Mon Sep 17 00:00:00 2001 From: Jascha Starke Date: Wed, 2 Mar 2016 19:57:25 +0100 Subject: [PATCH] Incomplete Spectator-Support --- .../minecraft/limitedcreative/FeatureSwitchGameMode.java | 8 ++++++++ .../limitedcreative/SwitchGameModePermissions.java | 5 +++++ src/main/resources/lang/messages.properties | 1 + src/main/resources/lang/messages_de.properties | 1 + 4 files changed, 15 insertions(+) diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java index f038293..61eef00 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java @@ -138,6 +138,14 @@ public class FeatureSwitchGameMode extends CoreModule { public boolean adventure(CommandContext context, String player) throws MissingPermissionCommandException, CommandException { return changeGameMode(context, player, GameMode.ADVENTURE, SwitchGameModePermissions.ADVENTURE); } + @IsCommand("spectator") + @Alias("sp") + @Description(value = "command.switch.spectator", translate = true) + @NeedsPermission(value={"spectator", "backonly"}, optional = true) + @Usages("[player]") + public boolean spectator(CommandContext context, String player) throws MissingPermissionCommandException, CommandException { + return changeGameMode(context, player, GameMode.SPECTATOR, SwitchGameModePermissions.SPECTATOR); + } @Override public List getTabCompleter(MethodCommand cmd) { diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/SwitchGameModePermissions.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/SwitchGameModePermissions.java index 015e15a..3739611 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/SwitchGameModePermissions.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/SwitchGameModePermissions.java @@ -46,6 +46,11 @@ public class SwitchGameModePermissions extends ParentPermissionContainerNode { */ @IsChildPermission public final static BasicPermission ADVENTURE = new BasicPermission(ALL, "adventure", PermissionDefault.FALSE); + /** + * Allows switching of own game mode to spectator, but not to creative/survival/adventure + */ + @IsChildPermission + public final static BasicPermission SPECTATOR = new BasicPermission(ALL, "spectator", PermissionDefault.FALSE); /** * Allows switching of other users game mode diff --git a/src/main/resources/lang/messages.properties b/src/main/resources/lang/messages.properties index fd88c9c..556128d 100644 --- a/src/main/resources/lang/messages.properties +++ b/src/main/resources/lang/messages.properties @@ -11,6 +11,7 @@ command.regions: LimitedCreative-Region-Command: configure creative regions command.switch.survival: Changes the game mode of a player to survival command.switch.creative: Changes the game mode of a player to creative command.switch.adventure: Changes the game mode of a player to adventure +command.switch.spectator: Changes the game mode of a player to spectator command.config.reload: Reloads configuration and re-initializes all active modules. command.config.reload.success: The plugin was successfully reloaded. command.gamemode.changed: {0}''s game mode has been changed diff --git a/src/main/resources/lang/messages_de.properties b/src/main/resources/lang/messages_de.properties index d0b2f30..1e1ae2f 100644 --- a/src/main/resources/lang/messages_de.properties +++ b/src/main/resources/lang/messages_de.properties @@ -11,6 +11,7 @@ command.regions: LimitedCreative-Region-Kommando: Kreativ-Regionen konfigurieren command.switch.survival: Ändert den Spielmodus des Spielers zu Überleben command.switch.creative: Ändert den Spielmodus des Spielers zu Kreativ command.switch.adventure: Ändert den Spielmodus des Spielers zu Abenteuer +command.switch.spectator: Ändert den Spielmodus des Spielers zu Beobachter command.config.reload: Lädt die Konfiguration neu und initialisiert alle Module neu command.config.reload.success: Das Plugin wurde erfolgreich neu geladen command.gamemode.changed: {0}''s GameMode wurde geändert