Archived
0
This repository has been archived on 2024-08-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Modules/src/com/redstoner/utils/CommandMap.java
Pepich d965f30dca General cleanup
Removing outdated comments
Removing outdated annotations
Adding new annotations
Removing deprecation
2017-05-30 11:56:56 +02:00

24 lines
712 B
Java

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);
}
}