mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-31 09:52:57 +00:00
Adding some debug info to /essentials
This commit is contained in:
parent
cdbae1631d
commit
af7eae6201
3 changed files with 52 additions and 12 deletions
|
@ -11,6 +11,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 IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
|
|
||||||
public AlternativeCommandsHandler(final IEssentials ess)
|
public AlternativeCommandsHandler(final IEssentials ess)
|
||||||
|
@ -100,7 +101,7 @@ public class AlternativeCommandsHandler
|
||||||
if (commands == null || commands.isEmpty())
|
if (commands == null || commands.isEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (commands.size() == 1)
|
if (commands.size() == 1)
|
||||||
{
|
{
|
||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
|
@ -114,4 +115,14 @@ public class AlternativeCommandsHandler
|
||||||
// return the first alias
|
// return the first alias
|
||||||
return commands.get(0);
|
return commands.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void executed(final String label)
|
||||||
|
{
|
||||||
|
executed.add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> disabledCommands()
|
||||||
|
{
|
||||||
|
return new ArrayList<String>(executed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,8 @@ 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)
|
||||||
{
|
{
|
||||||
LOGGER.info("Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
alternativeCommandsHandler.executed(commandLabel);
|
||||||
|
LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
||||||
return pc.execute(sender, commandLabel, args);
|
return pc.execute(sender, commandLabel, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -23,12 +24,44 @@ public class Commandessentials extends EssentialsCommand
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("debug"))
|
if (args.length == 0) {
|
||||||
{
|
run_disabled(server, sender, commandLabel, args);
|
||||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
|
||||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("debug"))
|
||||||
|
{
|
||||||
|
run_debug(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("nya"))
|
||||||
|
{
|
||||||
|
run_nya(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
run_reload(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||||
|
sender.sendMessage("/<command> <reload/debug>");
|
||||||
|
sender.sendMessage("Essentials blocked the following commands, due to command conflicts:");
|
||||||
|
sender.sendMessage(Util.joinList(ess.getAlternativeCommandsHandler().disabledCommands()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||||
|
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
ess.reload();
|
||||||
|
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||||
noteMap.put("1F#", (byte)0x0);
|
noteMap.put("1F#", (byte)0x0);
|
||||||
noteMap.put("1G", (byte)0x1);
|
noteMap.put("1G", (byte)0x1);
|
||||||
|
@ -54,8 +87,6 @@ public class Commandessentials extends EssentialsCommand
|
||||||
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
||||||
noteMap.put("2E", (byte)(0xA + 0xC));
|
noteMap.put("2E", (byte)(0xA + 0xC));
|
||||||
noteMap.put("2F", (byte)(0xB + 0xC));
|
noteMap.put("2F", (byte)(0xB + 0xC));
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
|
|
||||||
{
|
|
||||||
if (!noteBlocks.isEmpty())
|
if (!noteBlocks.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -106,9 +137,6 @@ public class Commandessentials extends EssentialsCommand
|
||||||
}
|
}
|
||||||
}, 20, 2);
|
}, 20, 2);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
ess.reload();
|
|
||||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopTune()
|
private void stopTune()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue