コード例 #1
0
ファイル: ParticleEffect.java プロジェクト: wizjany/craftbook
  @Override
  public void load() {

    String[] eff =
        RegexUtil.COLON_PATTERN.split(RegexUtil.EQUALS_PATTERN.split(getSign().getLine(2))[0], 2);
    try {
      effectID = Integer.parseInt(eff[0]);
    } catch (Exception e) {
      effectID = Effect.valueOf(eff[0]).getId();
    }
    if (Effect.getById(effectID) == null) return;
    try {
      effectData = Integer.parseInt(eff[1]);
    } catch (Exception e) {
      effectData = 0;
    }

    try {
      times = Integer.parseInt(getSign().getLine(3));
    } catch (Exception ignored) {
      times = 1;
    }

    try {
      String[] off =
          RegexUtil.COLON_PATTERN.split(RegexUtil.EQUALS_PATTERN.split(getSign().getLine(2))[1], 2);
      offset =
          new Vector(
              Double.parseDouble(off[0]), Double.parseDouble(off[1]), Double.parseDouble(off[2]));
    } catch (Exception e) {
      offset = new Vector(0, 1, 0);
    }
  }
コード例 #2
0
ファイル: ParticleEffect.java プロジェクト: wizjany/craftbook
  public void doEffect() {

    try {
      if (effectID == 0) return;
      if (effectID == 2001 && BlockType.fromID(effectData) == null) return;
      Block b = SignUtil.getBackBlock(BukkitUtil.toSign(getSign()).getBlock());
      for (int i = 0; i < times; i++) {
        b.getWorld()
            .playEffect(b.getLocation().add(offset), Effect.getById(effectID), effectData, 50);
      }
    } catch (Exception ignored) {
    }
  }