當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。