Java Code Examples for org.bukkit.event.entity.EntityCombustByEntityEvent#getCombuster()

The following examples show how to use org.bukkit.event.entity.EntityCombustByEntityEvent#getCombuster() . 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: 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 3
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 4
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 5
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);
			}
		}
		
	}
}