コード例 #1
0
ファイル: BaseExecutor.java プロジェクト: Jujutan/BattleArena
            public int compare(MethodWrapper mw1, MethodWrapper mw2) {
              MCCommand cmd1 = mw1.getCommand();
              MCCommand cmd2 = mw2.getCommand();

              int c = new Float(mw1.getHelpOrder()).compareTo(mw2.getHelpOrder());
              if (c != 0) return c;
              c = new Integer(cmd1.order()).compareTo(cmd2.order());
              return c != 0 ? c : new Integer(cmd1.hashCode()).compareTo(cmd2.hashCode());
            }
コード例 #2
0
ファイル: BaseExecutor.java プロジェクト: Jujutan/BattleArena
 private void addMethod(Object obj, Method method, MCCommand mc, String cmd) {
   int ml = method.getParameterTypes().length;
   if (mc.subCmds().length == 0) {
     TreeMap<Integer, MethodWrapper> mthds = methods.get(cmd);
     if (mthds == null) {
       mthds = new TreeMap<Integer, MethodWrapper>();
     }
     int order =
         (mc.order() != -1 ? mc.order() * 100000 : Integer.MAX_VALUE) - ml * 100 - mthds.size();
     MethodWrapper mw = new MethodWrapper(obj, method);
     mthds.put(order, mw);
     methods.put(cmd, mthds);
     addUsage(mw, mc);
   } else {
     Map<String, TreeMap<Integer, MethodWrapper>> basemthds = subCmdMethods.get(cmd);
     if (basemthds == null) {
       basemthds = new HashMap<String, TreeMap<Integer, MethodWrapper>>();
       subCmdMethods.put(cmd, basemthds);
     }
     for (String subcmd : mc.subCmds()) {
       TreeMap<Integer, MethodWrapper> mthds = basemthds.get(subcmd);
       if (mthds == null) {
         mthds = new TreeMap<Integer, MethodWrapper>();
         basemthds.put(subcmd, mthds);
       }
       int order =
           (mc.order() != -1 ? mc.order() * 100000 : Integer.MAX_VALUE) - ml * 100 - mthds.size();
       MethodWrapper mw = new MethodWrapper(obj, method);
       /// Set help order
       if (mc.helpOrder() == Integer.MAX_VALUE) {
         mw.helpOrder = (float) (Integer.MAX_VALUE - usage.size());
       }
       mthds.put(order, mw);
       addUsage(mw, mc);
     }
   }
 }