I have this command in my plugin yml:
rankup:
description: Allows to rankup through the prison ranks
aliases: [ru]
However there is a configuration file for disabling commands and if you disable this command:
rankupstrue: false
I need to keep that in the plugin yml in case this boolean is set to true in the configuration file. However, if they disable this I return on the onCommand boolean before anything happens, like so:
public boolean onCommand(CommandSender s, Command cmd, String label, String[] args){
if(main.getConfig().getBoolean("rankupstrue"))return true;
// code
}
I then enable it here in the onEnable
getCommand("rankup").setExecutor(new RankupCore(this, qm));
However if the boolean that disables this command is set to false and an alternative plugin has the same command, the alternative plugin's command will not work. To fix this I have tried to stop enabling it in the onEnable:
if(main.getConfig().getBoolean("rankupstrue"))
{
// getCommand
}
However this brings me the same result. I then default back to the plugin yml. Is there a way to remove:
rankup:
description: Allows to rankup through the prison ranks
aliases: [ru]
from the plugin yml if rankupstrue
is false?
Or is there a way to add that to the plugin yml if that boolean is true?
Or is there a way to block out this command in any way besides the plugin yml?
To fix this problem you would use PlayerCommandPreprocessEvent
and check if the command is equal to the command that is doing this problem. Make sure you cancel the event after you check to make sure.
// in the event
if(e.getMessage().equalsIgnoreCase("command"))e.setCancelled(true);