当前位置: 首页>>代码示例>>Java>>正文


Java EntityType.PLAYER属性代码示例

本文整理汇总了Java中org.bukkit.entity.EntityType.PLAYER属性的典型用法代码示例。如果您正苦于以下问题:Java EntityType.PLAYER属性的具体用法?Java EntityType.PLAYER怎么用?Java EntityType.PLAYER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.entity.EntityType的用法示例。


在下文中一共展示了EntityType.PLAYER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRegen

@EventHandler
public void onRegen(EntityRegainHealthEvent event) {
    if (event.getEntityType() != EntityType.PLAYER || event.getRegainReason() != EntityRegainHealthEvent.RegainReason.SATIATED) return;
    event.setCancelled(true);

    Player player = (Player) event.getEntity();
    long currentTime = System.currentTimeMillis() / 1000;

    if (currentTime - getLastHealTime(player) < 3)
        return;

    double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();

    if (player.getHealth() < maxHealth) {
        player.setHealth(clamp(player.getHealth() + 1, 0.0, maxHealth));
        healTimes.put(player.getUniqueId(), currentTime);
    }

    float exhToApply = (float) 3;

    Bukkit.getScheduler().runTaskLater(TGM.get(), () -> {
        //This is because bukkit doesn't stop the exhaustion change when cancelling the event
        player.setExhaustion(player.getExhaustion() + exhToApply);
        //debug("Exhaustion before: " + previousExh + " Now: " + p.getExhaustion() + "Saturation: " + p.getSaturation(), p);
    }, 1L);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:26,代码来源:RegenModule.java

示例2: onPlayerFall

@EventHandler
public void onPlayerFall(EntityDamageEvent event) {
    if (event.getEntity().getType() == EntityType.PLAYER
            && event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        Player player = (Player) event.getEntity();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);
        double height = (1.5D + jumpModifier.getBonus()) * jumpModifier.getMultiplier() * 1.5;
        event.setDamage(event.getDamage() - height);

        if (event.getDamage() <= 0.0D) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:19,代码来源:ItemListener.java

示例3: ClickCheckItem

@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
    if(ConfigPatch.AntiLongStringCrashenable == true){
        if(evt.getWhoClicked().getType() != EntityType.PLAYER){
            return;
        }
        Player player = (Player) evt.getWhoClicked();
        ItemStack item = evt.getCursor();
        if(item != null){
            if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
                if(item.getItemMeta().getDisplayName().length() >= 127){
                    evt.setCancelled(true);
                    evt.setCurrentItem(null);
                    AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
                }
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:19,代码来源:AntiLongStringCrash.java

示例4: onEntityToggleGlide

@EventHandler(ignoreCancelled = true)
public void onEntityToggleGlide(EntityToggleGlideEvent event) {
    if (event.getEntityType() != EntityType.PLAYER) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.isGliding()) {
        PlayerWrapper playerWrapper = InventoryManager.get(player);
        playerWrapper.onStartGliding();
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:ElytraListener.java

示例5: onDamageWhenPlayerNotLoaded

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onDamageWhenPlayerNotLoaded(EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.PLAYER) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        PlayerLoader.setDamageForPlayer(player, event.getFinalDamage());
    }

    event.setCancelled(true);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:17,代码来源:PlayerListener.java

示例6: EntityFarmChecker

@EventHandler
public void EntityFarmChecker(EntityInteractEvent event){
    if(ConfigFunction.ProtectFarmenable){
        if(event.getEntityType() != EntityType.PLAYER){
            Block block = event.getBlock();
            if(block.getType() == Material.SOIL||block.getType() == Material.CROPS){
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:11,代码来源:FarmProtecter.java

示例7: getNearbyPlayers

public static List<Player> getNearbyPlayers(Location location, double distance) {
    List<Player> nearbyPlayers = new ArrayList<>();
    for (LivingEntity entity : location.getWorld().getLivingEntities()) {
        if (entity.getType() == EntityType.PLAYER && entity.getLocation().distance(location) <= distance) {
            nearbyPlayers.add((Player) entity);
        }
    }

    return nearbyPlayers;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:10,代码来源:LocationUtils.java

示例8: onEntityDismount

@EventHandler
public void onEntityDismount(EntityDismountEvent event)
{
    if (event.getEntity().getType() != EntityType.PLAYER)
        return;

    if (!this.hasPlayer((Player) event.getEntity()))
        return;

    event.getDismounted().setPassenger(event.getEntity());
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:11,代码来源:SonicSquid.java

示例9: onSpawn

@EventHandler
public void onSpawn(EntitySpawnEvent event) {
    if (Skywars.getInstance().isSingleServerMode()) {
        if (event.getEntityType() != EntityType.PLAYER && event.getEntityType() != EntityType.DROPPED_ITEM && event.getEntityType() != EntityType.PRIMED_TNT) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:8,代码来源:EntitySpawn.java

示例10: onCraftItem

@EventHandler(priority = EventPriority.HIGH)
public void onCraftItem(CraftItemEvent event) 
{
	if( event.getRecipe().getResult().getType() == Material.STONE_SWORD
			|| event.getRecipe().getResult().getType() == Material.IRON_SWORD
			|| event.getRecipe().getResult().getType() == Material.GOLD_SWORD
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_SWORD
|| event.getRecipe().getResult().getType() == Material.LEATHER_BOOTS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.LEATHER_HELMET
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_BOOTS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_HELMET
|| event.getRecipe().getResult().getType() == Material.GOLD_BOOTS
			|| event.getRecipe().getResult().getType() == Material.GOLD_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.GOLD_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.GOLD_HELMET
			|| event.getRecipe().getResult().getType() == Material.IRON_BOOTS
			|| event.getRecipe().getResult().getType() == Material.IRON_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.IRON_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.IRON_HELMET
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_BOOTS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_LEGGINGS
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE
			|| event.getRecipe().getResult().getType() == Material.DIAMOND_HELMET)
	{
		if( event.getWhoClicked().getType() == EntityType.PLAYER )
		{
			Player p = (Player)event.getWhoClicked();
			p.sendMessage("Sorry, you are not allowed to craft this item. Purchase it from a Safe Dock instead.");
		}
		event.setCancelled(false);
	}
 
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:37,代码来源:NavyCraft_InventoryListener.java

示例11: onEntityDeath

/**
 * When a player kill a mob there's a 40% chance to spawn the same at the same place
 *
 * @param event Event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
    if (event.getEntity().getType() == EntityType.PLAYER)
        return;

    if (this.random.nextDouble() < (double) this.moduleConfiguration.get("chance"))
        event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), event.getEntity().getType());
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:14,代码来源:InfestationModule.java

示例12: onTarget

@EventHandler
public void onTarget(EntityTargetLivingEntityEvent event) {
    if (!(event.getEntity() instanceof Tameable) || !(event.getEntity() instanceof LivingEntity)
            || event.getTarget() == null || !InventoryManager.isAllowedWorld(event.getTarget().getWorld())) {
        return;
    }

    LivingEntity petEntity = (LivingEntity) event.getEntity();
    final OfflinePlayer player = (OfflinePlayer) ((Tameable) petEntity).getOwner();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && petEntity == playerWrapper.getPet()) {
        PetType petType = PetManager.getPetFromEntity(petEntity, player);

        if (petType == null) {
            return;
        }

        if (event.getTarget() != null && event.getTarget().getType() == EntityType.PLAYER) {
            event.setCancelled(!petType.isAttackPlayers());
        } else {
            event.setCancelled(!petType.isAttackMobs());
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:29,代码来源:PetListener.java

示例13: onDamage

/**
 * Cancel fall damages
 *
 * @param event Event instance
 */
@EventHandler
public void onDamage(EntityDamageEvent event)
{
    if (event.getEntityType() == EntityType.PLAYER && event.getCause() == EntityDamageEvent.DamageCause.FALL)
    {
        event.setCancelled(true);
        event.setDamage(0);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:14,代码来源:SuperheroesPlusModule.java

示例14: onDamage

/**
 * Fire player on damage
 * @param event Event
 */
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageEvent event)
{
    if (((SurvivalGame) SamaGamesAPI.get().getGameManager().getGame()).isDamagesActivated()
            && event.getEntityType() == EntityType.PLAYER
            && event.getCause() != EntityDamageEvent.DamageCause.FIRE
            && event.getCause() != EntityDamageEvent.DamageCause.FIRE_TICK
            && event.getDamage() > 0
            && !event.isCancelled())
        event.getEntity().setFireTicks((int) this.moduleConfiguration.get("fire-time") * 20);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:15,代码来源:PyroTechnicsModule.java

示例15: onMobJump

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMobJump(EntityInteractEvent e) {
	if (!cm.farmProtectEnabled) {
		return;
	}
	if (e.getEntityType() == EntityType.PLAYER) {
		return;
	}
	if (e.getBlock().getType() == Material.SOIL) {
		e.setCancelled(true);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:12,代码来源:FarmProtecter.java


注:本文中的org.bukkit.entity.EntityType.PLAYER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。