Allow event hosts to use /game

This commit is contained in:
cnr 2017-09-01 23:14:26 -05:00
parent acae54f021
commit b860a69d46
5 changed files with 46 additions and 20 deletions

View File

@ -179,9 +179,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
KIT_UNLOCK_COMMAND, KIT_UNLOCK_COMMAND,
TAUNT_COMMAND, TAUNT_COMMAND,
GAME_COMMAND, GAME_COMMAND,
SET_GAME_COMMAND,
START_GAME_COMMAND,
STOP_GAME_COMMAND,
AUTO_OP, AUTO_OP,
KIT_ACCESS, KIT_ACCESS,
FEATURED_SERVER, FEATURED_SERVER,
@ -627,19 +624,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
PermissionGroup.CONTENT.setPermission(Perm.KIT_UNLOCK_COMMAND, true, true); PermissionGroup.CONTENT.setPermission(Perm.KIT_UNLOCK_COMMAND, true, true);
PermissionGroup.PLAYER.setPermission(Perm.TAUNT_COMMAND, true, true); PermissionGroup.PLAYER.setPermission(Perm.TAUNT_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.GAME_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.GAME_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.SET_GAME_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.START_GAME_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.STOP_GAME_COMMAND, true, true);
if (UtilServer.isTestServer()) if (UtilServer.isTestServer())
{ {
PermissionGroup.QA.setPermission(Perm.GAME_COMMAND, true, true); PermissionGroup.QA.setPermission(Perm.GAME_COMMAND, true, true);
PermissionGroup.QA.setPermission(Perm.SET_GAME_COMMAND, true, true);
PermissionGroup.QA.setPermission(Perm.START_GAME_COMMAND, true, true);
PermissionGroup.QA.setPermission(Perm.STOP_GAME_COMMAND, true, true);
PermissionGroup.MAPLEAD.setPermission(Perm.GAME_COMMAND, false, true); PermissionGroup.MAPLEAD.setPermission(Perm.GAME_COMMAND, false, true);
PermissionGroup.MAPLEAD.setPermission(Perm.SET_GAME_COMMAND, false, true);
PermissionGroup.MAPLEAD.setPermission(Perm.START_GAME_COMMAND, false, true);
PermissionGroup.MAPLEAD.setPermission(Perm.STOP_GAME_COMMAND, false, true);
} }
if (UtilServer.isTestServer() || UtilServer.isDevServer()) if (UtilServer.isTestServer() || UtilServer.isDevServer())
{ {
@ -925,6 +913,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return true; return true;
} }
public boolean canPlayerUseGameCmd(Player player)
{
if (!GetClients().Get(player).hasPermission(Perm.GAME_COMMAND) && !(_gameHostManager.isEventServer() && _gameHostManager.isAdmin(player, false)))
{
player.sendMessage(F.main("Game", "You are not allowed to use game commands."));
return false;
}
return true;
}
@EventHandler @EventHandler
public void StaffIncognito(IncognitoStatusChangeEvent event) public void StaffIncognito(IncognitoStatusChangeEvent event)
{ {

View File

@ -3,6 +3,8 @@ package nautilus.game.arcade.command;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.command.MultiCommandBase; import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -14,17 +16,26 @@ import static nautilus.game.arcade.command.SetCommand.SOURCE_PREFIX;
public class GameCommand extends MultiCommandBase<ArcadeManager> public class GameCommand extends MultiCommandBase<ArcadeManager>
{ {
public enum Perm implements Permission
{
GAME_COMMAND_DUMMY_PERM,
}
public GameCommand(ArcadeManager plugin) public GameCommand(ArcadeManager plugin)
{ {
super(plugin, ArcadeManager.Perm.GAME_COMMAND, "game"); super(plugin, Perm.GAME_COMMAND_DUMMY_PERM, "game");
AddCommand(new StartCommand(Plugin)); AddCommand(new StartCommand(Plugin));
AddCommand(new StopCommand(Plugin)); AddCommand(new StopCommand(Plugin));
AddCommand(new SetCommand(Plugin)); AddCommand(new SetCommand(Plugin));
PermissionGroup.PLAYER.setPermission(Perm.GAME_COMMAND_DUMMY_PERM, true, true);
} }
@Override @Override
protected void Help(Player caller, String[] args) protected void Help(Player caller, String[] args)
{
if (!Plugin.canPlayerUseGameCmd(caller))
{ {
UtilPlayer.message(caller, F.main("Game", "Available Commands")); UtilPlayer.message(caller, F.main("Game", "Available Commands"));
UtilPlayer.message(caller, F.help("/game start", "Start the current game", ChatColor.DARK_RED)); UtilPlayer.message(caller, F.help("/game start", "Start the current game", ChatColor.DARK_RED));
@ -32,3 +43,4 @@ public class GameCommand extends MultiCommandBase<ArcadeManager>
caller.sendMessage(F.help(String.format("/game set <gametype> [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED)); caller.sendMessage(F.help(String.format("/game set <gametype> [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED));
} }
} }
}

View File

@ -26,12 +26,17 @@ public class SetCommand extends CommandBase<ArcadeManager>
public SetCommand(ArcadeManager plugin) public SetCommand(ArcadeManager plugin)
{ {
super(plugin, ArcadeManager.Perm.SET_GAME_COMMAND, "set"); super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "set");
} }
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (!Plugin.canPlayerUseGameCmd(caller))
{
return;
}
if (Plugin.GetGame() == null) if (Plugin.GetGame() == null)
return; return;

View File

@ -13,12 +13,17 @@ public class StartCommand extends CommandBase<ArcadeManager>
{ {
public StartCommand(ArcadeManager plugin) public StartCommand(ArcadeManager plugin)
{ {
super(plugin, ArcadeManager.Perm.START_GAME_COMMAND, "start"); super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "start");
} }
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (!Plugin.canPlayerUseGameCmd(caller))
{
return;
}
if (Plugin.GetGame() == null || Plugin.GetGame().GetState() == GameState.Loading) if (Plugin.GetGame() == null || Plugin.GetGame().GetState() == GameState.Loading)
{ {
UtilPlayer.message(caller, F.main("Game", "The game is currently loading, it cannot be started!")); UtilPlayer.message(caller, F.main("Game", "The game is currently loading, it cannot be started!"));

View File

@ -14,12 +14,17 @@ public class StopCommand extends CommandBase<ArcadeManager>
{ {
public StopCommand(ArcadeManager plugin) public StopCommand(ArcadeManager plugin)
{ {
super(plugin, ArcadeManager.Perm.STOP_GAME_COMMAND, "stop"); super(plugin, GameCommand.Perm.GAME_COMMAND_DUMMY_PERM, "stop");
} }
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (!Plugin.canPlayerUseGameCmd(caller))
{
return;
}
if (Plugin.GetGame() == null) if (Plugin.GetGame() == null)
{ {
UtilPlayer.message(caller, F.main("Game", "There is no game to stop!")); UtilPlayer.message(caller, F.main("Game", "There is no game to stop!"));