mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Output the redirected plugin too.
This commit is contained in:
parent
57a0ec9912
commit
0b2a3fcf7f
3 changed files with 28 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
|
@ -11,7 +10,7 @@ import org.bukkit.plugin.Plugin;
|
||||||
public class AlternativeCommandsHandler
|
public class AlternativeCommandsHandler
|
||||||
{
|
{
|
||||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||||
private final transient Set<String> executed = new HashSet<String>();
|
private final transient Map<String, String> executed = new HashMap<String, String>();
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
|
|
||||||
public AlternativeCommandsHandler(final IEssentials ess)
|
public AlternativeCommandsHandler(final IEssentials ess)
|
||||||
|
@ -19,7 +18,8 @@ public class AlternativeCommandsHandler
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||||
{
|
{
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled())
|
||||||
|
{
|
||||||
addPlugin(plugin);
|
addPlugin(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,10 @@ public class AlternativeCommandsHandler
|
||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
}
|
}
|
||||||
// return the first command that is not an alias
|
// return the first command that is not an alias
|
||||||
for (PluginCommand command : commands) {
|
for (PluginCommand command : commands)
|
||||||
if (command.getName().equalsIgnoreCase(label)) {
|
{
|
||||||
|
if (command.getName().equalsIgnoreCase(label))
|
||||||
|
{
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,12 +118,12 @@ public class AlternativeCommandsHandler
|
||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executed(final String label)
|
public void executed(final String label, final String otherlabel)
|
||||||
{
|
{
|
||||||
executed.add(label);
|
executed.put(label, otherlabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> disabledCommands()
|
public Map<String, String> disabledCommands()
|
||||||
{
|
{
|
||||||
return executed;
|
return executed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||||
if (pc != null)
|
if (pc != null)
|
||||||
{
|
{
|
||||||
alternativeCommandsHandler.executed(commandLabel);
|
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||||
LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
||||||
return pc.execute(sender, commandLabel, args);
|
return pc.execute(sender, commandLabel, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,15 @@ public class Commandessentials extends EssentialsCommand
|
||||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||||
sender.sendMessage("/<command> <reload/debug>");
|
sender.sendMessage("/<command> <reload/debug>");
|
||||||
sender.sendMessage("Essentials blocked the following commands, due to command conflicts:");
|
sender.sendMessage("Essentials blocked the following commands, due to command conflicts:");
|
||||||
sender.sendMessage(Util.joinList(ess.getAlternativeCommandsHandler().disabledCommands()));
|
final StringBuilder disabledCommands = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||||
|
{
|
||||||
|
if (disabledCommands.length() > 0) {
|
||||||
|
disabledCommands.append(", ");
|
||||||
|
}
|
||||||
|
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||||
|
}
|
||||||
|
sender.sendMessage(disabledCommands.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
|
Loading…
Reference in a new issue