Java Code Examples for cn.nukkit.utils.EventException

The following examples show how to use cn.nukkit.utils.EventException. These examples are extracted from open source projects. 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 Project: Jupiter   Source File: RegisteredListener.java    License: 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 Project: Jupiter   Source File: EntityDamageEvent.java    License: 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 Project: Nukkit   Source File: RegisteredListener.java    License: 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 Project: Nukkit   Source File: EntityDamageEvent.java    License: 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 Project: Nukkit   Source File: RegisteredListener.java    License: 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 Project: Nukkit   Source File: EntityDamageEvent.java    License: 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 Project: Jupiter   Source File: Event.java    License: 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 Project: Jupiter   Source File: Event.java    License: 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 Project: Nukkit   Source File: Event.java    License: 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 Project: Nukkit   Source File: Event.java    License: 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 Project: Nukkit   Source File: Event.java    License: 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 Project: Nukkit   Source File: Event.java    License: 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 Project: Jupiter   Source File: EventExecutor.java    License: GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException; 
Example 14
Source Project: Nukkit   Source File: EventExecutor.java    License: GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException; 
Example 15
Source Project: Nukkit   Source File: EventExecutor.java    License: GNU General Public License v3.0 votes vote down vote up
void execute(Listener listener, Event event) throws EventException;