本文整理汇总了Java中org.bukkit.entity.Player.setFoodLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setFoodLevel方法的具体用法?Java Player.setFoodLevel怎么用?Java Player.setFoodLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.setFoodLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void resetPlayer(Player player) {
player.setLevel(0);
player.setExp(0);
player.setFoodLevel(20);
player.setHealth(20);
player.setHealthScale(20);
player.setExhaustion(0);
player.getInventory().clear();
ItemStack blankItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
ItemMeta blankMeta = blankItem.getItemMeta();
blankMeta.setDisplayName("" + ChatColor.RED);
blankItem.setItemMeta(blankMeta);
for(int i=9; i<=35; i++) {
player.getInventory().setItem(i, blankItem);
}
player.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
player.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
player.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
player.getInventory().setBoots(new ItemStack(Material.AIR, 1));
for(PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
player.setFireTicks(0);
}
示例2: onPreStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPreStart() {
Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(spawnLocation);
player.setGameMode(GameMode.ADVENTURE);
player.setFoodLevel(1);
}
this.potionDropLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("potionDropPosition"));
this.potionVelocityMultiplier = Double.parseDouble((String) this.getGameMap().fetchSetting("potionVelocityMultiplier"));
this.healthDropPerTwoSeconds = Double.parseDouble((String) this.getGameMap().fetchSetting("healthDropPerTwoSeconds"));
this.potionDropPerSecond = Integer.parseInt((String) this.getGameMap().fetchSetting("potionDropPerSecond"));
this.poisonEffectDelayInSeconds = Integer.parseInt((String) this.getGameMap().fetchSetting("poisonEffectDelayInSeconds"))+1;
this.witherEffectDelayInSeconds = Integer.parseInt((String) this.getGameMap().fetchSetting("witherEffectDelayInSeconds"))+1;
this.slownessEffectDelayInSeconds = Integer.parseInt((String) this.getGameMap().fetchSetting("slownessEffectDelayInSeconds"))+1;
}
示例3: 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");
}
示例4: onJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
event.setJoinMessage(null);
if (!Skywars.getInstance().isSingleServerMode()) {
player.setGameMode(GameMode.ADVENTURE);
player.getInventory().clear();
player.setMaxHealth(20);
player.setHealth(player.getMaxHealth());
player.setFoodLevel(25);
player.teleport(Skywars.getInstance().getLobbyPoint());
}
}
示例5: 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;
}
示例6: startup
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**Called when the first button within the entry Module was just pushed
* Takes appropriate startup actions and then sets the state to RUNNING.
*/
private void startup() {
getServer().getPluginManager().registerEvents(this, this);
activePlayers = new LinkedList<>(getServer().getOnlinePlayers());
// Backing up player modes to restore upon dungeon stop
playersSnapshotAtStart = new ArrayList<GameMode>();// backup copy of gamemode
for (int i=0; i<activePlayers.size(); i++) {
playersSnapshotAtStart.add(activePlayers.get(i).getGameMode());
}
for (Player p : activePlayers) {
p.setFoodLevel(18);
p.setGameMode(GameMode.ADVENTURE);
p.sendMessage("Your mode was set to adventure...");
giveStartingGear(p);
}
state = State.RUNNING;
}
示例7: 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();
}
示例8: 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 !");
}
示例9: resetPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void resetPlayer(Player player) {
player.setCanPickupItems(false);
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[4]);
player.setHealth(20.0);
player.setFoodLevel(20);
player.setFireTicks(1);
player.getActivePotionEffects().forEach(effect -> player.removePotionEffect(effect.getType()));
}
示例10: StartGame
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void StartGame() {
gameSituation = true;
startTime = System.currentTimeMillis();
for (Player players : Bukkit.getOnlinePlayers()) {
players.setGameMode(GameMode.SURVIVAL);
players.getInventory().clear();
players.setFoodLevel(20);
players.setMaxHealth(40);
players.teleport(findLocation(players));
}
}
示例11: 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);
}
示例12: 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);
}
示例13: onPlayerJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
joinTimes.put(event.getPlayer().getName(), new Date());
event.setJoinMessage(null);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
Location l = event.getPlayer().getWorld().getSpawnLocation();
l.setX(14.5);
l.setY(10.5);
l.setZ(-795.5);
l.setPitch(0.5F);
l.setYaw(90 * RandomUtil.between(1, 4));
p.teleport(l);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().addItem(Lobby.book);
p.getInventory().addItem(Lobby.compass);
Lobby.addPotionEffect(event.getPlayer(), new PotionEffect(PotionEffectType.SPEED, 2147483647, 2));
if (Gamer.get(p.getName()).getRank().getLevel() >= RankType.ADMIN.getLevel())
event.getPlayer().addAttachment(Lobby.getInstance(), "bukkit.command.gamemode", true);
}
示例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: onHungerChange
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onHungerChange(FoodLevelChangeEvent e){
if(e.getEntity() instanceof Player){
Player p = (Player) e.getEntity();
p.setSaturation(1000);
p.setFoodLevel(20);
}
}