Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
39 kB
4
Indexable
Never
/* Decompiler 473ms, total 584ms, lines 883 */
package com.Zrips.CMI.commands;

import com.Zrips.CMI.CMI;
import com.Zrips.CMI.Config;
import com.Zrips.CMI.Containers.CMIUser;
import com.Zrips.CMI.Containers.CommandAlias;
import com.Zrips.CMI.Containers.CommandAliasType;
import com.Zrips.CMI.Containers.Snd;
import com.Zrips.CMI.Modules.CmdCost.CMICommandCost;
import com.Zrips.CMI.Modules.CmdCost.CMICommandCostUsage;
import com.Zrips.CMI.Modules.Homes.CmiHome;
import com.Zrips.CMI.Modules.ModuleHandling.CMIModule;
import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm;
import com.Zrips.CMI.commands.list.dsign;
import com.Zrips.CMI.commands.list.home;
import com.Zrips.CMI.commands.list.killall;
import com.Zrips.CMI.commands.list.placeholders;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import net.Zrips.CMILib.CMILib;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.CMIArray;
import net.Zrips.CMILib.Container.PageInfo;
import net.Zrips.CMILib.Locale.LC;
import net.Zrips.CMILib.RawMessages.RawMessage;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.ProxiedCommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

public class CommandsHandler implements CommandExecutor {
   public static final String label = "cmi";
   private static String packagePath = "";
   public static int stage = 0;
   public static String msg = "";
   private Map<String, CMICommand> commands = new TreeMap();
   private List<String> disabledBase = new ArrayList();
   private boolean testServer = false;
   protected CMI plugin;

   public CommandsHandler(CMI var1) {
      this.plugin = var1;
      packagePath = this.getClass().getPackage().getName() + ".list";
      if (CMILib.getInstance().getReflectionManager().getServerName().equals("LT_Craft") && ((World)Bukkit.getWorlds().get(0)).getSeed() == 1782374759L) {
         this.testServer = true;
      }

   }

   public Boolean performCMICommand(CommandSender var1, Class<?> var2, String... var3) {
      CMICommand var4 = (CMICommand)this.getCommands().get(var2.getSimpleName().toLowerCase());
      return var4 == null ? false : this.performCMICommand(var1, var4, var3);
   }

   public Boolean performCMICommand(CommandSender var1, CMICommand var2, String[] var3) {
      return var2 == null ? false : var2.getCmdClass().perform(this.plugin, var1, var3);
   }

   public Boolean performCMICommand(CommandSender var1, Class<?> var2, String var3) {
      CMICommand var4 = (CMICommand)this.getCommands().get(var2.getSimpleName().toLowerCase());
      return var4 == null ? false : this.performCMICommand(var1, var4, var3);
   }

   public Boolean performCMICommand(CommandSender var1, CMICommand var2, String var3) {
      if (var2 == null) {
         return false;
      } else {
         String[] var4 = new String[]{var3};
         return var2.getCmdClass().perform(this.plugin, var1, var3.contains(" ") ? var3.split(" ") : (var3.isEmpty() ? new String[0] : var4));
      }
   }

   public boolean onCommand(CommandSender var1, Command var2, String var3, String[] var4) {
      if (var4.length > 0 && var4[0].equalsIgnoreCase("rmc")) {
         return false;
      } else {
         CommandAlias var5 = CMI.getInstance().getAliasManager().getAliasForCommand(CMIArray.toString(var4));
         if (var2 != null && var2.getName().equalsIgnoreCase(getLabel()) && var5 != null && var5.isDisableBase()) {
            this.plugin.sendMessage(var1, LC.info_NoCommand, new Object[0]);
            return false;
         } else {
            try {
               if (Class.forName("org.bukkit.command.ProxiedCommandSender") != null && var1 instanceof ProxiedCommandSender) {
                  var1 = Bukkit.getConsoleSender();
               }
            } catch (Exception var22) {
            }

            int var6;
            try {
               if (Class.forName("org.bukkit.command.BlockCommandSender") != null && var1 instanceof BlockCommandSender) {
                  try {
                     for(var6 = 0; var6 < var4.length; ++var6) {
                        String var7 = var4[var6];
                        List var8 = Bukkit.selectEntities((CommandSender)var1, var7.toLowerCase());
                        if (!var8.isEmpty() && (var7.equalsIgnoreCase("@p") || var7.equalsIgnoreCase("@r"))) {
                           var4[var6] = ((Entity)var8.get(0)).getName();
                        }
                     }
                  } catch (Throwable var23) {
                  }

                  if (var4.length > 0 && !var4[0].equalsIgnoreCase(killall.class.getSimpleName()) || var4.length == 0) {
                     var1 = Bukkit.getConsoleSender();
                  }
               }
            } catch (Exception var24) {
               var24.printStackTrace();
            }

            if (!CMIPerm.command.hasPermission((CommandSender)var1, false, 5000L)) {
               if (var1 instanceof Player) {
                  boolean var30 = this.plugin.getConfigManager().isPermisionOnError() || CMIPerm.permisiononerror.hasPermission((CommandSender)var1, false, 5000L);
                  RawMessage var27 = new RawMessage();
                  var27.addText(this.plugin.getMsg(LC.info_NoPermission, new Object[0])).addHover(var30 ? "&2" + CMIPerm.command.getPermission() : null);
                  var27.show((CommandSender)var1);
               }

               ConsoleCommandSender var32 = Bukkit.getServer().getConsoleSender();
               Snd var29 = (new Snd()).setSender(var32).setTarget((CommandSender)var1);
               this.plugin.sendMessage(var32, this.plugin.getMsg(LC.info_NoPlayerPermission, new Object[]{var29, "[permission]", CMIPerm.command.getPermission()}), false);
               return false;
            } else if (var4.length == 0) {
               if (!Config.ShowMainHelpPage) {
                  this.plugin.sendMessage(var1, LC.info_NoCommand, new Object[0]);
                  return false;
               } else {
                  return this.help((CommandSender)var1, 1);
               }
            } else if ((var4.length == 1 || var4.length == 2) && (var4[0].equalsIgnoreCase("?") || var4[0].equalsIgnoreCase("help"))) {
               if (!Config.ShowMainHelpPage) {
                  this.plugin.sendMessage(var1, LC.info_NoCommand, new Object[0]);
                  return false;
               } else {
                  var6 = 1;
                  if (var4.length == 2) {
                     try {
                        var6 = Integer.parseInt(var4[1]);
                     } catch (NumberFormatException var21) {
                        this.plugin.sendMessage(var1, this.plugin.getMsg(LC.info_UseInteger, new Object[0]), false);
                        return true;
                     }
                  }

                  if (var6 < 1) {
                     var6 = 1;
                  }

                  return this.help((CommandSender)var1, var6);
               }
            } else {
               String var25 = var4[0].toLowerCase();
               Cmd var26 = this.getCmdClass(var25);
               if (var1 instanceof Player && !var25.equalsIgnoreCase(placeholders.class.getSimpleName()) && !var25.equalsIgnoreCase(dsign.class.getSimpleName())) {
                  for(int var28 = 1; var28 < var4.length; ++var28) {
                     if (CMI.getInstance().getPlaceholderAPIManager().containsPlaceHolder(var4[var28])) {
                        var4[var28] = CMI.getInstance().getPlaceholderAPIManager().coolDownPlaceHolders(var4[var28], (Player)var1);
                     }
                  }
               }

               if (var26 == null) {
                  var26 = this.getBestCmdmatch(var25);
                  if (var26 != null) {
                     String var31 = CMIArray.toString(var4, 1);
                     if (!var31.isEmpty()) {
                        var31 = " " + var31;
                     }

                     if (!this.plugin.getCooldownManager().canUseCmd((CommandSender)var1, getLabel() + " " + var26.getClass().getSimpleName() + var31)) {
                        return false;
                     }

                     if (this.plugin.getWarmUpManager().startCmdUsage((CommandSender)var1, getLabel() + " " + var26.getClass().getSimpleName() + var31)) {
                        return false;
                     }
                  }
               }

               if (var26 != null && stage == 0) {
                  var25 = var26.getClass().getSimpleName();
                  if (var1 instanceof Player && var25.equalsIgnoreCase(home.class.getSimpleName()) && var4.length == 1) {
                     CMIUser var34 = this.plugin.getPlayerManager().getUser((Player)var1);
                     if (var34.getHomes().size() == 1) {
                        CmiHome var9 = (CmiHome)var34.getHomes().values().iterator().next();
                        var4 = CMIArray.addLast(var4, var9.getName());
                        if (this.plugin.getCooldownManager().isCmdInCooldown((CommandSender)var1, getLabel() + " " + home.class.getSimpleName() + " ")) {
                           return false;
                        }

                        if (this.plugin.getWarmUpManager().startCmdUsage((CommandSender)var1, getLabel() + " " + home.class.getSimpleName() + " " + var9.getName())) {
                           return false;
                        }

                        this.plugin.getCooldownManager().canUseCmd((CommandSender)var1, getLabel() + " " + home.class.getSimpleName() + " ");
                     }
                  }

                  int var10;
                  String var33;
                  if (!var25.equalsIgnoreCase(var4[0])) {
                     RawMessage var35 = new RawMessage();
                     var33 = "";

                     for(var10 = 1; var10 < var4.length; ++var10) {
                        if (!var33.isEmpty()) {
                           var33 = var33 + " ";
                        }

                        var33 = var33 + var4[var10];
                     }

                     var35.addText(this.plugin.getMsg(LC.info_cantFindCommand, new Object[]{"[%1]", var4[0], "[%2]", var25})).addHover(this.plugin.getMsg(LC.info_Click, new Object[0])).addCommand(getLabel() + " " + var25 + " " + var33);
                     var35.show((CommandSender)var1);
                     if (this.plugin.getConfigManager().isOptimizationsSimilarCommandPrevention()) {
                        return false;
                     }
                  }

                  if (!hasCommandPermission((CommandSender)var1, var25, 50L)) {
                     if (var1 instanceof Player) {
                        CMICommand var38 = (CMICommand)this.getCommands().get(var26.getClass().getSimpleName());
                        if (var38 != null && !var38.getAnottation().redirectClass().equals(Void.class)) {
                           Class var44 = var38.getAnottation().redirectClass();
                           if (hasCommandPermission((CommandSender)var1, var44.getSimpleName(), 50L)) {
                              this.plugin.performCommand((CommandSender)var1, getLabel() + " " + var44.getSimpleName() + " " + CMIArray.toString(CMIArray.removeFirst(var4)));
                              return true;
                           }
                        }

                        boolean var45 = this.plugin.getConfigManager().isPermisionOnError() || CMIPerm.permisiononerror.hasPermission((CommandSender)var1, false, 5000L);
                        RawMessage var42 = new RawMessage();
                        var42.addText(this.plugin.getMsg(LC.info_NoPermission, new Object[0])).addHover(var45 ? "&2cmi.command." + var25 : null);
                        var42.show((CommandSender)var1);
                        ConsoleCommandSender var43 = Bukkit.getServer().getConsoleSender();
                        Snd var47 = (new Snd()).setSender(var43).setTarget((CommandSender)var1);
                        this.plugin.sendMessage(var43, LC.info_NoPlayerPermission.getLocale(new Object[]{var47, "[permission]", "cmi.command." + var25}), false);
                     } else {
                        this.plugin.sendMessage(var1, this.plugin.getMsg(LC.info_NoPermission, new Object[0]), false);
                     }

                     if (var1 instanceof Player) {
                        this.plugin.getCooldownManager().removeCooldown((CommandSender)var1, getLabel() + " " + var25);
                     }

                     return false;
                  } else {
                     String[] var36 = CMIArray.removeFirst(var4);
                     if (var36.length > 0 && var36[var36.length - 1].equals("?")) {
                        CMICommand var37 = (CMICommand)this.getCommands().get(var26.getClass().getSimpleName());
                        if (var37 == null || !var37.getAnottation().ignoreHelpPage() && !var37.getAnottation().subIgnoreHelpPage()) {
                           this.sendUsage((CommandSender)var1, var25);
                           return false;
                        }

                        if (var36.length == 1 && var37.getAnottation().subIgnoreHelpPage()) {
                           this.sendUsage((CommandSender)var1, var25);
                           return false;
                        }
                     }

                     Method[] var12;
                     int var11 = (var12 = var26.getClass().getMethods()).length;

                     for(var10 = 0; var10 < var11; ++var10) {
                        Method var39 = var12[var10];
                        if (var39.isAnnotationPresent(CAnnotation.class)) {
                           CAnnotation var13 = (CAnnotation)var39.getAnnotation(CAnnotation.class);
                           int[] var14;
                           ArrayList var15;
                           boolean var16;
                           int var17;
                           int var18;
                           int var19;
                           int[] var20;
                           boolean var48;
                           if (var1 instanceof Player) {
                              var14 = var13.regVar();
                              var15 = new ArrayList();
                              var16 = true;
                              var20 = var14;
                              var19 = var14.length;

                              for(var18 = 0; var18 < var19; ++var18) {
                                 var17 = var20[var18];
                                 if (var17 < 0) {
                                    var16 = false;
                                 }

                                 var15.add(var17);
                              }

                              var17 = var36.length;
                              var48 = true;
                              if (var15.contains(666)) {
                                 this.plugin.sendMessage(var1, CMILib.getInstance().getLM().getMessage("info.FromConsole", new Object[0]), false);
                                 return false;
                              }

                              if (var15.contains(-var17)) {
                                 var48 = false;
                              }

                              if (var15.contains(var17)) {
                                 var48 = true;
                              }

                              if (var15.contains(-100) && var17 == 0) {
                                 var48 = false;
                              }

                              if (var16 && !var15.contains(var17)) {
                                 var48 = false;
                              }

                              if (!var48) {
                                 this.sendUsage((CommandSender)var1, var26.getClass().getSimpleName(), false);
                                 return false;
                              }
                           } else {
                              var14 = var13.consoleVar();
                              var15 = new ArrayList();
                              var16 = true;
                              var20 = var14;
                              var19 = var14.length;

                              for(var18 = 0; var18 < var19; ++var18) {
                                 var17 = var20[var18];
                                 if (var17 < 0) {
                                    var16 = false;
                                 }

                                 var15.add(var17);
                              }

                              var17 = var36.length;
                              var48 = true;
                              if (var15.contains(666)) {
                                 this.plugin.sendMessage(var1, CMILib.getInstance().getLM().getMessage("info.Ingame", new Object[0]), false);
                                 return false;
                              }

                              if (var15.contains(-var17)) {
                                 var48 = false;
                              }

                              if (var15.contains(var17)) {
                                 var48 = true;
                              }

                              if (var15.contains(-100) && var17 == 0) {
                                 var48 = false;
                              }

                              if (var16 && !var15.contains(var17)) {
                                 var48 = false;
                              }

                              if (!var48) {
                                 this.sendUsage((CommandSender)var1, var26.getClass().getSimpleName(), false);
                                 return false;
                              }
                           }
                        }
                     }

                     if (var36.length > 0) {
                        var36[var36.length - 1] = var36[var36.length - 1].replace("<>-<>", "");
                     }

                     var33 = CMIArray.toString(var36, " ");
                     var33 = var33.isEmpty() ? "" : " " + var33;
                     if (!this.plugin.getCommandCostManager().isContinueCommand((CommandSender)var1, "cmi " + var26.getClass().getSimpleName() + var33)) {
                        if (var1 instanceof Player) {
                           this.plugin.getCooldownManager().removeCooldown((CommandSender)var1, getLabel() + " " + var25);
                           this.plugin.getCooldownManager().removeCooldown((CommandSender)var1, getLabel() + " " + var25 + " ");
                        }

                        return false;
                     } else {
                        Boolean var40 = var26.perform(this.plugin, (CommandSender)var1, var36);
                        if (var40 != null && !var40) {
                           this.sendUsage((CommandSender)var1, var25, false);
                        }

                        if ((var40 == null || !var40) && var1 instanceof Player) {
                           if (var36.length > 0) {
                              this.plugin.getCooldownManager().removeCooldown((CommandSender)var1, getLabel() + " " + var25 + " " + CMIArray.toString(var36, " ").toLowerCase());
                           } else {
                              this.plugin.getCooldownManager().removeCooldown((CommandSender)var1, getLabel() + " " + var25);
                           }
                        }

                        if (var40 != null && var40 && var1 instanceof Player && !this.plugin.getCommandCostManager().canUseCmd((CommandSender)var1, "cmi " + var26.getClass().getSimpleName() + var33).equals(CMICommandCostUsage.CostBypass)) {
                           CMICommandCost var41 = this.plugin.getCommandCostManager().getCost("cmi " + var26.getClass().getSimpleName() + var33);
                           CMIUser var46 = this.plugin.getPlayerManager().getUser((Player)var1);
                           if (var41 != null && var41.getCost() > 0.0D) {
                              if (var46.hasMoney(var41.getCost())) {
                                 var46.withdraw(var41.getCost());
                                 var41.removeConfirmation(var46.getUniqueId());
                                 if (var41.isInformOnCharge()) {
                                    this.plugin.sendMessage(var1, LC.econ_charged, new Object[]{"[amount]", this.plugin.getEconomyManager().format(var41.getCost())});
                                 }
                              } else {
                                 this.plugin.sendMessage(var1, LC.econ_notEnoughMoney, new Object[]{"[amount]", this.plugin.getEconomyManager().format(var41.getCost())});
                              }
                           }
                        }

                        return var40 != null && var40;
                     }
                  }
               } else {
                  if (stage != 0 && !msg.isEmpty()) {
                     this.plugin.consoleMessage(msg);
                  }

                  this.plugin.sendMessage(var1, LC.info_NoCommand, new Object[0]);
                  return false;
               }
            }
         }
      }
   }

   public static boolean hasCommandPermission(CommandSender var0, String var1, Long var2) {
      if (!(var0 instanceof Player)) {
         return true;
      } else {
         return CMIPerm.command_$1.hasPermission(var0, false, true, var2, new String[]{"*"}) ? true : CMIPerm.command_$1.hasPermission(var0, false, true, var2, new String[]{var1});
      }
   }

   private String getUsage(String var1) {
      String var2 = "";
      if (this.plugin.getAliasManager().getAll().containsKey(var1.toLowerCase()) && ((CommandAlias)this.plugin.getAliasManager().getAll().get(var1.toLowerCase())).getState()) {
         var2 = var1;
      } else if (this.plugin.getAliasManager().getFrom().containsKey("cmi " + var1)) {
         CommandAlias var3 = (CommandAlias)this.plugin.getAliasManager().getFrom().get("cmi " + var1);
         var2 = var3.getAlias();
      } else if (this.plugin.getConfigManager().isOptimizationsCommandRemoveLabel()) {
         var2 = var1;
      } else {
         var2 = "cmi " + var1;
      }

      String var5 = this.plugin.getLM().getMessage("command.help.output.cmdFormat", new Object[]{"[command]", var2});
      String var4 = "command." + var1 + ".help.args";
      if (this.plugin.getLM().containsKey(var4) && !this.plugin.getLM().getMessage(var4, new Object[0]).isEmpty()) {
         var5 = var5.replace("[arguments]", " " + this.plugin.getLM().getMessage(var4, new Object[0]));
      } else {
         var5 = var5.replace("[arguments]", "");
      }

      return var5;
   }

   private String getCommandRoot(String var1) {
      if (this.plugin.getAliasManager().getAll().containsKey(var1.toLowerCase()) && ((CommandAlias)this.plugin.getAliasManager().getAll().get(var1.toLowerCase())).getState()) {
         return var1;
      } else if (this.plugin.getAliasManager().getFrom().containsKey("cmi " + var1)) {
         return ((CommandAlias)this.plugin.getAliasManager().getFrom().get("cmi " + var1)).getAlias();
      } else {
         return this.plugin.getConfigManager().isOptimizationsCommandRemoveLabel() ? var1 : "cmi " + var1;
      }
   }

   public void sendUsage(CommandSender var1, String var2) {
      this.sendUsage(var1, var2, true);
   }

   public void sendUsage(CommandSender var1, String var2, boolean var3) {
      String var4 = CMIChatColor.YELLOW + this.plugin.getLM().getMessage("command.help.output.usage", new Object[0]);
      var4 = var4.replace("%usage%", this.getUsage(var2));
      this.plugin.sendMessage(var1, var4, false);
      this.plugin.sendMessage(var1, this.plugin.getLM().getMessage("command.help.output.helpPageDescription", new Object[]{"[description]", this.plugin.getLM().getMessage("command." + var2 + ".help.info", new Object[0])}), false);
      if (var3 && this.plugin.getLM().containsKey("command." + var2 + ".help.explanation")) {
         if (this.plugin.getLM().isString("command." + var2 + ".help.explanation")) {
            this.plugin.sendMessage(var1, this.plugin.getLM().getMessage("command.help.output.explanation", new Object[]{"[explanation]", this.plugin.getLM().getMessage("command." + var2 + ".help.explanation", new Object[0])}), false);
         } else {
            Iterator var6 = this.plugin.getLM().getMessageList("command." + var2 + ".help.explanation", new Object[0]).iterator();

            while(var6.hasNext()) {
               String var5 = (String)var6.next();
               this.plugin.sendMessage(var1, this.plugin.getLM().getMessage("command.help.output.explanation", new Object[]{"[explanation]", var5}), false);
            }
         }
      }

   }

   protected boolean help(CommandSender var1, int var2) {
      Map var3 = this.GetCommands(var1);
      if (var3.size() == 0) {
         this.plugin.sendMessage(var1, CMILib.getInstance().getLM().getMessage("info.NoPermission", new Object[0]), false);
         return true;
      } else {
         if (!this.plugin.getConfigManager().isOptimizationsCommandSorting()) {
            var3 = sort(var3);
         }

         PageInfo var4 = new PageInfo(7, var3.size(), var2);
         this.plugin.sendMessage(var1, this.plugin.getLM().getMessage("command.help.output.title", new Object[0]), false);
         RawMessage var5 = new RawMessage();
         Iterator var7 = var3.entrySet().iterator();

         while(var7.hasNext()) {
            Entry var6 = (Entry)var7.next();
            if (var4.isBreak()) {
               break;
            }

            if (!var4.isContinue()) {
               String var8 = this.plugin.getLM().getMessage("command.help.output.cmdInfoFormat", new Object[0]);
               var8 = var8.replace("[command]", this.getUsage((String)var6.getKey()));
               var8 = var8.replace("[description]", this.plugin.getLM().getMessage("command." + (String)var6.getKey() + ".help.info", new Object[0]));
               var5.addText(var8);
               var5.addHover(this.plugin.getLM().getMessage("command." + (String)var6.getKey() + ".help.info", new Object[0]));
               var5.addSuggestion("/" + this.getCommandRoot((String)var6.getKey()) + " ");
               if (!var4.isBreak() && var4.getPositionForOutput() <= var4.getEnd()) {
                  var5.addText("\n");
               }
            }
         }

         var5.show(var1);
         this.plugin.ShowPagination(var1, var4, "/cmi ?");
         return true;
      }
   }

   public static List<String> getClassesFromPackage(String var0) {
      ArrayList var1 = new ArrayList();

      try {
         URL[] var5;
         int var4 = (var5 = ((URLClassLoader)CMI.class.getClassLoader()).getURLs()).length;

         for(int var3 = 0; var3 < var4; ++var3) {
            URL var2 = var5[var3];

            try {
               var1.addAll(getClassesInSamePackageFromJar(var0, var2.toURI().getPath()));
            } catch (URISyntaxException var7) {
            }
         }

         return var1;
      } catch (NullPointerException var8) {
         throw new ClassNotFoundException(var0 + " does not appear to be a valid package (Null pointer exception)");
      }
   }

   private static List<String> getClassesInSamePackageFromJar(String var0, String var1) {
      JarFile var2 = null;
      ArrayList var3 = new ArrayList();

      try {
         var2 = new JarFile(var1);
         Enumeration var4 = var2.entries();

         while(var4.hasMoreElements()) {
            JarEntry var5 = (JarEntry)var4.nextElement();
            String var6 = var5.getName();
            var0 = var0.replace(".", "/");
            if (var6 != null && var6.endsWith(".class") && var6.startsWith(var0)) {
               String var7 = var6.replace(var0, "").replace(".class", "").replace("/", "");
               if (var7.contains("$")) {
                  var7 = var7.split("\\$")[0];
               }

               var3.add(var7);
            }
         }
      } catch (Exception var16) {
      } finally {
         if (var2 != null) {
            try {
               var2.close();
            } catch (Exception var15) {
            }
         }

      }

      return var3;
   }

   public Map<String, Integer> GetCommands(CommandSender var1) {
      TreeMap var2 = new TreeMap();
      Iterator var4 = this.commands.entrySet().iterator();

      while(true) {
         label58:
         while(true) {
            Entry var3;
            do {
               do {
                  do {
                     if (!var4.hasNext()) {
                        return var2;
                     }

                     var3 = (Entry)var4.next();
                  } while(((CMICommand)var3.getValue()).getAnottation().hidden());
               } while(((CMICommand)var3.getValue()).getAnottation().test());
            } while(((CMICommand)var3.getValue()).getEnabled() != null && !((CMICommand)var3.getValue()).getEnabled());

            if (((CMICommand)var3.getValue()).getEnabled() == null) {
               if (((CMICommand)var3.getValue()).getAnottation().modules().length > 0) {
                  String[] var8;
                  int var7 = (var8 = ((CMICommand)var3.getValue()).getAnottation().modules()).length;

                  for(int var6 = 0; var6 < var7; ++var6) {
                     String var5 = var8[var6];
                     if (!CMIModule.isEnabled(var5)) {
                        ((CMICommand)var3.getValue()).setEnabled(false);
                        continue label58;
                     }
                  }
               }

               ((CMICommand)var3.getValue()).setEnabled(true);
            }

            if (var1 == null || hasCommandPermission(var1, (String)var3.getKey(), 5000L)) {
               var2.put((String)var3.getKey(), ((CMICommand)var3.getValue()).getAnottation().priority());
            }
         }
      }
   }

   public void fillCommands() {
      Object var1 = new ArrayList();
      HashMap var2 = new HashMap();

      try {
         var1 = getClassesFromPackage(packagePath);
      } catch (ClassNotFoundException var12) {
         var12.printStackTrace();
      }

      Iterator var4 = ((List)var1).iterator();

      while(var4.hasNext()) {
         String var3 = (String)var4.next();
         Class var5 = getClass(var3);
         if (var5 != null) {
            var2.put(var3, var5);
         }
      }

      var4 = var2.entrySet().iterator();

      while(var4.hasNext()) {
         Entry var14 = (Entry)var4.next();
         Method[] var8;
         int var7 = (var8 = ((Class)var14.getValue()).getMethods()).length;

         for(int var6 = 0; var6 < var7; ++var6) {
            Method var15 = var8[var6];
            if (var15.isAnnotationPresent(CAnnotation.class)) {
               String var9 = (String)var14.getKey();

               try {
                  if (!Cmd.class.isAssignableFrom((Class)var14.getValue())) {
                     break;
                  }

                  Cmd var10 = (Cmd)((Class)var14.getValue()).getConstructor().newInstance();
                  CMICommand var11 = new CMICommand(var10, var9, (CAnnotation)var15.getAnnotation(CAnnotation.class));
                  if (!var11.getAnottation().test() || this.testServer) {
                     this.commands.put(var9.toLowerCase(), var11);
                     break;
                  }
               } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException var13) {
                  Bukkit.getConsoleSender().sendMessage("!!! " + var9);
                  var13.printStackTrace();
                  break;
               }
            }
         }
      }

   }

   private static Class<?> getClass(String var0) {
      Class var1 = null;
      if (var0.toLowerCase().contains("notfinished")) {
         return null;
      } else {
         try {
            var1 = Class.forName(packagePath + "." + var0.toLowerCase());
         } catch (Exception var3) {
            CMI.getInstance().consoleMessage("&cFailed to load " + var0.toLowerCase() + " command!");
            var3.printStackTrace();
         }

         return var1;
      }
   }

   private Cmd getCmdClass(String var1) {
      CMICommand var2 = (CMICommand)this.commands.get(var1.toLowerCase());
      if (var2 == null) {
         return null;
      } else if (var2.getAnottation().test() && !this.testServer) {
         return null;
      } else if (var2.getEnabled() != null && !var2.getEnabled()) {
         this.plugin.consoleMessage("&5Someone tried to use command for disabled module (" + var2.getName() + ")");
         return null;
      } else {
         if (var2.getEnabled() == null) {
            if (var2.getAnottation().modules().length > 0) {
               String[] var6;
               int var5 = (var6 = var2.getAnottation().modules()).length;

               for(int var4 = 0; var4 < var5; ++var4) {
                  String var3 = var6[var4];
                  if (!CMIModule.isEnabled(var3)) {
                     var2.setEnabled(false);
                     this.plugin.consoleMessage("&5Someone tried to use command for disabled module (" + var2.getName() + ")");
                     return null;
                  }
               }
            }

            var2.setEnabled(true);
         }

         return var2.getCmdClass();
      }
   }

   private Cmd getBestCmdmatch(String var1) {
      if (this.plugin.getConfigManager().getOptimizationsSimilarCommandChecker() > 0) {
         Cmd var2 = null;
         int var3 = var1.length() * 2;
         Iterator var5 = this.commands.entrySet().iterator();

         while(var5.hasNext()) {
            Entry var4 = (Entry)var5.next();
            int var6 = distance((String)var4.getKey(), var1);
            if (var6 <= var3) {
               var3 = var6;
               var2 = ((CMICommand)var4.getValue()).getCmdClass();
               if (var6 == 1) {
                  break;
               }
            }
         }

         if (var2 != null) {
            double var7 = 100.0D - (double)var3 * 100.0D / (double)var2.getClass().getSimpleName().length();
            if ((double)this.plugin.getConfigManager().getOptimizationsSimilarCommandChecker() <= var7) {
               return var2;
            }
         }
      }

      return null;
   }

   public static int distance(String var0, String var1) {
      var0 = var0.toLowerCase();
      var1 = var1.toLowerCase();
      int[] var2 = new int[var1.length() + 1];

      int var3;
      for(var3 = 0; var3 < var2.length; var2[var3] = var3++) {
      }

      for(var3 = 1; var3 <= var0.length(); ++var3) {
         var2[0] = var3;
         int var4 = var3 - 1;

         for(int var5 = 1; var5 <= var1.length(); ++var5) {
            int var6 = Math.min(1 + Math.min(var2[var5], var2[var5 - 1]), var0.charAt(var3 - 1) == var1.charAt(var5 - 1) ? var4 : var4 + 1);
            var4 = var2[var5];
            var2[var5] = var6;
         }
      }

      return var2[var1.length()];
   }

   private static Map<String, Integer> sort(Map<String, Integer> var0) {
      LinkedList var1 = new LinkedList(var0.entrySet());
      Collections.sort(var1, new Comparator<Entry<String, Integer>>() {
         public int compare(Entry<String, Integer> var1, Entry<String, Integer> var2) {
            return ((Integer)var1.getValue()).compareTo((Integer)var2.getValue());
         }

         // $FF: synthetic method
         // $FF: bridge method
         public int compare(Object var1, Object var2) {
            return this.compare((Entry)var1, (Entry)var2);
         }
      });
      LinkedHashMap var2 = new LinkedHashMap();
      Iterator var3 = var1.iterator();

      while(var3.hasNext()) {
         Entry var4 = (Entry)var3.next();
         var2.put((String)var4.getKey(), (Integer)var4.getValue());
      }

      return var2;
   }

   public Map<String, CMICommand> getCommands() {
      return this.commands;
   }

   public static String getLabel() {
      return "cmi";
   }

   public boolean isTestServer() {
      return this.testServer;
   }

   public static String getCommandPrefix(String var0) {
      if (var0.startsWith("/")) {
         var0 = var0.substring(1);
      }

      if (var0.startsWith(getLabel() + " ")) {
         var0 = var0.substring(getLabel().length() + 1);
      }

      CommandAlias var1 = CMI.getInstance().getAliasManager().getAliasForCommand(var0);
      return var1 != null && var1.getState() && var1.getType() == CommandAliasType.base ? var1.getAlias() : getLabel() + " " + var0;
   }

   public void setBaseCommandState(String var1, boolean var2) {
      CMICommand var3 = (CMICommand)this.getCommands().get(var1.toLowerCase());
      if (var3 != null) {
         var3.setBaseEnabled(var2);
      }

      if (!var2) {
         this.addDisabledBase(var1.toLowerCase());
      }

   }

   public List<String> getDisabledBase() {
      return this.disabledBase;
   }

   public void clearDisabledBase() {
      this.disabledBase.clear();
   }

   public void addDisabledBase(String var1) {
      this.disabledBase.add(var1);
   }
}