Guest User

Untitled

a guest
May 1st, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. Public void UnRegCmd(String command_name) {
  2. try {
  3. HashMap<String, Command> known_commands = (HashMap<String, Command>) this.getPrivateField((CommandMap) this.getPrivateField(this.pm, "commandMap"), "knownCommands");
  4. for (String alias : this.getCommand(command_name).getAliases()) {
  5. known_commands.remove(command_name);
  6. }
  7. known_commands.remove(command_name);
  8. } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
  9. this.utils.writeWatchdogExceptionLog(this, this.getClass(), ex);
  10. }
  11. }
  12.  
  13. private Object getPrivateField(Object object, String field) throws
  14. SecurityException,
  15. NoSuchFieldException,
  16. IllegalArgumentException,
  17. IllegalAccessException {
  18. Field objectField = object.getClass().getDeclaredField(field);
  19. objectField.setAccessible(true);
  20. return objectField.get(object);
  21. }
  22.  
  23.  
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment