本文整理汇总了Java中org.bukkit.entity.Player.setAllowFlight方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setAllowFlight方法的具体用法?Java Player.setAllowFlight怎么用?Java Player.setAllowFlight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.setAllowFlight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Starts the tutorial for the given player.
*
* @param id The UUID of the player.
*/
public void start(UUID id)
{
if (isWatchingTutorial(id))
{
p.getLogger().info(p.getServer().getPlayer(id).getName() + "(" + id + ") is trying to see the tutorial whilst watching it.");
return;
}
Player player = p.getServer().getPlayer(id);
// The player cannot move anymore (except with our teleportations)
player.setFlySpeed(0f);
player.setAllowFlight(true);
player.setFlying(true);
// All other players are hidden
for (Player other : p.getServer().getOnlinePlayers())
{
player.hidePlayer(other);
other.hidePlayer(player);
}
// The player's hour is updated, if needed
if(tutorialHour != null)
{
player.setPlayerTime(tutorialHour, false);
}
// The tutorial is started
viewers.put(
id, p.getServer().getScheduler().runTaskTimer(p, new TutorialRunner(this, id), 10L, 10L)
);
}
示例2: stop
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Stops the tutorial for the given player.
*
* @param id The UUID of the player.
* @param interrupted {@code true} if the tutorial is stopped because it was interrupted
* using {@link #stopForAll(String)}, {@link #stop(UUID)} or if the
* user disconnected.
*/
void stop(UUID id, final Boolean interrupted) // package-private
{
if (!isWatchingTutorial(id)) return;
Player player = p.getServer().getPlayer(id);
if (player != null)
{
// The player can now move.
player.setFlySpeed(0.1f);
player.setFlying(false);
player.setAllowFlight(false);
// All other players are displayed
for (Player other : p.getServer().getOnlinePlayers())
{
player.showPlayer(other);
other.showPlayer(player);
}
player.resetPlayerTime();
}
try
{
viewers.get(id).cancel();
}
catch (IllegalStateException ignored) {}
viewers.remove(id);
onTutorialEnds(player, interrupted);
}
示例3: setSpectating
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Toggles whether a player is in Spectator Mode.
* @param player
* @param toggle
*/
public void setSpectating(Player player, boolean toggle) {
if(toggle && spec.contains(player)) return;
if(!toggle && !spec.contains(player)) return;
if(toggle) {
player.setAllowFlight(true);
player.setFlying(true);
player.setGameMode(GameMode.SPECTATOR);
spec.add(player);
} else {
player.setGameMode(GameMode.ADVENTURE);
spec.remove(player);
}
this.setAlive(player, false);
Bukkit.getServer().getPluginManager().callEvent(new PlayerAliveStatusEvent(player, false, toggle));
}
示例4: stopSpectating
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void stopSpectating(Player player, boolean sendMsg) {
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
profile.getSpectatingMatch().getSpectators().remove(player.getUniqueId());
profile.setStatus(PlayerStatus.LOBBY);
profile.setSpectatingMatch(null);
GameUtils.resetPlayer(player);
player.getInventory().setContents(GameUtils.getLobbyInventory());
player.updateInventory();
player.setAllowFlight(false);
player.setShowEntities(new ArrayList<>());
ManagerHandler.getConfig().teleportToSpawn(player);
ManagerHandler.getEntityHider().showAllPlayers(player);
if (sendMsg) {
player.sendMessage(ChatColor.RED + "You are no longer spectating the match.");
}
}
示例5: onFly
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
if (this.controller.getGameFromPlayer(event.getPlayer()) != null) {
final Game game = this.controller.getGameFromPlayer(event.getPlayer());
final Player player = event.getPlayer();
if ((player.getGameMode() != GameMode.CREATIVE)) {
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
if (game.getArena().getTeamMeta().isAllowDoubleJump()) {
player.setVelocity(player.getLocation().getDirection()
.multiply(game.getArena().getTeamMeta().getDoubleJumpMeta().getHorizontalStrength())
.setY(game.getArena().getTeamMeta().getDoubleJumpMeta().getVerticalStrength()));
try {
game.getArena().getTeamMeta().getDoubleJumpSound().play(player.getLocation());
} catch (final InterPreter19Exception e) {
Bukkit.getServer().getConsoleSender().sendMessage(BlockBallPlugin.PREFIX_CONSOLE + ChatColor.RED + "Invalid 1.8/1.9 sound. [DoubleJumpSound]");
}
game.getArena().getTeamMeta().getDoubleJumpParticle().play(player.getLocation());
}
}
}
}
示例6: 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();
}
示例7: reset
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void reset(Player player) {
Bukkit.getOnlinePlayers().stream().filter(other -> other != player).forEach(other -> other.hidePlayer(player));
player.setGameMode(GameMode.CREATIVE);
player.setHealth(20.0);
player.setFoodLevel(20);
player.getActivePotionEffects().forEach(potionEffect -> player.removePotionEffect(potionEffect.getType()));
player.setAllowFlight(true);
player.setFlying(true);
player.setVelocity(player.getVelocity().setY(1.1));
player.getInventory().clear();
player.getInventory().setArmorContents(null);
}
示例8: e
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@GameEvent
public void e(@Nonnull PlayerMoveEvent event) {
Player player = event.getPlayer();
if (player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.AIR && (!player.isFlying())) {
player.setAllowFlight(true);
}
}
示例9: cancelMatch
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void cancelMatch(String cancelReason) {
this.sendMessage(ChatColor.DARK_RED + "The match has been canceled for: " + ChatColor.RED + cancelReason);
for (Player player : getPlayers()) {
if (this.leftMatch.contains(player.getUniqueId())) continue;
GameUtils.resetPlayer(player);
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
profile.setStatus(PlayerStatus.LOBBY);
profile.setCurrentMatch(null);
if (profile.getParty() != null) {
if (profile.getParty().getLeader() == player) {
player.getInventory().setContents(GameUtils.getPartyLeaderInventory());
}
else {
player.getInventory().setContents(GameUtils.getPartyMemberInventory());
}
}
else {
player.getInventory().setContents(GameUtils.getLobbyInventory());
}
player.setMaximumNoDamageTicks(19);
player.setAllowFlight(false);
player.updateInventory();
ManagerHandler.getEntityHider().showAllPlayers(player);
ManagerHandler.getConfig().teleportToSpawn(player);
ManagerHandler.getScoreboardHandler().getPlayerBoard(player.getUniqueId()).addUpdates(getPlayers());
}
cleanSpectators();
ManagerHandler.getMatchManager().getMatches().remove(this.identifier);
this.matchStatus = MatchStatus.CANCELED;
}
示例10: 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);
}
示例11: 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);
}
示例12: updateSpectators
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void updateSpectators() {
for (String list : getSpectators()) {
Player t = Bukkit.getPlayerExact(list);
if (t == null || !t.isOnline())
continue;
t.setAllowFlight(true);
for (Player p : Bukkit.getOnlinePlayers()) {
if (getSpectators().contains(p.getName()))
continue;
p.hidePlayer(t);
}
}
}
示例13: equipSpectatingPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void equipSpectatingPlayer(final Player player) {
player.setAllowFlight(true);
player.setFlying(true);
player.getInventory().clear();
player.getInventory().setItem(0, constructItem(Material.NETHER_STAR, 1, (byte) 0, ChatColor.AQUA + "" + ChatColor.BOLD + "Jouer", null));
player.getInventory().setItem(4, Utils.constructBook(constructItem(Material.WRITTEN_BOOK, 1, (byte) 0, ChatColor.LIGHT_PURPLE + "Règles", Arrays.asList(ChatColor.GRAY + "Visualiser les règles du jeu")), ChatColor.LIGHT_PURPLE + "Règles", "Infinity & Rigner", Utils.getRulesBookText()));
player.getInventory().setItem(1, constructItem(Material.WOOL, 1, (byte) 14, AgarMC.get().getGame().getGameType() == GameType.TEAMS ? ChatColor.AQUA + "" + ChatColor.BOLD + "Choisir son équipe" : ChatColor.AQUA + "" + ChatColor.BOLD + "Choisir sa couleur", null));
player.getInventory().setItem(8, SamaGamesAPI.get().getGameManager().getCoherenceMachine().getLeaveItem());
}
示例14: onDamage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if (!TGM.get().getMatchManager().getMatch().getMatchStatus().equals(MatchStatus.MID) || teamManagerModule.getTeam(player).isSpectator()) return;
if (player.getHealth() - event.getFinalDamage() >= 0.5) return;
createDeath(event);
removeLife(player);
event.setDamage(0);
TGM.get().getModule(SpawnPointHandlerModule.class).spawnPlayer(TGM.get().getPlayerManager().getPlayerContext(player), teamManagerModule.getTeam(player), false);
if (getLives(player) <= 0) {
player.setGameMode(GameMode.SPECTATOR);
player.setAllowFlight(true);
player.setFlying(true);
player.getInventory().clear();
if (player.getLocation().getY() < 0) {
player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
}
MatchTeam team = teamManagerModule.getTeam(player);
updateScoreboardTeamLine(team, getAlivePlayers(team).size());
Bukkit.broadcastMessage(team.getColor() + player.getName() + ChatColor.RED + " has been eliminated!");
player.sendTitle("", ChatColor.RED + "You have been eliminated.");
} else {
showLives(player);
player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
}
if (lastTeamAlive()) {
MatchTeam winnerTeam = teamManagerModule.getTeams().stream().filter(matchTeam -> !matchTeam.isSpectator()).filter(matchTeam -> getAlivePlayers(matchTeam).size() > 0).findFirst().get();
if (winnerTeam == null) {
winnerTeam = teamManagerModule.getTeams().get(1);
}
TGM.get().getMatchManager().endMatch(winnerTeam);
return;
}
}
示例15: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
p.setAllowFlight(!p.getAllowFlight());
p.sendMessage(ChatColor.AQUA + "Flying " + (p.getAllowFlight() ? "en" : "dis") + "abled!");
}