cn.nukkit.utils.EventException Java Examples

The following examples show how to use cn.nukkit.utils.EventException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegisteredListener.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public void callEvent(Event event) throws EventException {
    if (event instanceof Cancellable) {
        if (event.isCancelled() && isIgnoringCancelled()) {
            return;
        }
    }
    this.timing.startTiming();
    executor.execute(listener, event);
    this.timing.stopTiming();
}
 
Example #2
Source File: EntityDamageEvent.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public EntityDamageEvent(Entity entity, DamageCause cause, Map<DamageModifier, Float> modifiers) {
    this.entity = entity;
    this.cause = cause;
    this.modifiers = modifiers;

    this.originals = this.modifiers;

    if (!this.modifiers.containsKey(DamageModifier.BASE)) {
        throw new EventException("BASE Damage modifier missing");
    }

    if (entity.hasEffect(Effect.DAMAGE_RESISTANCE)) {
        this.setDamage((float) -(this.getDamage(DamageModifier.BASE) * 0.20 * (entity.getEffect(Effect.DAMAGE_RESISTANCE).getAmplifier() + 1)), DamageModifier.RESISTANCE);
    }
}
 
Example #3
Source File: RegisteredListener.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void callEvent(Event event) throws EventException {
    if (event instanceof Cancellable) {
        if (event.isCancelled() && isIgnoringCancelled()) {
            return;
        }
    }
    this.timing.startTiming();
    executor.execute(listener, event);
    this.timing.stopTiming();
}
 
Example #4
Source File: EntityDamageEvent.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public EntityDamageEvent(Entity entity, DamageCause cause, Map<DamageModifier, Float> modifiers) {
    this.entity = entity;
    this.cause = cause;
    this.modifiers = new EnumMap<>(modifiers);

    this.originals = ImmutableMap.copyOf(this.modifiers);

    if (!this.modifiers.containsKey(DamageModifier.BASE)) {
        throw new EventException("BASE Damage modifier missing");
    }

    if (entity.hasEffect(Effect.DAMAGE_RESISTANCE)) {
        this.setDamage((float) -(this.getDamage(DamageModifier.BASE) * 0.20 * (entity.getEffect(Effect.DAMAGE_RESISTANCE).getAmplifier() + 1)), DamageModifier.RESISTANCE);
    }
}
 
Example #5
Source File: RegisteredListener.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void callEvent(Event event) throws EventException {
    if (event instanceof Cancellable) {
        if (event.isCancelled() && isIgnoringCancelled()) {
            return;
        }
    }
    this.timing.startTiming();
    executor.execute(listener, event);
    this.timing.stopTiming();
}
 
Example #6
Source File: EntityDamageEvent.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public EntityDamageEvent(Entity entity, DamageCause cause, Map<DamageModifier, Float> modifiers) {
    this.entity = entity;
    this.cause = cause;
    this.modifiers = modifiers;

    this.originals = this.modifiers;

    if (!this.modifiers.containsKey(DamageModifier.BASE)) {
        throw new EventException("BASE Damage modifier missing");
    }

    if (entity.hasEffect(Effect.DAMAGE_RESISTANCE)) {
        this.setDamage((float) -(this.getDamage(DamageModifier.BASE) * 0.20 * (entity.getEffect(Effect.DAMAGE_RESISTANCE).getAmplifier() + 1)), DamageModifier.RESISTANCE);
    }
}
 
Example #7
Source File: Event.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public boolean isCancelled() {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    return isCancelled;
}
 
Example #8
Source File: Event.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public void setCancelled(boolean value) {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    isCancelled = value;
}
 
Example #9
Source File: Event.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public boolean isCancelled() {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    return isCancelled;
}
 
Example #10
Source File: Event.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setCancelled(boolean value) {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    isCancelled = value;
}
 
Example #11
Source File: Event.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public boolean isCancelled() {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    return isCancelled;
}
 
Example #12
Source File: Event.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setCancelled(boolean value) {
    if (!(this instanceof Cancellable)) {
        throw new EventException("Event is not Cancellable");
    }
    isCancelled = value;
}
 
Example #13
Source File: EventExecutor.java    From Jupiter with GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException; 
Example #14
Source File: EventExecutor.java    From Nukkit with GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException; 
Example #15
Source File: EventExecutor.java    From Nukkit with GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException;