@SuppressWarnings("unchecked") private final static void registerExecutor() { if (registeredExecutor) return; for (final Class<? extends Event> c : new Class[] {BlockExpEvent.class, EntityDeathEvent.class, ExpBottleEvent.class, PlayerFishEvent.class}) Bukkit.getPluginManager().registerEvent(c, new Listener() {}, SkriptConfig.defaultEventPriority.value(), executor, Skript.getInstance(), true); }
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) { if (!ScriptLoader.isCurrentEvent(BlockExpEvent.class)) { Skript.error("You can not use Block xp expression in any event but on block xp drop!"); return false; } return true; }
@Override public void change(Event e, Object[] delta, Changer.ChangeMode mode){ Number xp = (Number)delta[0]; Number xpNow = ((BlockExpEvent)e).getExpToDrop(); if (mode == ChangeMode.SET) { ((BlockExpEvent)e).setExpToDrop(xp.intValue()); } else if (mode == ChangeMode.ADD) { ((BlockExpEvent)e).setExpToDrop(xpNow.intValue() + xp.intValue()); } else if (mode == ChangeMode.REMOVE) { ((BlockExpEvent)e).setExpToDrop(xpNow.intValue() - xp.intValue()); } }
@EventHandler public void onDropXpEvent(BlockExpEvent event) { if(plugin.isXpBar()) { if(event.getExpToDrop() != 0) { event.setExpToDrop(0); } } }
@Override @Nullable protected Number[] get(Event e) { return new Number[]{((BlockExpEvent)e).getExpToDrop()}; }
@EventHandler public void mineXP(BlockExpEvent e) { if (!RUtils.isInInfectedWorld(e.getBlock().getLocation())) return; e.setExpToDrop(0); }