Add disabled commands

This commit is contained in:
md_5 2013-07-09 14:55:27 +10:00
parent 9adcb05d45
commit 0189ad9c17
6 changed files with 38 additions and 1 deletions

View File

@ -240,4 +240,11 @@ public abstract class ProxyServer
* @return a new {@link CustomTabList} instance
*/
public abstract CustomTabList customTabList(ProxiedPlayer player);
/**
* Gets the commands which are disabled and will not be run on this proxy.
*
* @return the set of disabled commands
*/
public abstract Collection<String> getDisabledCommands();
}

View File

@ -43,6 +43,15 @@ public interface ConfigurationAdapter
*/
public boolean getBoolean(String path, boolean def);
/**
* Get a list from the specified path.
*
* @param path the path to retrieve the list form.
* @param def the default value
* @return the retrieved list
*/
public Collection<?> getList(String path, Collection<?> def);
/**
* Get the configuration all servers which may be accessible via the proxy.
*

View File

@ -86,7 +86,12 @@ public class PluginManager
public boolean dispatchCommand(CommandSender sender, String commandLine)
{
String[] split = argsSplit.split( commandLine );
Command command = commandMap.get( split[0].toLowerCase() );
String commandName = split[0].toLowerCase();
if ( proxy.getDisabledCommands().contains( commandName ) )
{
return false;
}
Command command = commandMap.get( commandName );
if ( command == null )
{
return false;

View File

@ -518,4 +518,9 @@ public class BungeeCord extends ProxyServer
{
return new Custom( player );
}
public Collection<String> getDisabledCommands()
{
return config.getDisabledCommands();
}
}

View File

@ -2,6 +2,7 @@ package net.md_5.bungee.config;
import com.google.common.base.Preconditions;
import gnu.trove.map.TMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
@ -14,6 +15,7 @@ import net.md_5.bungee.tab.GlobalPing;
import net.md_5.bungee.tab.Global;
import net.md_5.bungee.tab.ServerUnique;
import net.md_5.bungee.util.CaseInsensitiveMap;
import net.md_5.bungee.util.CaseInsensitiveSet;
/**
* Core configuration for the proxy.
@ -43,6 +45,7 @@ public class Configuration
*/
private boolean onlineMode = true;
private int playerLimit = -1;
private Collection<String> disabledCommands;
public void load()
{
@ -55,6 +58,8 @@ public class Configuration
onlineMode = adapter.getBoolean( "online_mode", onlineMode );
playerLimit = adapter.getInt( "player_limit", playerLimit );
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "find" ) ) );
Preconditions.checkArgument( listeners != null && !listeners.isEmpty(), "No listeners defined." );
Map<String, ServerInfo> newServers = adapter.getServers();

View File

@ -234,6 +234,12 @@ public class YamlConfig implements ConfigurationAdapter
return ret;
}
@Override
public Collection<?> getList(String path, Collection<?> def)
{
return get( path, def );
}
@Override
@SuppressWarnings("unchecked")
public Collection<String> getPermissions(String group)