本文整理汇总了Java中org.bukkit.entity.Player.setExp方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setExp方法的具体用法?Java Player.setExp怎么用?Java Player.setExp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.setExp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleLogin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void handleLogin(Player p)
{
super.handleLogin(p);
p.setGameMode(GameMode.ADVENTURE);
p.setLevel(0);
p.setExp(0);
p.setFoodLevel(20);
p.setSaturation(20);
Location spec = new Location(AgarMC.get().getWorld(), origin.getX() + dimensions / 2, origin.getY() + 20, origin.getZ() + dimensions / 2);
spec.setPitch(90);
p.teleport(spec);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
if (gamePlayers.size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
this.status = Status.IN_GAME;
Titles.sendTabTitle(p, ChatColor.GREEN + "Bienvenue sur " + ChatColor.AQUA + "SamaGames" + ChatColor.GREEN + " !\n",
ChatColor.AQUA + "\nTeamSpeak : " + ChatColor.GREEN + "ts.samagames.net");
}
示例2: 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());
}
}
示例3: 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));
}
示例4: onJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent event) {
plugin.getPlayerManager().loadData(event.getPlayer());
if(event.getPlayer().hasPermission("asgardascension.staff")) {
event.getPlayer().setPlayerListName(ChatColor.YELLOW + event.getPlayer().getDisplayName());
}
// Restoring location, level and experience in case server crashed
plugin.getPlayerFile().createConfig(event.getPlayer());
if(plugin.getPlayerFile().isInChallenge()) {
Player player = event.getPlayer();
player.teleport(plugin.getPlayerFile().getChallengeLocation());
player.setLevel(plugin.getPlayerFile().getChallengeLevel());
player.setExp(plugin.getPlayerFile().getChallengeExperience());
plugin.getEconomy().depositPlayer(player, plugin.getPlayerFile().getChallengePrice());
plugin.getPlayerFile().removeChallenge();
plugin.getPlayerFile().saveConfig();
}
}
示例5: loadData
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void loadData(Player player) {
player.setFireTicks(0);
player.setHealth(20);
player.setLevel(level.get(player.getName()));
player.setExp(exp.get(player.getName()));
playerLocation.remove(player.getName());
testing.remove(player.getName());
armor.remove(player.getName());
inventory.remove(player.getName());
killsLeft.remove(player.getName());
exp.remove(player.getName());
level.remove(player.getName());
plugin.getPlayerFile().createConfig(player);
plugin.getPlayerFile().removeChallenge();
plugin.getPlayerFile().saveConfig();
}
示例6: 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;
}
示例7: 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);
}
示例8: restore
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void restore(Player p) {
PlayerInventory inv = p.getInventory();
inv.setContents(items);
inv.setArmorContents(armorItems);
p.setLevel(level);
p.setExp(exp);
p.updateInventory();
}
示例9: 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();
}
示例10: onPlayerJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Should be executed when the player joins the server.
*/
protected void onPlayerJoin() {
// Resets
Player player = getPlayer();
player.setLevel(0);
player.setExp(0);
player.setFoodLevel(20);
player.setSaturation(20);
player.setHealth(20);
// TODO coherence
getPlayer().sendMessage(ChatColor.GOLD + "Bienvenue en Apsorbtion !");
}
示例11: 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);
}
示例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: subtractExpPoints
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void subtractExpPoints(Player p, int points) {
if (points < 0) throw new IllegalArgumentException();
if (points == 0) return;
int total = getExpPoints(p);
if (total < points) throw new IllegalArgumentException("Negative Exp Left");
int newLevel = getLevelForExp(total - points);
int remPoint = total - points - getExpForLevel(newLevel);
p.setLevel(newLevel);
p.setExp(0);
p.giveExp(remPoint);
}
示例14: join
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean join(Player player, Team team) {
this.storeTemporaryInventory(player);
player.getInventory().clear();
player.updateInventory();
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setExp(0);
player.setLevel(0);
if (team == Team.RED) {
player.getInventory().setArmorContents(this.arena.getTeamMeta().getRedItems());
this.redTeam.add(player);
if (this.arena.getTeamMeta().getRedSpawnPoint() != null)
player.teleport(this.arena.getTeamMeta().getRedSpawnPoint());
else
player.teleport(this.arena.getBallSpawnLocation());
player.sendMessage(Language.PREFIX + this.arena.getTeamMeta().getJoinMessage());
if (this.getHologram() != null) {
this.getHologram().show(player);
}
} else {
player.getInventory().setArmorContents(this.arena.getTeamMeta().getBlueItems());
this.blueTeam.add(player);
if (this.arena.getTeamMeta().getBlueSpawnPoint() != null)
player.teleport(this.arena.getTeamMeta().getBlueSpawnPoint());
else
player.teleport(this.arena.getBallSpawnLocation());
player.sendMessage(Language.PREFIX + this.arena.getTeamMeta().getJoinMessage());
if (this.getHologram() != null) {
this.getHologram().show(player);
}
}
return true;
}
示例15: 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);
}