@Override
  public boolean cast(final Player p) {
    HPS.SpellTargeter.register(
        p,
        new SpellHitEvent() {

          @Override
          public void hitBlock(Block block) {
            if (isValidBlock(block) && blockAboveIsValidBlock(block)) {
              getBlockAbove(block).setType(Material.RED_ROSE);
              return;
            } else {
              HPS.PM.warn(p, HPS.Localisation.getTranslation("spellNoRose"));
              return;
            }
          }

          @Override
          public void hitEntity(LivingEntity entity) {
            HPS.PM.warn(p, HPS.Localisation.getTranslation("spellBlockOnly"));
          }
        },
        1f,
        ParticleEffect.HEART);
    return true;
  }
Example #2
0
  public boolean cast(final Player p) {
    HPS.SpellTargeter.register(
        p,
        new SpellHitEvent() {

          @Override
          public void hitBlock(Block block) {
            HPS.PM.warn(p, HPS.Localisation.getTranslation("spellLivingEntityOnly"));
          }

          @Override
          public void hitEntity(LivingEntity entity) {

            int duration = (int) getTime("duration", 100l);

            entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration, 1));

            if (entity instanceof Player) {
              final Player player = (Player) entity;
              Deprimo.players.add(player.getName());
              Bukkit.getServer()
                  .getScheduler()
                  .scheduleSyncDelayedTask(
                      HPS,
                      new Runnable() {

                        @Override
                        public void run() {
                          Deprimo.players.remove(player.getName());
                        }
                      },
                      400L);
            }
            return;
          }
        },
        1f,
        ParticleEffect.CRIT_MAGIC);
    return true;
  }