Fix for Bukkit "unknown command" error when using console commands
handling for extra commas in "baseCommandAliases" in conf.json adding null values
This commit is contained in:
parent
61bd37c99b
commit
f5450886f1
@ -3,6 +3,10 @@ version: 1.6.0_dev
|
||||
main: com.massivecraft.factions.P
|
||||
authors: [Olof Larsson, Brett Flannigan]
|
||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, nChat, ChatManager, CAPI, AuthMe, Register, Spout, WorldEdit, WorldGuard]
|
||||
commands:
|
||||
factions:
|
||||
description: Reference command for Factions.
|
||||
aliases: [f]
|
||||
permissions:
|
||||
factions.kit.admin:
|
||||
description: All faction permissions.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
|
||||
public class FCmdRoot extends FCommand
|
||||
@ -55,6 +57,7 @@ public class FCmdRoot extends FCommand
|
||||
{
|
||||
super();
|
||||
this.aliases.addAll(Conf.baseCommandAliases);
|
||||
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
||||
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
|
@ -1,17 +1,31 @@
|
||||
package com.massivecraft.factions.zcore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
public class MPluginSecretServerListener extends ServerListener
|
||||
{
|
||||
private MPlugin p;
|
||||
private String refCommand;
|
||||
|
||||
public MPluginSecretServerListener(MPlugin p)
|
||||
{
|
||||
this.p = p;
|
||||
refCommand = "";
|
||||
|
||||
// attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there
|
||||
// reference command will be used to prevent "unknown command" console messages
|
||||
try
|
||||
{
|
||||
Map<String, Object> refCmd = (Map<String, Object>) p.getDescription().getCommands();
|
||||
if (refCmd != null && !refCmd.isEmpty())
|
||||
refCommand = (String)(refCmd.keySet().toArray()[0]);
|
||||
}
|
||||
catch (ClassCastException ex) {}
|
||||
}
|
||||
|
||||
// This method is not perfect. It says unknown console command.
|
||||
@Override
|
||||
public void onServerCommand(ServerCommandEvent event)
|
||||
{
|
||||
@ -19,7 +33,7 @@ public class MPluginSecretServerListener extends ServerListener
|
||||
|
||||
if (p.handleCommand(event.getSender(), event.getCommand()))
|
||||
{
|
||||
event.setCommand("");
|
||||
event.setCommand(refCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user