本文整理汇总了Java中org.bukkit.entity.Player.getExp方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getExp方法的具体用法?Java Player.getExp怎么用?Java Player.getExp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getExp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeTotalXP
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Originally adapted from 1.8 computation TODO: doublecheck still valid.
*
* @param e The entity whose current XP to compute
* @return the number of XP in hotbar right now.
*/
public static int computeTotalXP(LivingEntity e) {
if (e instanceof Player) {
Player p = (Player) e;
float cLevel = (float) p.getLevel();
float progress = p.getExp();
float a = 1f, b = 6f, c = 0f, x = 2f, y = 7f;
if (cLevel > 16 && cLevel <= 31) {
a = 2.5f; b = -40.5f; c = 360f; x = 5f; y = -38f;
} else if (cLevel >= 32) {
a = 4.5f; b = -162.5f; c = 2220f; x = 9f; y = -158f;
}
return (int) Math.floor(a * cLevel * cLevel + b * cLevel + c + progress * (x * cLevel + y));
} else {
return 0; //TODO perhaps some fixed amount?
}
}
示例2: getCurrentFractionalXP
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Get the player's current fractional XP.
*
* @return The player's total XP with fractions.
*/
private double getCurrentFractionalXP() {
Player player = getPlayer();
int lvl = player.getLevel();
double cur = getXpForLevel(lvl) + (double) (getXpNeededToLevelUp(lvl) * player.getExp());
return cur;
}
示例3: storeTemporaryInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
void storeTemporaryInventory(Player player) {
final TemporaryPlayerStorage storage = new TemporaryPlayerStorage();
storage.armorContent = player.getInventory().getArmorContents().clone();
storage.isFlying = player.getAllowFlight();
storage.inventory = player.getInventory().getContents().clone();
storage.gameMode = player.getGameMode();
storage.level = player.getLevel();
storage.exp = player.getExp();
storage.health = player.getHealth();
storage.foodLevel = player.getFoodLevel();
storage.scoreboard = player.getScoreboard();
this.temporaryStorage.put(player, storage);
}
示例4: storeTemporaryInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void storeTemporaryInventory(Player player) {
final TemporaryPlayerStorage storage = new TemporaryPlayerStorage();
storage.armorContent = player.getInventory().getArmorContents().clone();
storage.isFlying = player.getAllowFlight();
storage.inventory = player.getInventory().getContents().clone();
storage.gameMode = player.getGameMode();
storage.level = player.getLevel();
storage.exp = player.getExp();
storage.scoreboard = player.getScoreboard();
this.temporaryStorage.put(player, storage);
}
示例5: updatePlayerScoreboard
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void updatePlayerScoreboard(Player player){
// Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
// Objective o = scoreboard.registerNewObjective("status","");
// o.setDisplaySlot(DisplaySlot.SIDEBAR);
// o.setDisplayName(ChatColor.GREEN + "状态");
//
// //血量显示
// Score healthScore = o.getScore(ChatColor.RED + "血量:");
// healthScore.setScore((int) (player.getHealth() + 0.5));
//
// //升级所需经验显示
// Score expToLevelScore = o.getScore(ChatColor.GREEN + "升级所需经验:");
// expToLevelScore.setScore((int) (player.getExpToLevel() - player.getExp()));
//
//
// //用户到服务器ping值
// Score pingScore = o.getScore(ChatColor.AQUA + "延迟(ms):");
// pingScore.setScore(((CraftPlayer)player).getHandle().ping);
//
//
// player.setScoreboard(scoreboard);
String[] scoresLayout = new String[6];
scoresLayout[0] = ChatColor.GREEN + "状态";
scoresLayout[1] = "";
scoresLayout[2] = ChatColor.RED + "血量: " + (int) (player.getHealth() + 0.5);
scoresLayout[3] = ChatColor.GREEN + "升级所需经验: " + (int) (player.getExpToLevel() - player.getExp());
scoresLayout[4] = ChatColor.AQUA + "延迟: " + ((CraftPlayer)player).getHandle().ping + "ms";
scoresLayout[5] = "";
ScoreboardUtil.unrankedSidebarDisplay(player,scoresLayout);
}
示例6: show
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void show(VPPlayer player) {
Player p = player.getPlayer();
Object nmsPlay = getNMSPlayer(p);
Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
.instance(addPlayerEnum, arrayPlayer);
Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
.instance(0, difficulty, type, gamemode);
boolean flying = p.isFlying();
Location location = player.getLocation();
int level = player.getLevel();
float xp = p.getExp();
double maxHealth = p.getMaxHealth();
double health = p.getHealth();
PacketUtils.sendPacket(respawn, player);
p.setFlying(flying);
player.teleport(location);
p.updateInventory();
player.setLevel(level);
p.setExp(xp);
p.setMaxHealth(maxHealth);
p.setHealth(health);
for(VPPlayer vp : VanillaPlusCore.getPlayerManager().getOnlinePlayers())
PacketUtils.sendPacket(add, vp);
}
示例7: updateSelf
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void updateSelf(VPPlayer player){
Player p = player.getPlayer();
Object nmsPlay = getNMSPlayer(p);
Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
ReflectionObject del = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, removePlayerEnum.getClass(), arrayPlayer.getClass())
.instance(removePlayerEnum, arrayPlayer);
final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
.instance(addPlayerEnum, arrayPlayer);
Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
.instance(0, difficulty, type, gamemode);
PacketUtils.sendPacket(del, player);
boolean flying = p.isFlying();
Location location = player.getLocation();
int level = player.getLevel();
float xp = p.getExp();
double maxHealth = p.getMaxHealth();
double health = p.getHealth();
PacketUtils.sendPacket(respawn, player);
p.setFlying(flying);
player.teleport(location);
p.updateInventory();
player.setLevel(level);
p.setExp(xp);
p.setMaxHealth(maxHealth);
p.setHealth(health);
PacketUtils.sendPacket(add, player);
}
示例8: PlayerBackup
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public PlayerBackup(Player player) {
this(player.getInventory(), player.getExp(), player.getLevel());
}