本文整理汇总了Java中org.bukkit.entity.Player.getLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getLevel方法的具体用法?Java Player.getLevel怎么用?Java Player.getLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: onItemConsume
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent e){
Player p = e.getPlayer();
ItemStack item = e.getItem();
Material type = item != null ? item.getType() : Material.AIR;
int thirst = p.getLevel();
if (type == Material.POTION && item.getDurability() == 0 && p.getInventory().getItemInMainHand().isSimilar(item)){
p.getInventory().getItemInMainHand().setType(Material.AIR);
for (ItemStack i : p.getInventory().getContents()){
if (i.getType() == Material.GLASS_BOTTLE){
i.setType(Material.AIR);
}
}
p.setLevel(0);
if (thirst + 256 >= 1000){
p.setLevel(1000);
return;
}
p.setLevel(thirst + 256);
p.sendMessage(p.getLevel() + " // " + thirst + 256);
}
}
示例4: onPlayerDeath
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
.getGameManager().getGameOfPlayer(e.getEntity());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
Player p = e.getEntity();
int dropped = 0;
if (Config.isDirect) {
dropped = (int) (Config.Death);
} else {
dropped = (int) (p.getLevel() * (Config.Death));
}
BedwarsXPPlayerDeathDropExpEvent event = new BedwarsXPPlayerDeathDropExpEvent(
bw.getName(), p, dropped);
Bukkit.getPluginManager().callEvent(event);
dropped = event.getDroppedXP();
int to = XPManager.getXP(bw.getName(), p) - dropped;
if (to < 0) {
to = 0;
}
e.setNewLevel(to);
XPManager.setXP(bw.getName(), p, to);
}
示例5: onPlayerDeath
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
.getGameOfPlayer(e.getEntity());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
Player p = e.getEntity();
int dropped = 0;
if (Config.isDirect) {
dropped = (int) (Config.Death);
} else {
dropped = (int) (p.getLevel() * (Config.Death));
}
BedwarsXPPlayerDeathDropExpEvent event = new BedwarsXPPlayerDeathDropExpEvent(
bw.getName(), p, dropped);
Bukkit.getPluginManager().callEvent(event);
dropped = event.getDroppedXP();
int to = XPManager.getXP(bw.getName(), p) - dropped;
if (to < 0) {
to = 0;
}
e.setNewLevel(to);
XPManager.setXP(bw.getName(), p, to);
}
示例6: canUnlock
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean canUnlock(Player p)
{
if(!enabled)
return true;
if(!SlimefunStartup.getResearchCfg().getBoolean((new StringBuilder(String.valueOf(id))).append(".enabled").toString()))
return true;
return p.getGameMode() == GameMode.CREATIVE && creative_research || p.getLevel() >= cost;
}
示例7: getCurrentExp
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Get the player's current XP total.
*
* @return the player's total XP
*/
public int getCurrentExp() {
Player player = getPlayer();
int lvl = player.getLevel();
int cur = getXpForLevel(lvl) + (int) Math.round(getXpNeededToLevelUp(lvl) * player.getExp());
return cur;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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);
}
示例11: checkLevel
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean checkLevel(Player player, int required) {
int level = 0;
switch (RPGInventory.getLevelSystem()) {
case EXP:
level = player.getLevel();
break;
case SKILLAPI:
PlayerData playerData = SkillAPI.getPlayerData(player);
level = playerData.hasClass() ? playerData.getMainClass().getLevel() : 0;
break;
case BATTLELEVELS:
level = BattleLevelsAPI.getLevel(player.getUniqueId());
break;
case SKILLS:
level = Skills.getLevel(player);
break;
case HEROES:
level = Heroes.getInstance().getCharacterManager().getHero(player).getLevel();
break;
case RAC:
level = LevelAPI.getCurrentLevel(player);
break;
case RPGPL:
level = new API().getPlayerLevel(player);
break;
}
return level >= required;
}
示例12: onDeath
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent e) {
Player p = e.getEntity();
if (!Utils.isInArena(p)) {
return;
}
int level = p.getLevel();
ExperienceOrb exp = (ExperienceOrb) p.getWorld().spawnEntity(p.getLocation(), EntityType.EXPERIENCE_ORB);
exp.setExperience(level * 2);
}
示例13: onPlayerLvlChanged
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerLvlChanged(PlayerLevelChangeEvent event){
Player player = event.getPlayer();
if (player.getLevel() >= 60){
return;
}
//增加血槽
double healAdded = event.getNewLevel();
player.setMaxHealth(20 + healAdded);
}
示例14: PlayerBackup
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public PlayerBackup(Player player) {
this(player.getInventory(), player.getExp(), player.getLevel());
}
示例15: onPlayerInteract
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
if (event.hasItem() && (action == Action.RIGHT_CLICK_AIR || (action == Action.RIGHT_CLICK_BLOCK && !event.isCancelled()))) {
ItemStack stack = event.getItem();
if (!isBottledExperience(stack)) {
return;
}
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
Integer amount = null;
for (String loreLine : lore) {
if ((amount = JavaUtils.tryParseInt(ChatColor.stripColor(loreLine).split(" ")[0])) != null) {
break;
}
}
if (amount != null) {
event.setCancelled(true);
Player player = event.getPlayer();
int previousLevel = player.getLevel();
new ExperienceManager(player).changeExp(amount);
// Play a fancy sound if they earned 5 exp levels.
if ((player.getLevel() - previousLevel) > 5) {
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1.0F, 1.0F);
}
// If the hand is more than 1, decrease by 1
// otherwise remove. To prevent user error.
if (stack.getAmount() > 1) {
stack.setAmount(stack.getAmount() - 1);
} else {
player.setItemInHand(new ItemStack(Material.GLASS_BOTTLE, 1));
}
}
}
}