/** * Method to grab Essentials internal altCommands hash. This is ugly code but Essentials offers no * external APIs to make this any cleaner. * * @throws NoSuchFieldException * @throws SecurityException * @throws IllegalAccessException * @throws IllegalArgumentException */ @SuppressWarnings("unchecked") private void grabInternalAltCommands() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Essentials pluginObject = (Essentials) essentialsPlugin; Field commandHandler = pluginObject.getClass().getDeclaredField("alternativeCommandsHandler"); commandHandler.setAccessible(true); AlternativeCommandsHandler ach = (AlternativeCommandsHandler) commandHandler.get(pluginObject); Field altCommandsField = ach.getClass().getDeclaredField("altcommands"); altCommandsField.setAccessible(true); altcommands = (HashMap<String, List<PluginCommand>>) altCommandsField.get(ach); log.debug("altcommands = {}", altcommands); }