当前位置: 首页>>代码示例>>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;未经允许,请勿转载。