blob: 4003b01012f313bb3d8a7712f6f5e67094e4b55b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package com.redstoner.utils;
import java.lang.reflect.Field;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.plugin.SimplePluginManager;
public class CommandMap
{
@SuppressWarnings("unchecked")
public static Map<String, Command> getCommandMap() throws ReflectiveOperationException, ClassCastException
{
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
field.setAccessible(true);
Object map = field.get(Bukkit.getPluginManager());
field = SimpleCommandMap.class.getDeclaredField("knownCommands");
field.setAccessible(true);
return (Map<String, Command>) field.get(map);
}
}
|