org.bukkit.event.entity.EntityCombustByEntityEvent Java Examples

The following examples show how to use org.bukkit.event.entity.EntityCombustByEntityEvent. 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: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityCombustByEntityEvent event) {
    GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
    Object source = event.getCombuster();
    if (source == null) {
        source = NMSUtil.getInstance().getFlameableBlock(event.getEntity());
    }
    if (protectEntity(event, source, event.getEntity())) {
        event.setCancelled(true);
    }
    GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
 
Example #2
Source File: EventFilterMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCombust(final EntityCombustEvent event) {
  cancelUnlessInteracting(event, event.getEntity());
  if (event instanceof EntityCombustByEntityEvent) {
    cancelUnlessInteracting(event, ((EntityCombustByEntityEvent) event).getCombuster());
  }
}
 
Example #3
Source File: DamageMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onIgnition(EntityCombustByEntityEvent event) {
  MatchPlayer victim = getVictim(event.getEntity());
  if (victim == null) return;

  processDamageEvent(
      event,
      victim.getParticipantState(),
      tracker()
          .resolveDamage(
              EntityDamageEvent.DamageCause.FIRE, event.getEntity(), event.getCombuster()));
}
 
Example #4
Source File: FireTracker.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityIgnite(EntityCombustByEntityEvent event) {
  if (event.getDuration() == 0) return;

  FireInfo info = resolveBurning(event.getCombuster());
  if (info != null) {
    // First, try to resolve the player who ignited the combuster
    info = new FireInfo(new EntityInfo(event.getCombuster(), info.getOwner()));
  } else {
    // If an igniter is not found, fall back to the owner of the entity
    info = new FireInfo(entities().resolveEntity(event.getCombuster()));
  }

  burningEntities.put(event.getEntity(), info);
}
 
Example #5
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCombust(final EntityCombustEvent event) {
    cancelUnlessInteracting(event, event.getEntity());
    if(event instanceof EntityCombustByEntityEvent) {
        cancelUnlessInteracting(event, ((EntityCombustByEntityEvent) event).getCombuster());
    }
}
 
Example #6
Source File: DamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onIgnition(EntityCombustByEntityEvent event) {
    MatchPlayer victim = getVictim(event.getEntity());
    if(victim == null) return;
    processDamageEvent(event, victim.getParticipantState(),
                       damageResolver.resolveDamage(EntityDamageEvent.DamageCause.FIRE, event.getEntity(), event.getCombuster()));
}
 
Example #7
Source File: FireTracker.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityIgnite(EntityCombustByEntityEvent event) {
    if(event.getDuration() == 0) return;

    FireInfo info = resolveBurning(event.getCombuster());
    if(info != null) {
        // First, try to resolve the player who ignited the combuster
        info = new FireInfo(new EntityInfo(event.getCombuster(), info.getOwner()));
    } else {
        // If an igniter is not found, fall back to the owner of the entity
        info = new FireInfo(entities.resolveEntity(event.getCombuster()));
    }

    burningEntities.put(event.getEntity(), info);
}
 
Example #8
Source File: EntityListener.java    From Guilds with MIT License 5 votes vote down vote up
/**
 * Handles flame arrows
 *
 * @param event
 */
@EventHandler
public void onFlameArrow(EntityCombustByEntityEvent event) {

    if (!(event.getEntity() instanceof Player))
        return;

    if (!(event.getCombuster() instanceof Arrow))
        return;

    Arrow arrow = (Arrow) event.getCombuster();

    if (!(arrow.getShooter() instanceof Player))
        return;

    Player damagee = (Player) event.getEntity();
    Player damager = (Player) arrow.getShooter();

    if (settingsManager.getProperty(GuildSettings.RESPECT_WG_PVP_FLAG)) {
        event.setCancelled(ClaimUtils.checkPvpDisabled(damagee));
        return;
    }

    if (guildHandler.isSameGuild(damagee, damager)) {
        arrow.setFireTicks(0);
        event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE));
        return;
    }

    if (guildHandler.isAlly(damagee, damager)) {
        arrow.setFireTicks(0);
        event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE));
    }
}
 
Example #9
Source File: DMobListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
    if (plugin.getGameWorld(event.getEntity().getWorld()) != null) {
        if (event.isCancelled()) {
            event.setCancelled(false);
        }
    }
}
 
Example #10
Source File: BukkitEventManager.java    From Parties with GNU Affero General Public License v3.0 4 votes vote down vote up
public BukkitPartiesCombustFriendlyFireBlockedEvent prepareCombustFriendlyFireBlockedEvent(PartyPlayer victim, PartyPlayer attacker, EntityCombustByEntityEvent originalEvent) {
	return new BukkitPartiesCombustFriendlyFireBlockedEvent(victim, attacker, originalEvent);
}
 
Example #11
Source File: BukkitFightListener.java    From Parties with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler (ignoreCancelled = true)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
	if (BukkitConfigParties.FRIENDLYFIRE_ENABLE
			&& event.getEntity() instanceof Player
			&& event.getCombuster() instanceof Projectile
			&& ((Projectile) event.getCombuster()).getShooter() instanceof Player) {
		Player victim = (Player) event.getEntity();
		Player attacker = (Player)((Projectile) event.getCombuster()).getShooter();
		
		// Found right attacker
		if (attacker != null && !victim.getUniqueId().equals(attacker.getUniqueId())) {
			// Friendly fire not allowed here
			PartyPlayerImpl ppVictim = plugin.getPlayerManager().getPlayer(victim.getUniqueId());
			PartyPlayerImpl ppAttacker = plugin.getPlayerManager().getPlayer(attacker.getUniqueId());
			BukkitPartyImpl party = (BukkitPartyImpl) plugin.getPartyManager().getParty(ppAttacker.getPartyName());
			
			if (party != null
					&& ppVictim.getPartyName().equalsIgnoreCase(ppAttacker.getPartyName())
					&& party.isFriendlyFireProtected()
					&& !attacker.hasPermission(PartiesPermission.ADMIN_PROTECTION_BYPASS.toString())) {
				// Calling API event
				BukkitPartiesCombustFriendlyFireBlockedEvent partiesFriendlyFireEvent = ((BukkitEventManager) plugin.getEventManager()).prepareCombustFriendlyFireBlockedEvent(ppVictim, ppAttacker, event);
				plugin.getEventManager().callEvent(partiesFriendlyFireEvent);
				
				if (!partiesFriendlyFireEvent.isCancelled()) {
					// Friendly fire confirmed
					User userAttacker = plugin.getPlayer(attacker.getUniqueId());
					userAttacker.sendMessage(
							plugin.getMessageUtils().convertAllPlaceholders(BukkitMessages.ADDCMD_PROTECTION_PROTECTED, party, ppAttacker)
							, true);
					party.warnFriendlyFire(ppVictim, ppAttacker);
					
					event.setCancelled(true);
					plugin.getLoggerManager().logDebug(PartiesConstants.DEBUG_FRIENDLYFIRE_DENIED
							.replace("{type}", "entity combust")
							.replace("{player}", attacker.getName())
							.replace("{victim}", victim.getName()), true);
				} else
					plugin.getLoggerManager().logDebug(PartiesConstants.DEBUG_API_FRIENDLYFIREEVENT_DENY
							.replace("{type}", "entity combust")
							.replace("{player}", attacker.getName())
							.replace("{victim}", victim.getName()), true);
			}
		}
		
	}
}
 
Example #12
Source File: BukkitPartiesCombustFriendlyFireBlockedEvent.java    From Parties with GNU Affero General Public License v3.0 4 votes vote down vote up
public BukkitPartiesCombustFriendlyFireBlockedEvent(PartyPlayer victim, PartyPlayer attacker, EntityCombustByEntityEvent originalEvent) {
	super(false);
	this.victim = victim;
	this.attacker = attacker;
	this.originalEvent = originalEvent;
}
 
Example #13
Source File: BukkitPartiesCombustFriendlyFireBlockedEvent.java    From Parties with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Get the original Bukkit event handled by Parties
 *
 * @return Returns the original {@link EntityCombustByEntityEvent}
 */
@NonNull
public EntityCombustByEntityEvent getOriginalEvent() {
	return originalEvent;
}