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


Java Player.getAttribute方法代碼示例

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


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

示例1: reset

import org.bukkit.entity.Player; //導入方法依賴的package包/類
public static void reset(Player player, boolean heal) {
    if (heal) player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
    player.setFoodLevel(20);
    player.setSaturation(20);
    player.getInventory().clear();
    player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
    player.setItemOnCursor(new ItemStack(Material.AIR));

    player.getActivePotionEffects().forEach(potionEffect -> {
        try {
            player.removePotionEffect(potionEffect.getType());
        } catch (NullPointerException ignored) {}
    });

    player.setFireTicks(0);
    player.setFallDistance(0);
    player.setTotalExperience(0);
    player.setExp(0);
    player.setLevel(0);
    player.setWalkSpeed(0.2F);
    player.setFlySpeed(0.1F);

    player.setSneaking(false);
    player.setInvulnerable(false);
    player.setCanPickupItems(true);
    player.setCollidable(true);
    player.setFlying(false);
    player.setAllowFlight(false);

    player.resetTitle();

    for (Attribute attribute : Attribute.values()) {
        if (player.getAttribute(attribute) == null) continue;
        for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) {
            player.getAttribute(attribute).removeModifier(modifier);
        }
    }
    player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 24.000D, AttributeModifier.Operation.ADD_SCALAR));

    player.updateInventory();
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:42,代碼來源:Players.java

示例2: clearStats

import org.bukkit.entity.Player; //導入方法依賴的package包/類
private void clearStats() {
    Player player = this.player.getPlayer();

    AttributeInstance speedAttribute = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
    AttributeModifier rpgInvModifier = null;
    for (AttributeModifier modifier : speedAttribute.getModifiers()) {
        if (modifier.getUniqueId().compareTo(Attributes.SPEED_MODIFIER_ID) == 0) {
            rpgInvModifier = modifier;
        }
    }

    if (rpgInvModifier != null) {
        speedAttribute.removeModifier(rpgInvModifier);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:16,代碼來源:PlayerWrapper.java

示例3: onPlayerJoin

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
    Player player = event.getPlayer();

    if (api.getGameManager().isLegacyPvP())
    {
        AttributeInstance genericAttackSpeedAttribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);

        if (genericAttackSpeedAttribute != null)
            genericAttackSpeedAttribute.setBaseValue(1024.0D);
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesCore,代碼行數:14,代碼來源:CooldownModule.java


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