本文整理汇总了Java中org.bukkit.entity.Player.setLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setLevel方法的具体用法?Java Player.setLevel怎么用?Java Player.setLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.setLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joinLobby
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public synchronized boolean joinLobby(Player player) {
if (this.canJoinLobby(player)) {
this.lobby.add(player);
this.storeTemporaryInventory(player);
player.getInventory().setArmorContents(new ItemStack[4]);
player.getInventory().clear();
player.updateInventory();
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setExp(0);
player.setLevel(0);
player.setGameMode(GameMode.ADVENTURE);
player.teleport(this.getArena().getLobbyMeta().getLobbySpawn());
return true;
}
return false;
}
示例2: sendSound
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Send a piano note to the players if the remaining seconds are
* belows or equals 5.
*
* @param seconds Actual remaining seconds
*/
private void sendSound(int seconds)
{
boolean ring = false;
if (seconds <= 5 && seconds != 0)
{
ring = true;
}
for(Player player : Bukkit.getOnlinePlayers())
{
player.setLevel(seconds);
if (ring)
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_HARP, 1L, 1L);
if (seconds == 0)
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, 1L, 1L);
}
}
示例3: cleanPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Clean player's inventory
*
* @param player Player
*/
public static void cleanPlayer(Player player)
{
if(player != null && Bukkit.getPlayer(player.getUniqueId()) != null)
{
player.getInventory().clear();
player.getInventory().setHelmet(null);
player.getInventory().setChestplate(null);
player.getInventory().setLeggings(null);
player.getInventory().setBoots(null);
player.setSaturation(20.0F);
player.setHealth(player.getMaxHealth());
player.setExp(0.0F);
player.setLevel(0);
for(PotionEffect potionEffect : player.getActivePotionEffects())
player.removePotionEffect(potionEffect.getType());
}
}
示例4: 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);
}
示例5: onJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent e){
Player p = e.getPlayer();
Economy eco = new Economy(p);
p.setLevel(1000);
WCTWD.getPlayer(p).noItemsCooldown();
if (eco.isInTeam()){
WCTWD.getInstance().getTeams().loadTeam(WCTWD.getPlayer(p));
Location l = WCTWD.getInstance().getTeams().getTeamLocation(WCTWD.getInstance().getTeams().getTeam(WCTWD.getPlayer(p)));
if (l == null) return;
p.teleport(l);
return;
}
p.sendMessage("Pon /prision o /woodbury para entrar en un equipo");
}
示例6: 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);
}
}
示例7: reset
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void reset() {
final Player bukkit = getBukkit();
bukkit.closeInventory();
clearInventory();
bukkit.setExhaustion(0);
bukkit.setFallDistance(0);
bukkit.setFireTicks(0);
bukkit.setFoodLevel(20); // full
bukkit.setMaxHealth(20);
bukkit.setHealth(bukkit.getMaxHealth());
bukkit.setAbsorption(0);
bukkit.setLevel(0);
bukkit.setExp(0); // clear xp
bukkit.setSaturation(5); // default
bukkit.setFastNaturalRegeneration(false);
bukkit.setSlowNaturalRegeneration(true);
bukkit.setAllowFlight(false);
bukkit.setFlying(false);
bukkit.setSneaking(false);
bukkit.setSprinting(false);
bukkit.setFlySpeed(0.1f);
bukkit.setKnockbackReduction(0);
bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT);
AttributeUtils.removeAllModifiers(bukkit);
resetPotions();
// we only reset bed spawn here so people don't have to see annoying messages when they respawn
bukkit.setBedSpawnLocation(null);
match.callEvent(new PlayerResetEvent(this));
}
示例8: onSpawn
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(PlayerRespawnEvent e) {
Player p = e.getPlayer();
if (Utils.isInArena(p)) {
Arena arena = Utils.getAreana(p);
Location loc = arena.getRandomSpawnLocation();
if (loc == null) {
p.sendMessage(Messages.prefix + Messages.SpawnLocationsNotFound);
} else {
e.setRespawnLocation(loc);
}
Utils.fillInventory(p);
p.setLevel(0);
Utils.flushSkillSelection(p);
}
}
示例9: onCraftItem
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCraftItem(CraftItemEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (humanEntity instanceof Player) {
Player player = (Player) humanEntity;
if (event.getSlotType() == InventoryType.SlotType.RESULT && isBottledExperience(event.getCurrentItem())) {
player.setLevel(0);
player.setExp(0);
}
}
}
示例10: restore
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Restore a player to this death point.
* @param player
*/
@SuppressWarnings("unchecked")
public void restore(Player player) {
player.setLevel(getXpLost());
Utils.giveItems(player, JsonSerializer.fromJson(JsonList.class, getInventory(), ItemStack.class));
player.sendMessage(ChatColor.GOLD + "Death point restored.");
}
示例11: loadInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void loadInventory(Player p)
{
p.getInventory().clear();
p.getInventory().setContents((ItemStack[])inventoryContents.get(p.getName()));
p.getInventory().setArmorContents((ItemStack[])armorContents.get(p.getName()));
p.setLevel(((Integer)xplevel.get(p.getName())).intValue());
inventoryContents.remove(p.getName());
armorContents.remove(p.getName());
xplevel.remove(p.getName());
}
示例12: startChallenge
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void startChallenge(final Player player) {
final int challenge;
if(isTesting(player)) {
challenge = getChallenge(player);
} else {
challenge = plugin.getPlayerManager().getRank(player) + 1;
}
long price = plugin.getChallengesFile().getPrice(challenge) * (plugin.getPlayerManager().getPrestige(player) + 1);
if(!plugin.getEconomy().has(player, price)) {
player.sendMessage(Lang.HEADERS_CHALLENGES.toString() +
Lang.CHALLENGES_NOT_ENOUGH_MONEY.toString().replaceAll("%d", Convert.toPrice(price, false)));
return;
}
plugin.getEconomy().withdrawPlayer(player, price);
saveData(player, challenge, price);
player.teleport(plugin.getChallengesFile().getSpawnpoint(challenge));
if("fight".equalsIgnoreCase(plugin.getChallengesFile().getType(challenge))) {
new BukkitRunnable() {
public void run() {
if(plugin.getChallengesFile().getMonsters(challenge) != null) {
String[] split;
for(String mob : plugin.getChallengesFile().getMonsters(challenge)) {
split = mob.split(", ");
addMobs(player, Integer.parseInt(split[1]));
Convert.spawnEntity(player.getName(), challenge, split[0], Integer.parseInt(split[1]));
}
}
}
}.runTaskLater(plugin, 20L);
}
if("fight".equalsIgnoreCase(plugin.getChallengesFile().getType(challenge))) {
player.setLevel(getKillsLeft(player));
player.setExp(0F);
}
player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
+ Lang.CHALLENGES_START.toString()
.replaceAll("%s", plugin.getChallengesFile().getTitle(challenge))
.replaceAll("%d", Convert.toPrice(price, false)));
}
示例13: buySlot
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean buySlot(@NotNull Player player, int line) {
if (RPGInventory.economyConnected() && RPGInventory.getEconomy().withdrawPlayer(player, Config.getConfig().getDouble("slots.money.cost.line" + line)).transactionSuccess()) {
if (RPGInventory.getLevelSystem() == PlayerUtils.LevelSystem.EXP && Config.getConfig().getBoolean("slots.level.spend")) {
player.setLevel(player.getLevel() - Config.getConfig().getInt("slots.level.required.line" + line));
}
return true;
}
return false;
}
示例14: 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);
}
示例15: updateXPBar
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void updateXPBar(String bw, Player p) {
p.setLevel(get(bw, p));
}