Connected standard command handler getCommand("f"), for it to work with other plugins which directly execute commands using that interface.
This commit is contained in:
@ -36,6 +36,7 @@ public abstract class MPlugin extends JavaPlugin
|
||||
protected boolean loadSuccessful = false;
|
||||
public boolean getAutoSave() {return this.autoSave;}
|
||||
public void setAutoSave(boolean val) {this.autoSave = val;}
|
||||
public String refCommand = "";
|
||||
|
||||
// Listeners
|
||||
private MPluginSecretPlayerListener mPluginSecretPlayerListener;
|
||||
@ -68,7 +69,17 @@ public abstract class MPlugin extends JavaPlugin
|
||||
|
||||
this.txt = new TextUtil();
|
||||
initTXT();
|
||||
|
||||
|
||||
// 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, Map<String, Object>> refCmd = this.getDescription().getCommands();
|
||||
if (refCmd != null && !refCmd.isEmpty())
|
||||
this.refCommand = (String)(refCmd.keySet().toArray()[0]);
|
||||
}
|
||||
catch (ClassCastException ex) {}
|
||||
|
||||
// Create and register listeners
|
||||
this.mPluginSecretPlayerListener = new MPluginSecretPlayerListener(this);
|
||||
this.mPluginSecretServerListener = new MPluginSecretServerListener(this);
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.massivecraft.factions.zcore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -10,22 +8,10 @@ import org.bukkit.event.server.ServerCommandEvent;
|
||||
public class MPluginSecretServerListener implements Listener
|
||||
{
|
||||
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, Map<String, Object>> refCmd = p.getDescription().getCommands();
|
||||
if (refCmd != null && !refCmd.isEmpty())
|
||||
refCommand = (String)(refCmd.keySet().toArray()[0]);
|
||||
}
|
||||
catch (ClassCastException ex) {}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -35,7 +21,7 @@ public class MPluginSecretServerListener implements Listener
|
||||
|
||||
if (p.handleCommand(event.getSender(), event.getCommand()))
|
||||
{
|
||||
event.setCommand(refCommand);
|
||||
event.setCommand(p.refCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user