當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityDamageByEntityEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityDamageByEntityEvent.setCancelled方法的具體用法?Java EntityDamageByEntityEvent.setCancelled怎麽用?Java EntityDamageByEntityEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityDamageByEntityEvent的用法示例。


在下文中一共展示了EntityDamageByEntityEvent.setCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EntityDamageByEntityListener

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
	if (!GameManager.getGameSituation()) {
		e.setCancelled(true);
	}
	if (e.getDamager() instanceof Player) {
		if (e.getEntity() instanceof Player) {
			Player damager = (Player) e.getDamager();
			Player victim = (Player) e.getEntity();
			if (SettingsManager.shotinfo) {
				if (e.getCause() == DamageCause.PROJECTILE) {
					if(victim.getLocation().distance(damager.getLocation()) < 20) {
						Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
					}
				}
			}
		}
	}
}
 
開發者ID:masste,項目名稱:McPlayUHC,代碼行數:20,代碼來源:EntityDamageByEntityListener.java

示例2: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.getDamager() instanceof Player == false)
		return;
	
	PetInstance pet = PetInstance.get(event.getEntity());
	
	if (pet == null)
		return;
	
	event.setCancelled(true);
	
	if (pet.getOwner().equalsIgnoreCase(((Player) event.getDamager()).getName())) {
		Chat.player((Player) event.getDamager(), "&2[Pets] &aYou have removed your pet. Spawn it with &b/pet spawn");
		pet.despawn();
		pet.setToSpawn(false);
	}
	else {
		Chat.player((Player) event.getDamager(), "&2[Pets] &cBuy pets at www.mczone.co/shop");
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:22,代碼來源:PetEvents.java

示例3: onDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
		Player player = (Player) event.getEntity();
		Player damager = (Player) event.getDamager();
		Profile playerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(player.getUniqueId());
		Profile damagerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(damager.getUniqueId());
		if (playerProfile.getTeam() == null || damagerProfile.getTeam() == null || playerProfile.getProfileStatus() != ProfileStatus.PLAYING || damagerProfile.getProfileStatus() != ProfileStatus.PLAYING) {
			event.setCancelled(true);
			damager.sendMessage(ChatColor.RED + "You cannot do this in your current state.");
			return;
		}
		if (playerProfile.getTeam() == damagerProfile.getTeam()) {
			event.setCancelled(true);
			damager.sendMessage(ChatColor.YELLOW + "You cannot hurt " + damagerProfile.getTeam().getColor() + player.getName() + ChatColor.YELLOW + ".");
		}
	}
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:19,代碼來源:TeamDamageListener.java

示例4: onPvP

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPvP(EntityDamageByEntityEvent evt) {
    if (Parties.isParty(evt.getDamager()))
        return;

    Player attacker = evt.getDamager() instanceof Player ? (Player) evt.getDamager() :
            (evt.getDamager() instanceof Projectile && ((Projectile) evt.getDamager()).getShooter() instanceof Player
            ? (Player) ((Projectile) evt.getDamager()).getShooter() : null); // Yuck, maybe we can make a method for this later.
    if (attacker == null || !(evt.getEntity() instanceof Player))
        return; // One or both of the combatants isn't a player.

    boolean outgoingFail = !getToggle(attacker, Toggle.PVP);
    boolean incomingFail = !getToggle(evt.getEntity(), Toggle.PVP);

    if (outgoingFail || incomingFail) {
        attacker.sendMessage(ChatColor.RED + (outgoingFail ? "You have PvP disabled. (/togglepvp)"
                : evt.getEntity().getName() + " has PvP disabled."));
        evt.setCancelled(true);
        evt.getEntity().setFireTicks(-1); // Disable fire damage.
    }
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:22,代碼來源:Toggles.java

示例5: onAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
	if(!(e.getEntity() instanceof Player)) return;
	if(e.getDamager() instanceof Player || e.getDamager() instanceof Projectile) {
		
		
		
	if(mayPvP) {
		if(e.getDamager() instanceof Projectile) {
			
			
			handleShooting(e);
		} else {
			handleMelee(e);
		}
	} else {
		e.setCancelled(true);
		return;
	}
	} else {
		return;
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:24,代碼來源:PvPManager.java

示例6: ArmorStandDestroy

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void ArmorStandDestroy(EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName());
    }
    if (!(e.getEntity() instanceof LivingEntity)) {
        return;
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    final LivingEntity livingEntity = (LivingEntity) e.getEntity();
    if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
        return;
    }
    if (e.getDamager() instanceof Player) {
        Player p = (Player) e.getDamager();
        if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check if on island
        if (plugin.getIslands().playerIsOnIsland(p)) {
            return;
        }
        // Check island
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        if (island != null && island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:37,代碼來源:IslandGuard1_8.java

示例7: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
	e.setCancelled(true);
	
	if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
		GamePlayer damager = Absorption.getPlayer((Player) e.getDamager());
		GamePlayer player = Absorption.getPlayer((Player) e.getEntity());
		
		if(damager == null || player == null) return;
		
		player.hitByPlayer(damager);
	}
}
 
開發者ID:SamaGames,項目名稱:Absorption,代碼行數:14,代碼來源:PlayerListener.java

示例8: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	Entity entity = event.getEntity();
	
	if (!(entity instanceof EnderCrystal) || event.getEntity().getWorld().getEnvironment() != Environment.THE_END
			|| !entity.isInvulnerable()) return;
	
	event.setCancelled(true);
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:10,代碼來源:LootListeners.java

示例9: onDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
		Game game = Chambers.getInstance().getGameManager().getGame();
		if (game.getInvincibilityTime() > 0) {
			Player damager = (Player) event.getDamager();
			damager.sendMessage(ChatColor.RED + "The invincibility timer is still on.");
			event.setCancelled(true);
		}
	}
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:15,代碼來源:GameDamageListener.java

示例10: onDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
	// Cancelling team damage
	if(event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
		Player victim = (Player) event.getEntity();
		Player damager = (Player) event.getDamager();
		if(!Utility.canAttack(victim, damager)){
			event.setCancelled(true);
		}
	}
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:12,代碼來源:PlayerListener.java

示例11: onEntityDamageEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageEntity(EntityDamageByEntityEvent e) {
	 Entity ent = e.getEntity();
	 Entity damager = e.getDamager();
	 if(ent instanceof Player && damager instanceof Player) {
			if (!hasIgnorePermission((Player) damager)) {
				 if (inLobbyWorld((Player) ent) && SkyWarsReloaded.getCfg().pvpDisabled()) {
					 e.setCancelled(true); 
				 }
			}
	 }
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:13,代碼來源:LobbyListener.java

示例12: onItemFrameAttack

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true) // Prevent hitting item frames.
public void onItemFrameAttack(EntityDamageByEntityEvent evt) {
    evt.setCancelled(evt.getEntity() instanceof ItemFrame && preventEdit(evt.getDamager()));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:5,代碼來源:Dungeons.java

示例13: customDeath

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST)
public void customDeath(EntityDamageByEntityEvent e){
	if(e.isCancelled())return;
	if(e.getEntity() instanceof Player && e.getDamager() instanceof Player){
		Player p = (Player) e.getEntity();
		if(e.getFinalDamage() >= p.getHealth()){
			Player killer = (Player) e.getDamager();
			String uuid2 = killer.getUniqueId().toString();
			e.setCancelled(true);
			if(! p.getName().equals(killer.getName())){ // if they were killed by someone else, not themselves
				setTokens(uuid2, getTokens(uuid2)+2);
				killer.sendMessage(tag + ChatColor.BLUE + "You have received " + ChatColor.GOLD + "2" +
						ChatColor.BLUE + " tokens for killing " + p.getName());
			}
			Bukkit.getServer().broadcastMessage(ChatColor.GRAY + killer.getName() + " destroyed " + p.getName());
			// Set statistics
			//killer.setStatistic(Statistic.KILL_ENTITY, killer.getStatistic(Statistic.KILL_ENTITY) + 1);
			//p.setStatistic(Statistic.DEATHS, p.getStatistic(Statistic.DEATHS) + 1);
			// Reset health, so they dont die
			p.setHealth(p.getMaxHealth());
			// Inventory clearing
			p.getInventory().clear();
			ItemStack air = new ItemStack(Material.AIR);
			p.getInventory().setHelmet(air);
			p.getInventory().setChestplate(air);
			p.getInventory().setLeggings(air);
			p.getInventory().setBoots(air);
			// Drop emerald at death location
			ItemStack reward = new ItemStack(Material.EMERALD);
			p.getWorld().dropItemNaturally(p.getLocation(), reward);
			// Clear potion effects
			for(PotionEffect pe : p.getActivePotionEffects()){
				p.removePotionEffect(pe.getType());
			}
			// Stop infinite kill glitch
			p.setGameMode(GameMode.SPECTATOR);
			p.setGameMode(GameMode.ADVENTURE);
			// Send them to the SPAWN of the world
			p.teleport(p.getWorld().getSpawnLocation());
			p.setFireTicks(0);
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:44,代碼來源:Core.java

示例14: onEntityDamaged

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamaged(EntityDamageByEntityEvent event) {
    if(event.getDamager().getUniqueId() == player.getUniqueId())
        event.setCancelled(true);
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:6,代碼來源:Freeze.java

示例15: onLingeringPotionDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
        plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
        plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
        plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
    }
    if (!Util.inWorld(e.getEntity().getLocation())) {
        return;
    }
    if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
        return;
    }
    if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
        UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
        // Self damage
        if (attacker.equals(e.getEntity().getUniqueId())) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
            return;
        }
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        boolean inNether = false;
        if (e.getEntity().getWorld().equals(IslandWorld.getNetherWorld())) {
            inNether = true;
        }
        // Monsters being hurt
        if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
            // Normal island check
            if (island != null && island.getMembers().contains(attacker)) {
                // Members always allowed
                return;
            }
            if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
                return;
            }
            // Not allowed
            e.setCancelled(true);
            return;
        }

        // Mobs being hurt
        if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
                || e.getEntity() instanceof Villager) {
            if (island != null && (island.getFlag(SettingsFlag.HURT_ANIMALS) || island.getMembers().contains(attacker))) {
                return;
            }
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
            e.setCancelled(true);
            return;
        }

        // Establish whether PVP is allowed or not.
        boolean pvp = false;
        if ((inNether && island != null && island.getFlag(SettingsFlag.PVP_NETHER) || (!inNether && island != null && island.getFlag(SettingsFlag.PVP_OVERWORLD)))) {
            if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
            pvp = true;
        }

        // Players being hurt PvP
        if (e.getEntity() instanceof Player) {
            if (!pvp) {
                if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:72,代碼來源:IslandGuard1_9.java


注:本文中的org.bukkit.event.entity.EntityDamageByEntityEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。