Esempio n. 1
0
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   int npcId = npc.getNpcId();
   int cond = st.getCond();
   if (cond == 3) {
     if (ArrayUtils.contains(SOD, npcId)) {
       st.rollAndGive(
           FleetSteedTroupsTotem,
           (int) Config.RATE_QUESTS_REWARD * 1,
           17); // Шанс на глаз и с потолка. Умножается на рейт квестов и делится на кол-во членов
       // группы. Для нас это (nRate*3)/9
     } else if (ArrayUtils.contains(SOI, npcId)) {
       st.rollAndGive(
           NucleusofanIncompleteSoul,
           (int) Config.RATE_QUESTS_REWARD * 1,
           17); // Шанс на глаз и с потолка. Умножается на рейт квестов и делится на кол-во членов
       // группы. Для нас это (nRate*3)/9
     } else if (ArrayUtils.contains(SOA, npcId)) {
       st.rollAndGive(
           SpiritStoneDust,
           (int) Config.RATE_QUESTS_REWARD * 1,
           20); // Шанс на глаз и с потолка. Умножается на рейт квестов и делится на кол-во членов
       // группы. Для нас это (nRate*3)/9
     }
   }
   return null;
 }
  /**
   * Replace a single conditional compilation variable
   *
   * @param variable something like "@_win32"
   * @return the value
   */
  private static String replaceOneVariable(
      final String variable, final BrowserVersion browserVersion) {
    final String[] varNaN = {
      "@_win16", "@_mac", "@_alpha", "@_mc680x0", "@_PowerPC", "@_debug", "@_fast"
    };
    final String[] varTrue = {"@_win32", "@_x86", "@_jscript"};

    if (ArrayUtils.contains(varTrue, variable)) {
      return "true";
    } else if ("@_jscript_version".equals(variable)) {
      if (browserVersion.getBrowserVersionNumeric() <= 6) {
        return "5.6";
      } else if (browserVersion.getBrowserVersionNumeric() == 7) {
        return "5.7";
      }
      return "5.8";
    } else if ("@_jscript_build".equals(variable)) {
      if (browserVersion.getBrowserVersionNumeric() <= 6) {
        return "6626";
      }
      if (browserVersion.getBrowserVersionNumeric() == 7) {
        return "5730";
      }
      return "18702";
    } else if (ArrayUtils.contains(varNaN, variable)) {
      return "NaN";
    }
    return variable;
  }
 public SeedOfAnnihilationInstance(int objectId, NpcTemplate template) {
   super(objectId, template);
   if (ArrayUtils.contains(BISTAKON_MOBS, template.getNpcId()))
     addMinions(BISTAKON_MINIONS[Rnd.get(BISTAKON_MINIONS.length)], template);
   else if (ArrayUtils.contains(COKRAKON_MOBS, template.getNpcId()))
     addMinions(COKRAKON_MINIONS[Rnd.get(COKRAKON_MINIONS.length)], template);
 }
Esempio n. 4
0
  @SuppressWarnings("rawtypes")
  public static boolean isSirenProperty(Class<?> type, Object obj, Field field) {
    boolean isProp = false;

    Siren4JProperty anno = field.getAnnotation(Siren4JProperty.class);
    if (anno != null || type.isEnum()) {
      isProp = true;
    } else if (ArrayUtils.contains(propertyTypes, type)) {
      isProp = true;
    } else if (obj != null && Collection.class.isAssignableFrom(type)) {
      // Try to determine value type
      if (!((Collection) obj).isEmpty()) {
        Object first = findFirstNonNull(((Collection) obj).iterator());
        if (first == null || ArrayUtils.contains(propertyTypes, first.getClass())) {
          isProp = true;
        }
      }
    } else if (obj != null && Map.class.isAssignableFrom(type)) {
      // Try to determine value types of key and value
      if (!((Map) obj).isEmpty()) {
        Object firstKey = findFirstNonNull(((Map) obj).keySet().iterator());
        Object firstVal = findFirstNonNull(((Map) obj).entrySet().iterator());
        if ((firstKey == null || ArrayUtils.contains(propertyTypes, firstKey.getClass()))
            && (firstVal == null
                || ArrayUtils.contains(
                    propertyTypes, ((HashMap.Entry) firstVal).getValue().getClass()))) {
          isProp = true;
        }
      }
    }
    return isProp;
  }
  /** 创建Content基本信息. */
  private ContentInfo getContentInfo(String contentPath) {
    ContentInfo contentInfo = new ContentInfo();

    String realFilePath = getServletContext().getRealPath(contentPath);
    File file = new File(realFilePath);

    contentInfo.file = file;
    contentInfo.contentPath = contentPath;
    contentInfo.fileName = file.getName();
    contentInfo.length = (int) file.length();

    contentInfo.lastModified = file.lastModified();
    contentInfo.etag = "W/\"" + contentInfo.lastModified + "\"";

    contentInfo.mimeType = mimetypesFileTypeMap.getContentType(contentInfo.fileName);

    if ((contentInfo.length >= GZIP_MINI_LENGTH)
        && ArrayUtils.contains(GZIP_MIME_TYPES, contentInfo.mimeType)) {
      contentInfo.needGzip = true;
    } else {
      contentInfo.needGzip = false;
    }

    return contentInfo;
  }
  @Override
  public String onKill(NpcInstance npc, QuestState st) {
    int npcId = npc.getNpcId();
    int cond = st.getCond();

    if (cond == 3 && ArrayUtils.contains(MOBS_1, npcId) && Rnd.chance(70)) {
      st.giveItems(ELCARDIAS_MARK, 1);
      if (st.getQuestItemsCount(ELCARDIAS_MARK) < 10) st.playSound(SOUND_ITEMGET);
      else {
        st.playSound(SOUND_MIDDLE);
        st.setCond(4);
      }
    } else if (npcId == CREATURE_OF_THE_DUSK_1) {
      st.set("CreatureOfTheDusk1", 2);
      if (st.get("CreatureOfTheDusk2") != null
          && Integer.parseInt(st.get("CreatureOfTheDusk2")) == 2) {
        st.playSound(SOUND_MIDDLE);
        st.setCond(6);
      }
    } else if (npcId == CREATURE_OF_THE_DUSK_2) {
      st.set("CreatureOfTheDusk2", 2);
      if (st.get("CreatureOfTheDusk1") != null
          && Integer.parseInt(st.get("CreatureOfTheDusk1")) == 2) {
        st.playSound(SOUND_MIDDLE);
        st.setCond(6);
      }
    }
    return null;
  }
  /**
   * 部署classpath下面的流程定义
   *
   * <p>从属性配置文件中获取属性<b>workflow.modules</b>扫描**deployments**
   *
   * <p>然后从每个**deployments/${module}**查找在属性配置文件中的属性**workflow.module.keys.${ submodule}**
   *
   * <p>配置实例:
   *
   * <p>
   *
   * <pre>
   * #workflow for deploy
   * workflow.modules=budget,erp,oa
   * workflow.module.keys.budget=budget
   * workflow.module.keys.erp=acceptInsurance,billing,effectInsurance,endorsement,payment
   * workflow.module.keys.oa=caruse,leave,officalstamp,officesupply,out,overtime
   * </pre>
   *
   * <p>
   *
   * @param processKey 流程定义KEY
   * @throws Exception
   */
  public void deployFromClasspath(String exportDir, String... processKey) throws Exception {
    ResourceLoader resourceLoader = new DefaultResourceLoader();
    String[] processKeys = {"leave", "leave-dynamic-from", "leave-formkey", "dispatch"};
    for (String loopProcessKey : processKeys) {

      /*
       * 需要过滤指定流程
       */
      if (ArrayUtils.isNotEmpty(processKey)) {
        if (ArrayUtils.contains(processKey, loopProcessKey)) {
          logger.debug("hit module of {}", processKey);
          deploySingleProcess(resourceLoader, loopProcessKey, exportDir);
        } else {
          logger.debug(
              "module: {} not equals process key: {}, ignore and continue find next.",
              loopProcessKey,
              processKey);
        }
      } else {
        /*
         * 所有流程
         */
        deploySingleProcess(resourceLoader, loopProcessKey, exportDir);
      }
    }
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) {
    QuestState st = killer.getQuestState(getClass());

    if (npc == null || st == null) {
      return null;
    }

    if (st.getCond() == 1) {
      if (ArrayUtils.contains(ДревниеГерои, npc.getNpcId())) {
        if (killer.getParty() == null) {
          st.giveItem(ПроклятаяСлизь);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          if (st.getQuestItemsCount(ПроклятаяСлизь) >= 8) {
            st.setCond(2);
            st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          }
        } else {
          QuestState pst = killer.getParty().getRandomPartyMember().getQuestState(getClass());
          if (pst != null && pst.getCond() == 1) {
            pst.giveItem(ПроклятаяСлизь);
            pst.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
            if (pst.getQuestItemsCount(ПроклятаяСлизь) >= 8) {
              pst.setCond(2);
              pst.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
            }
          }
        }
      }
    }
    return super.onKill(npc, killer, isPet);
  }
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   Player player = st.getPlayer();
   int npcId = npc.getNpcId();
   int refId = player.getReflectionId();
   if (npcId == KAMS && st.getQuestItemsCount(KDROP) == 0) {
     st.giveItems(KDROP, 1);
   } else if (npcId == ALKASO && st.getQuestItemsCount(ADROP) == 0) {
     st.giveItems(ADROP, 1);
   } else if (npcId == LEMATAN) {
     st.setCond(4);
     st.playSound(SOUND_MIDDLE);
     addSpawnToInstance(DADVENTURER2, new Location(84990, -208376, -3342, 55000), 0, refId);
   } else if (ArrayUtils.contains(Pailaka2nd, npcId)) {
     if (Rnd.get(100) < 80) {
       st.dropItem(npc, HERBS[Rnd.get(HERBS.length)], Rnd.get(1, 2));
     }
   } else if (npcId == CHEST) {
     if (Rnd.get(100) < 80) {
       st.dropItem(npc, CHESTDROP[Rnd.get(CHESTDROP.length)], Rnd.get(1, 10));
     }
   }
   // TODO вернуть когда будут работать двери
   // else
   //	dropItem(npc, KEY, 1);
   return null;
 }
Esempio n. 10
0
  @Override
  public void addSessionId(final String sessionId) {

    try {

      final String[] ids = getProperty(Principal.sessionIds);
      if (ids != null) {

        if (!ArrayUtils.contains(ids, sessionId)) {

          setProperty(
              Principal.sessionIds,
              (String[]) ArrayUtils.add(getProperty(Principal.sessionIds), sessionId));
        }

      } else {

        setProperty(Principal.sessionIds, new String[] {sessionId});
      }

    } catch (FrameworkException ex) {
      logger.log(
          Level.SEVERE, "Could not add sessionId " + sessionId + " to array of sessionIds", ex);
    }
  }
Esempio n. 11
0
 private static void reflectionAppend(
     Object obj,
     Object obj1,
     Class class1,
     CompareToBuilder comparetobuilder,
     boolean flag,
     String as[]) {
   Field afield[] = class1.getDeclaredFields();
   AccessibleObject.setAccessible(afield, true);
   int i = 0;
   do {
     if (i >= afield.length || comparetobuilder.comparison != 0) {
       return;
     }
     Field field = afield[i];
     if (!ArrayUtils.contains(as, field.getName())
         && field.getName().indexOf('$') == -1
         && (flag || !Modifier.isTransient(field.getModifiers()))
         && !Modifier.isStatic(field.getModifiers())) {
       try {
         comparetobuilder.append(field.get(obj), field.get(obj1));
       } catch (IllegalAccessException illegalaccessexception) {
         throw new InternalError("Unexpected IllegalAccessException");
       }
     }
     i++;
   } while (true);
 }
Esempio n. 12
0
 @Transactional
 public void update(Node node, Integer[] viewOrgIds) {
   if (viewOrgIds == null) {
     viewOrgIds = new Integer[0];
   }
   SortedSet<NodeOrg> nodeOrgs = node.getNodeOrgs();
   if (nodeOrgs == null) {
     nodeOrgs = new TreeSet<NodeOrg>(new NodeOrgComparator());
     node.setNodeOrgs(nodeOrgs);
   }
   // 先更新
   for (NodeOrg nodeOrg : nodeOrgs) {
     if (ArrayUtils.contains(viewOrgIds, nodeOrg.getOrg().getId())) {
       nodeOrg.setViewPerm(true);
     } else {
       nodeOrg.setViewPerm(false);
     }
   }
   // 再新增
   for (Integer viewOrgId : viewOrgIds) {
     boolean contains = false;
     for (NodeOrg nodeOrg : nodeOrgs) {
       if (nodeOrg.getOrg().getId().equals(viewOrgId)) {
         contains = true;
         break;
       }
     }
     if (!contains) {
       nodeOrgs.add(save(node, viewOrgId, true));
     }
   }
 }
  @Test
  public void testAppendAndDelete() throws Exception {
    int cap = 1024;
    int count = 10;
    int deleteSpace = 0;
    ByteBuffer buffer = makeAFrame(cap, count, deleteSpace);
    int dataOffset = buffer.position();
    appender.reset(buffer);

    int freeSpace = appender.getContiguousFreeSpace();
    int[] deleteSet = new int[] {1, 3, 5};
    for (int i = 0; i < deleteSet.length; i++) {
      deleteSpace += assertDeleteSucceed(deleteSet[i], freeSpace, deleteSpace);
    }

    ByteBuffer bufferRead = makeAFrame(cap, count * 2, 0);
    DeletableFrameTupleAppender accessor = new DeletableFrameTupleAppender(recordDescriptor);
    accessor.reset(bufferRead);

    for (int i = count; i < accessor.getTupleCount(); i++) {
      int id = appender.append(accessor, i);
      dataOffset += assertTupleIsExpected(i, dataOffset);
      assertEquals(i, id);
    }

    appender.reOrganizeBuffer();
    dataOffset = 0;
    for (int i = 0; i < appender.getTupleCount(); i++) {
      if (ArrayUtils.contains(deleteSet, i)) {
        continue;
      }
      dataOffset += assertTupleIsExpected(i, dataOffset);
    }
  }
 private void updateEnableState() {
   final SharedPreferences prefs = getSharedPreferences();
   if (prefs == null || mDependencyKey == null || mDependencyValues == null) return;
   final Map<String, ?> all = prefs.getAll();
   final String valueString =
       ParseUtils.parseString(all.get(mDependencyKey), mDependencyValueDefault);
   setEnabled(ArrayUtils.contains(mDependencyValues, valueString));
 }
Esempio n. 15
0
 private ISpell[] getCircleFilteredSpellList(ISpell[] spells) {
   List<ISpell> spellList = new ArrayList<>();
   for (ISpell spell : spells) {
     if (ArrayUtils.contains(spellModel.getCircles(), spell.getCircleType())) {
       spellList.add(spell);
     }
   }
   return spellList.toArray(new ISpell[spellList.size()]);
 }
Esempio n. 16
0
 /**
  * Constructor for RewardData.
  *
  * @param itemId int
  */
 public RewardData(int itemId) {
   _item = ItemHolder.getInstance().getTemplate(itemId);
   if (_item.isArrow()
       || (Config.NO_RATE_EQUIPMENT && _item.isEquipment())
       || (Config.NO_RATE_KEY_MATERIAL && _item.isKeyMatherial())
       || (Config.NO_RATE_RECIPES && _item.isRecipe())
       || ArrayUtils.contains(Config.NO_RATE_ITEMS, itemId)) {
     _notRate = true;
   }
 }
Esempio n. 17
0
 private boolean isKorteMaand(int maand) {
   //        boolean zitErin = false;
   //
   //        for (int i = 0; i < korteMaanden.length; i++) {
   //            if (maand == korteMaanden[i]) {
   //                zitErin = true;
   //            }
   //        }
   //        return zitErin;
   return ArrayUtils.contains(korteMaanden, maand);
 }
 /** Check if the given {@link Element} is visible in the given {@link Source}. */
 protected static boolean isInTheSameLibrary(
     Element element, AnalysisContext context, Source source) {
   // should be the same AnalysisContext
   if (!isInContext(element, context)) {
     return false;
   }
   // private elements are visible only in their library
   Source[] librarySourcesOfSource = context.getLibrariesContaining(source);
   Source librarySourceOfElement = element.getLibrary().getSource();
   return ArrayUtils.contains(librarySourcesOfSource, librarySourceOfElement);
 }
Esempio n. 19
0
 // Hack: ToRemove when doors will operate normally in reflections
 private void blockUnblockNpcs(boolean block, int[] npcArray) {
   for (NpcInstance n : getNpcs())
     if (ArrayUtils.contains(npcArray, n.getNpcId())) {
       if (block) {
         n.block();
         n.setIsInvul(true);
       } else {
         n.unblock();
         n.setIsInvul(false);
       }
     }
 }
Esempio n. 20
0
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   int cond = st.getCond();
   boolean doneKill = updateKill(npc, st);
   if (cond == 1) {
     if (ArrayUtils.contains(Mobs, npc.getNpcId())) {
       Party party = st.getPlayer().getParty();
       if (party != null) {
         for (Player member : party.getPartyMembers()) {
           QuestState qs = member.getQuestState(getClass());
           if (qs != null && qs.isStarted()) {
             if (st.getQuestItemsCount(Deadmans_Flesh) < 40) {
               qs.giveItems(Deadmans_Flesh, 1);
               qs.playSound(SOUND_ITEMGET);
               if (doneKill && st.getQuestItemsCount(Deadmans_Flesh) == 40) {
                 st.setCond(2);
               }
             }
           }
         }
       } else {
         if (st.getQuestItemsCount(Deadmans_Flesh) < 50) {
           st.giveItems(Deadmans_Flesh, 1);
           st.playSound(SOUND_ITEMGET);
           if (doneKill && st.getQuestItemsCount(Deadmans_Flesh) == 40) {
             st.setCond(2);
           }
         }
       }
     }
     if (npc.getNpcId() == Scaldisect) {
       Party party = st.getPlayer().getParty();
       if (party != null) {
         for (Player member : party.getPartyMembers()) {
           QuestState qs = member.getQuestState(getClass());
           if (qs != null && qs.isStarted()) {
             updateKill(npc, st);
             if (st.getQuestItemsCount(Deadmans_Flesh) == 40) {
               st.setCond(2);
             }
           }
         }
       } else {
         updateKill(npc, st);
         if (st.getQuestItemsCount(Deadmans_Flesh) == 40) {
           st.setCond(2);
         }
       }
     }
   }
   return null;
 }
Esempio n. 21
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    if (actor == null || actor.isDead()) return true;

    if (_def_think) {
      doTask();
      return true;
    }

    if (diedTeredor < 3 || currentPoint >= MOVE_LOC.length - 1) {
      List<Creature> list =
          World.getAroundCharacters(
              getActor(), getActor().getAggroRange(), getActor().getAggroRange());
      for (Creature target : list) {
        if (target != null
            && !target.isDead()
            && ArrayUtils.contains(ATTACK_IDS, target.getNpcId())) {
          Skill sk = SkillTable.getInstance().getInfo(SKILL_ID, 1);
          if (lastCastTime + sk.getHitTime() + sk.getReuseDelay() <= System.currentTimeMillis()) {
            lastCastTime = System.currentTimeMillis();
            clearTasks();
            addTaskCast(target, sk);
            return true;
          }
          return false;
        }
      }
    } else if (diedTeredor >= 3 && currentPoint < MOVE_LOC.length - 1) {
      if (loc == null || getActor().getDistance(loc) <= 100) {
        currentPoint++;
        loc =
            new Location(
                MOVE_LOC[currentPoint].getX() + Rnd.get(50) - Rnd.get(50),
                MOVE_LOC[currentPoint].getY() + Rnd.get(50) - Rnd.get(50),
                MOVE_LOC[currentPoint].getZ() + Rnd.get(50) - Rnd.get(50));
        if (currentPoint == 0) {
          Reflection r = getActor().getReflection();
          if (r instanceof MemoryOfDisaster) {
            ((MemoryOfDisaster) r).spawnTransparentTeredor();
          }
        }
      }
      actor.setWalking();
      clearTasks();
      addTaskMove(loc, true);
      doTask();
      return true;
    }
    return false;
  }
Esempio n. 22
0
 /** {@inheritDoc} */
 public void apply(HSSFCell cell, HSSFCellStyle cellStyle, Map<String, String> style) {
   for (String pos : new String[] {TOP, RIGHT, BOTTOM, LEFT}) {
     String posName = StringUtils.capitalize(pos.toLowerCase());
     // color
     String colorAttr = BORDER + "-" + pos + "-" + COLOR;
     HSSFColor poiColor = CssUtils.parseColor(cell.getSheet().getWorkbook(), style.get(colorAttr));
     if (poiColor != null) {
       try {
         MethodUtils.invokeMethod(cellStyle, "set" + posName + "BorderColor", poiColor.getIndex());
       } catch (Exception e) {
         log.error("Set Border Color Error Caused.", e);
       }
     }
     // width
     int width = CssUtils.getInt(style.get(BORDER + "-" + pos + "-" + WIDTH));
     String styleAttr = BORDER + "-" + pos + "-" + STYLE;
     String styleValue = style.get(styleAttr);
     short shortValue = -1;
     // empty or solid
     if (StringUtils.isBlank(styleValue) || "solid".equals(styleValue)) {
       if (width > 2) {
         shortValue = CellStyle.BORDER_THICK;
       } else if (width > 1) {
         shortValue = CellStyle.BORDER_MEDIUM;
       } else {
         shortValue = CellStyle.BORDER_THIN;
       }
     } else if (ArrayUtils.contains(new String[] {NONE, HIDDEN}, styleValue)) {
       shortValue = CellStyle.BORDER_NONE;
     } else if (DOUBLE.equals(styleValue)) {
       shortValue = CellStyle.BORDER_DOUBLE;
     } else if (DOTTED.equals(styleValue)) {
       shortValue = CellStyle.BORDER_DOTTED;
     } else if (DASHED.equals(styleValue)) {
       if (width > 1) {
         shortValue = CellStyle.BORDER_MEDIUM_DASHED;
       } else {
         shortValue = CellStyle.BORDER_DASHED;
       }
     }
     // border style
     if (shortValue != -1) {
       try {
         MethodUtils.invokeMethod(cellStyle, "setBorder" + posName, shortValue);
       } catch (Exception e) {
         log.error("Set Border Style Error Caused.", e);
       }
     }
   }
 }
Esempio n. 23
0
 @Override
 public String onKill(NpcInstance npc, QuestState st) {
   int cond = st.getCond();
   if ((cond != 1) || (npc == null)) {
     return null;
   }
   if ((ArrayUtils.contains(Mobs, npc.getNpcId())) && (Rnd.chance(50))) {
     st.giveItems(19496, 1L);
   }
   if (st.getQuestItemsCount(19496) >= 45L) {
     st.setCond(2);
   }
   return null;
 }
Esempio n. 24
0
  public Upload(Composite parent, int style, int... uploadStyles) {
    super(parent, style);
    setLayout(FormLayoutFactory.defaults().create());

    fileUpload = new FileUpload(this, SWT.NONE);
    fileUpload.setLayoutData(FormDataFactory.filled().create());
    fileUpload.setText(i18n.get("select"));
    fileUpload.setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE);
    setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE);

    fileUpload.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent ev) {
            UIUtils.activateCallback("upload");
            fileUpload.submit(UploadService.registerHandler(Upload.this));
          }
        });

    if (ArrayUtils.contains(uploadStyles, SHOW_UPLOAD_BUTTON)) {
      log.info("SHOW_UPLOAD_BUTTON is not supported yet.");
    }

    if (ArrayUtils.contains(uploadStyles, SHOW_PROGRESS)) {
      fileUpload.setLayoutData(FormDataFactory.filled().noRight().create());

      progress = new ProgressBar(this, SWT.HORIZONTAL);
      progress.setLayoutData(FormDataFactory.filled().left(fileUpload).create());
      progress.setMaximum(Integer.MAX_VALUE);

      progressLabel = new Label(this, SWT.NONE);
      progressLabel.setLayoutData(FormDataFactory.filled().top(0, 5).left(fileUpload, 20).create());
      progressLabel.setText(i18n.get("progressLabel"));
      log.warn("not yet ported: progressLabel.setForeground( new Color( 0x60, 0x60, 0x60 ) ) ");
      progressLabel.moveAbove(progress);
    }
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    QuestState st = player.getQuestState(getClass());
    if (st == null) {
      return null;
    }

    int npcId = npc.getNpcId();
    if (ArrayUtils.contains(MOBS, npcId)) {
      if (st.getState() == STARTED) {
        st.dropQuestItems(SPIRIT_BEAD, 1, -1, DROP_CHANCE, true);
      } else {
        return null;
      }
    }
    return super.onKill(npc, player, isPet);
  }
  @Override
  public boolean onCommand(
      CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
    Command command = new Command(label, sender, args);

    for (String[] commandNames : mappedCommandClasses.keySet()) {
      if (ArrayUtils.contains(commandNames, label.toLowerCase())) {
        Class<? extends CommandExecutor> commandClass = mappedCommandClasses.get(commandNames);

        for (CommandExecutor executor : getExecutors(commandClass)) {
          // Find all command executors for that command, and execute

          try {
            boolean executed =
                ((boolean)
                    commandClass
                        .getMethod(commandNames[0] + "Command", Command.class)
                        .invoke(executor, command));

            if (executed) return true;
          } catch (IllegalAccessException
              | IllegalArgumentException
              | InvocationTargetException
              | NoSuchMethodException
              | SecurityException e) {
            e.printStackTrace();

            Util.noticeableConsoleMessage(
                "Could not invoke the method: "
                    + commandNames[0]
                    + "Command, in the command class");
          }
        }

        // Send user message because the command was not handled by anyone

        command.sendSenderMessage("Usage: /{cmd} <subcommand>", ChatColor.RED);

        return true;
      }
    }

    return true;
  }
Esempio n. 27
0
 /**
  * Replaces field tokens with the actual value in the fields. The field types must be simple
  * property types
  *
  * @param str
  * @param fields info
  * @param parentMode
  * @param obj
  * @return
  * @throws Siren4JException
  */
 public static String replaceFieldTokens(
     Object obj, String str, List<ReflectedInfo> fields, boolean parentMode)
     throws Siren4JException {
   Map<String, Field> index = new HashMap<String, Field>();
   if (StringUtils.isBlank(str)) {
     return str;
   }
   if (fields != null) {
     for (ReflectedInfo info : fields) {
       Field f = info.getField();
       if (f != null) {
         index.put(f.getName(), f);
       }
     }
   }
   try {
     for (String key : ReflectionUtils.getTokenKeys(str)) {
       if ((!parentMode && !key.startsWith("parent."))
           || (parentMode && key.startsWith("parent."))) {
         String fieldname = key.startsWith("parent.") ? key.substring(7) : key;
         if (index.containsKey(fieldname)) {
           Field f = index.get(fieldname);
           if (f.getType().isEnum() || ArrayUtils.contains(propertyTypes, f.getType())) {
             String replacement = "";
             Object theObject = f.get(obj);
             if (f.getType().isEnum()) {
               replacement = theObject == null ? "" : ((Enum) theObject).name();
             } else {
               replacement = theObject == null ? "" : theObject.toString();
             }
             str = str.replaceAll("\\{" + key + "\\}", Matcher.quoteReplacement("" + replacement));
           }
         }
       }
     }
   } catch (Exception e) {
     throw new Siren4JException(e);
   }
   return str;
 }
 @Override
 public void selectGameProfile(GameProfile profile) throws AuthenticationException {
   if (!this.isLoggedIn()) {
     throw new AuthenticationException("Cannot change game profile whilst not logged in");
   }
   if (this.getSelectedProfile() != null) {
     throw new AuthenticationException("Cannot change game profile. You must log out and back in");
   }
   if (profile == null || !ArrayUtils.contains(this.profiles, profile)) {
     throw new IllegalArgumentException("Invalid profile '" + profile + "'");
   }
   RefreshRequest request = new RefreshRequest(this, profile);
   RefreshResponse response =
       this.getAuthenticationService().makeRequest(routeRefresh, request, RefreshResponse.class);
   if (!response.getClientToken().equals(this.getAuthenticationService().getClientToken())) {
     throw new AuthenticationException(
         "Server requested we change our client token. Don't know how to handler this!");
   }
   this.isOnline = true;
   this.accessToken = response.getAccessToken();
   this.setSelectedProfile(response.getSelectedProfile());
 }
Esempio n. 29
0
 public QuestsView(final long characterId, final ClientAchievementsContext context) {
   super(characterId);
   this.m_achievementsContext = context;
   final ArrayList<Category> rootCategories = AchievementsModel.INSTANCE.getRootCategories();
   Category questCategory = null;
   for (final Category category : rootCategories) {
     final int id = category.getId();
     if (id == 4) {
       questCategory = category;
       break;
     }
   }
   if (questCategory == null) {
     QuestsView.m_logger.error(
         (Object) "Probl\u00e8me d'export, pas de cat\u00e9gorie des qu\u00eates !!!");
     return;
   }
   final ArrayList<Category> children = questCategory.getChildren();
   if (children == null) {
     QuestsView.m_logger.error(
         (Object) "Probl\u00e8me d'export, la cat\u00e9gorie des qu\u00eates est vide !!!");
     return;
   }
   for (final Category subCategory : children) {
     final int subId = subCategory.getId();
     final boolean visible =
         !ArrayUtils.contains(AchievementConstants.HIDDEN_QUEST_CATEGORIES, subId);
     AchievementsViewManager.INSTANCE.createCategoryView(this.m_characterId, subCategory, null);
     if (visible) {
       final AchievementCategoryView categoryView =
           AchievementsViewManager.INSTANCE.getCategory(this.m_characterId, subCategory.getId());
       this.m_rootCategories.put(subId, categoryView);
       this.m_sortedRootCategories.add(categoryView);
     }
   }
   this.m_selectedRootCategory = this.m_sortedRootCategories.get(0);
 }
Esempio n. 30
0
 @Override
 public void onDeath(Creature self, Creature killer) {
   if (self.isNpc()) {
     if (self.getNpcId() == HallAlarmDevice) {
       for (int i = 0; i < hallADoors.length; i++) openDoor(hallADoors[i]);
       blockUnblockNpcs(false, blockANpcs);
       for (NpcInstance n : getNpcs())
         if (ArrayUtils.contains(blockANpcs, n.getNpcId()))
           n.getAI()
               .notifyEvent(
                   CtrlEvent.EVT_AGGRESSION,
                   getPlayers().get(Rnd.get(getPlayers().size())),
                   200);
     } else if (ArrayUtils.contains(blockANpcs, self.getNpcId())) {
       // ToCheck: find easier way
       for (NpcInstance n : getNpcs())
         if (ArrayUtils.contains(blockANpcs, n.getNpcId()) && !n.isDead()) return;
       for (int i = 0; i < corridorADoors.length; i++) openDoor(corridorADoors[i]);
       blockUnblockNpcs(true, blockBNpcs);
     } else if (self.getNpcId() == DarkChoirPlayer) {
       for (NpcInstance n : getNpcs())
         if (n.getNpcId() == DarkChoirPlayer && !n.isDead()) return;
       for (int i = 0; i < hallBDoors.length; i++) openDoor(hallBDoors[i]);
       blockUnblockNpcs(false, blockBNpcs);
     } else if (ArrayUtils.contains(blockBNpcs, self.getNpcId())) {
       if (Rnd.chance(10)) ((NpcInstance) self).dropItem(killer.getPlayer(), DewdropItem, 1);
       // ToCheck: find easier way
       for (NpcInstance n : getNpcs())
         if ((ArrayUtils.contains(blockBNpcs, n.getNpcId())
                 || ArrayUtils.contains(blockANpcs, n.getNpcId()))
             && !n.isDead()) return;
       for (int i = 0; i < corridorBDoors.length; i++) openDoor(corridorBDoors[i]);
       ThreadPoolManager.getInstance().schedule(new FrintezzaStart(), battleStartDelay);
     } else if (self.getNpcId() == _weakScarletId) {
       self.decayMe();
       return;
     } else if (self.getNpcId() == _strongScarletId) {
       ThreadPoolManager.getInstance().schedule(new Die(1), 10);
       setReenterTime(System.currentTimeMillis());
     }
   }
 }