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


Java Player.setTotalExperience方法代码示例

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


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

示例1: setExp

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void setExp(double base, double amt) {
    int xp = (int) Math.max(base + amt, 0);

    Player player = getPlayer();
    int curLvl = player.getLevel();
    int newLvl = getLevelForExp(xp);

    // Increment level
    if (curLvl != newLvl) {
        player.setLevel(newLvl);
    }
    // Increment total experience - this should force the server to send an update packet
    if (xp > base) {
        player.setTotalExperience(player.getTotalExperience() + xp - (int)base);
    }

    double pct = (base - getXpForLevel(newLvl) + amt) / (double) (getXpNeededToLevelUp(newLvl));
    player.setExp((float) pct);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:20,代码来源:ExperienceManager.java

示例2: 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

示例3: setSpectator

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setSpectator(Player player, String prefix, Location spawn) {
    if (!PREFIXES.containsKey(player.getName()))
        PREFIXES.put(player.getName(), prefix);

    player.setFoodLevel(20);
    player.setLevel(0);
    player.setGameMode(GameMode.ADVENTURE);
    player.setAllowFlight(true);
    player.setPlayerListName(prefix + player.getDisplayName());
    player.setDisplayName(prefix + player.getDisplayName());
    player.setExp(0);
    player.setHealthScale(20);
    player.setHealth(20);
    player.setTotalExperience(0);
    player.setCanPickupItems(false);
    player.setCustomName(prefix + player.getDisplayName());
    player.setCustomNameVisible(true);
    for (PotionEffect eff : player.getActivePotionEffects()) {
        player.removePotionEffect(eff.getType());
    }
    player.teleport(spawn);

    for (Player p : Bukkit.getOnlinePlayers()) {
        p.hidePlayer(player);
    }

    PlayerUtil.addDeadPlayer(player);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:29,代码来源:Spectator.java

示例4: removeSpectator

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void removeSpectator(Player player) {
    player.setFoodLevel(20);
    player.setLevel(0);
    player.setGameMode(GameMode.SURVIVAL);
    player.setAllowFlight(false);
    player.setExp(0);
    player.setHealthScale(20);
    player.setHealth(20);
    player.setTotalExperience(0);
    player.setCanPickupItems(false);
    for (PotionEffect eff : player.getActivePotionEffects()) {
        player.removePotionEffect(eff.getType());
    }

    if (PREFIXES.containsKey(player.getName())) {
        player.setCustomName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
        player.setPlayerListName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
        player.setDisplayName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
        player.setCustomNameVisible(true);
    }

    for (Player p : Bukkit.getOnlinePlayers()) {
        p.showPlayer(player);
    }

    PlayerUtil.removeDeadPlayer(player);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:28,代码来源:Spectator.java

示例5: setWantedLevel

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setWantedLevel(Player player, int level) throws SQLException {
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("UPDATE users_locked SET locked_wanted=" + level + " WHERE uuid = '" + player.getUniqueId() + "'");
    stmt.executeUpdate();
    switch (level) {
        case 0:
            player.setTotalExperience(0);
            break;
        case 1:
            player.setTotalExperience(1);
            break;
        case 2:
            player.setTotalExperience(500);
            break;
        case 3:
            player.setTotalExperience(2300);
            break;
        case 4:
            player.setTotalExperience(10800);
            break;
        case 5:
            player.setTotalExperience(45300);
            break;
        case 6:
            player.setTotalExperience(162500);
            break;
        case 7:
            player.setTotalExperience(452120);
            break;
        case 8:
            player.setTotalExperience(1245980);
            break;
        case 9:
            player.setTotalExperience(4560370);
            break;
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:37,代码来源:RankManager.java

示例6: onKill

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onKill(PlayerDeathEvent event) {
    Player target = event.getEntity();
    Player killer = target.getKiller();
    if (RankManager.isPrisoner(killer)) {
        if (RankManager.isPrisoner(target)) {
            killer.setTotalExperience(killer.getTotalExperience() + 250);
        } else if (RankManager.isGuard(target) || RankManager.isWarden(target)) {
            killer.setTotalExperience(killer.getTotalExperience() + 2000);
        }
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:13,代码来源:RankListener.java


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