/** * Handles the gamemode for the specified {@link Player}. * * @param player The {@link Player}. * @param world The world the player is in. */ public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) { if (!MVPlayerListener.this.pt.playerCanIgnoreGameModeRestriction(world, player)) { // Check that the player is in the new world and they haven't been teleported elsewhere or the // event cancelled. if (player.getWorld() == world.getCBWorld()) { Logging.fine( "Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString()); Logging.finest("From World: %s", player.getWorld()); Logging.finest("To World: %s", world); player.setGameMode(world.getGameMode()); // Check if their flight mode should change // TODO need a override permission for this if (player.getAllowFlight() && !world.getAllowFlight() && player.getGameMode() != GameMode.CREATIVE) { player.setAllowFlight(false); if (player.isFlying()) { player.setFlying(false); } } else if (world.getAllowFlight()) { if (player.getGameMode() == GameMode.CREATIVE) { player.setAllowFlight(true); } } } else { Logging.fine( "The gamemode/allowfly was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'", player.getName(), player.getWorld().getName(), world.getName()); } } else { MVPlayerListener.this.plugin.log( Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!"); } }
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if ((sender instanceof Player)) { if (args.length < 1) { Player p = (Player) sender; Boolean flying = p.isFlying(); p.setAllowFlight(!flying); p.setFlying(!flying); p.sendMessage("Fly mode changed!"); return true; } else { if (plugin.getServer().getPlayer(args[0]) != null) { Player pl = plugin.getServer().getPlayer(args[0]); boolean flying = pl.isFlying(); pl.setAllowFlight(!flying); pl.setFlying(!flying); pl.sendMessage(sender.getName() + " changed your fly mode to " + !flying); return true; } else { sender.sendMessage("Player not existing"); return false; } } } else { sender.sendMessage("Only a player could execute this command"); return true; } }
@SuppressWarnings("deprecation") @EventHandler public void onMove(PlayerMoveEvent e) { if (!plugin.getConfig().getBoolean("Complete")) return; Player p = e.getPlayer(); if (plugin.spieler != null && plugin.spieler == p) { if (p.getLocation().getWorld().getBlockAt(p.getLocation()).getTypeId() == 147) { if (!plugin.bfinish) { SpeedBuilder.gm.Win(); } } if (p.getLocation().getY() < plugin.spawnloc.getY() - 10) { if (plugin.starttime != 0 && !plugin.bfinish) { p.setAllowFlight(true); p.setFlying(true); p.teleport(plugin.spawnloc.clone().add(0, 1, 0)); SpeedBuilder.gm.Loose(); } else { p.teleport(plugin.spawnloc); } } } if (plugin.spectating.contains(p)) { if (p.getLocation().getY() <= plugin.spawnloc.clone().add(0, 15, 0).getY()) { p.teleport(p.getLocation().add(0, 3, 0)); p.setAllowFlight(true); p.setFlying(true); } } }
public FireJet(Player player) { if (instances.containsKey(player)) { // player.setAllowFlight(canfly); instances.remove(player); return; } if (timers.containsKey(player)) { if (System.currentTimeMillis() < timers.get(player) + (long) ((double) cooldown / Tools.getFirebendingDayAugment(player.getWorld()))) { return; } } factor = Tools.firebendingDayAugment(defaultfactor, player.getWorld()); Block block = player.getLocation().getBlock(); if (FireStream.isIgnitable(player, block) || block.getType() == Material.AIR || AvatarState.isAvatarState(player)) { player.setVelocity( player.getEyeLocation().getDirection().clone().normalize().multiply(factor)); block.setType(Material.FIRE); this.player = player; // canfly = player.getAllowFlight(); player.setAllowFlight(true); time = System.currentTimeMillis(); timers.put(player, time); instances.put(player, this); } }
public void leaveTeam(CommandSender sender, String[] args) { Player player; if (args.length >= 2) { player = getPlayerByName(args[1]); } else { player = getPlayerFromCommandSender(sender); } TeamManager teamManager = plugin.getTeamManager(); if (teamManager.hasTeam(player)) { teamManager.removePlayer(player); if (plugin.getGameManager().isGameInProgress()) { teamManager.setSpectating(player, 1); player.setAllowFlight(true); player.setFlying(true); player.sendMessage(ChatColor.RED + "You have been set as a spectator"); } notifyAdmins(sender, String.format("Removed %s from their team", player.getName())); } else { throw new CommandException( String.format("Could not remove %s from their team", player.getName())); } }
public void removeSpectator(Player p) { ArrayList<Player> players = new ArrayList<Player>(); players.addAll(activePlayers); players.addAll(inactivePlayers); if (p.isOnline()) { for (Player pl : Bukkit.getOnlinePlayers()) { pl.showPlayer(p); } } // restoreInv(p); p.setAllowFlight(false); p.setFlying(false); p.setFallDistance(0); p.setHealth(p.getMaxHealth()); p.setFoodLevel(20); p.setSaturation(20); p.teleport(SettingsManager.getInstance().getLobbySpawn()); // Bukkit.getServer().broadcastPrefixType("Removing Spec "+p.getName()+" "+spectators.size()+" // left"); spectators.remove(p.getName()); // Bukkit.getServer().broadcastPrefixType("Removed"); nextspec.remove(p); }
@EventHandler public void onMove(PlayerMoveEvent e) { Player p = e.getPlayer(); double x = p.getLocation().getX(); double y = p.getLocation().getY() - 1; double z = p.getLocation().getZ(); Location loc = new Location(p.getWorld(), x, y, z); Block b1 = loc.getBlock(); Block b2 = p.getLocation().getBlock(); if (b1.getType().equals(Material.REDSTONE_BLOCK) && b2.getType().equals(Material.WOOD_PLATE)) { // p.sendMessage("ON " + b1.getType().toString() + " + " + b2.getType().toString()); p.setVelocity(p.getLocation().getDirection().multiply(2).setY(p.getVelocity().getY() + 1)); p.setFallDistance(0f); for (Player all : Bukkit.getOnlinePlayers()) { all.playSound(p.getLocation(), Sound.WITHER_SHOOT, 0.1f, 0.1f); } } p.setSaturation(100f); p.setFoodLevel(20); p.setHealth(20f); if (p.getLocation().getY() <= 80) { p.teleport(p.getWorld().getSpawnLocation()); p.setGameMode(GameMode.ADVENTURE); p.setAllowFlight(true); p.setFlying(false); } }
@EventHandler public void onPlayerQuit(PlayerQuitEvent e) { Player p = e.getPlayer(); if (Config.getConfig().getBoolean("options.set-fly-on-join.fly")) p.setAllowFlight(false); if (Config.getConfig().getBoolean("broadcast.player-quit.enabled")) { if (Config.getConfig().getBoolean("broadcast.player-quit.hide")) { e.setQuitMessage(null); } else { e.setQuitMessage( ChatColor.translateAlternateColorCodes( '&', Config.getConfig() .getString("broadcast.player-quit.message") .replaceAll("%player%", e.getPlayer().getName()))); } } if (pvp.containsKey(p)) { if (pvp.get(p).isSync()) pvp.get(p).cancel(); pvp.remove(p); } if (Commands.delay.containsKey(p)) { if (Commands.delay.get(p).getTask().isSync()) Commands.delay.get(p).getTask().cancel(); Commands.delay.remove(p); } }
@SuppressWarnings("deprecation") public void restoreState() { if (state == null) { return; } bukkitPlayer.getInventory().setContents(state.getContents()); bukkitPlayer.getInventory().setHelmet(state.getHelmet()); bukkitPlayer.getInventory().setChestplate(state.getChestplate()); bukkitPlayer.getInventory().setLeggings(state.getLeggings()); bukkitPlayer.getInventory().setBoots(state.getBoots()); bukkitPlayer.setExhaustion(state.getExhaustion()); bukkitPlayer.setSaturation(state.getSaturation()); bukkitPlayer.setFoodLevel(state.getFoodLevel()); bukkitPlayer.setHealth(state.getHealth()); bukkitPlayer.addPotionEffects(state.getPotioneffects()); bukkitPlayer.setLevel(state.getLevel()); bukkitPlayer.setExp(state.getExp()); bukkitPlayer.setAllowFlight(state.isFly()); sendMessage(I18N._("stateRestored")); bukkitPlayer.updateInventory(); state = null; }
public AirScooter(Player player) { super(player); if (check(player)) return; else if (!player.isSprinting() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) || player.getEyeLocation().getBlock().isLiquid()) return; else if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) return; else if (bPlayer.isOnCooldown(this)) return; this.speed = getConfig().getDouble("Abilities.Air.AirScooter.Speed"); this.interval = getConfig().getDouble("Abilities.Air.AirScooter.Interval"); this.radius = getConfig().getDouble("Abilities.Air.AirScooter.Radius"); this.cooldown = getConfig().getLong("Abilities.Air.AirScooter.Cooldown"); this.maxHeightFromGround = getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround"); this.random = new Random(); this.angles = new ArrayList<>(); canFly = player.getAllowFlight(); hadFly = player.isFlying(); new Flight(player); player.setAllowFlight(true); player.setFlying(true); player.setSprinting(false); for (int i = 0; i < 5; i++) { angles.add((double) (60 * i)); } start(); }
public static void restoreInventory(Player player) { player.getInventory().clear(); player.teleport((Location) locations.get(player.getName())); for (PotionEffect effect : player.getActivePotionEffects()) { player.removePotionEffect(effect.getType()); } player.getInventory().setContents((ItemStack[]) inventoryContents.get(player.getName())); player.getInventory().setArmorContents((ItemStack[]) armourContents.get(player.getName())); player.setExp(((Float) xp.get(player.getName())).floatValue()); player.setLevel(((Integer) xpLevel.get(player.getName())).intValue()); player.setGameMode((GameMode) gameModes.get(player.getName())); player.addPotionEffects((Collection<PotionEffect>) potions.get(player.getName())); player.setFoodLevel(((Integer) foodLevel.get(player.getName())).intValue()); player.setHealth(((Double) Health.get(player.getName())).doubleValue()); player.setAllowFlight(((Boolean) flight.get(player.getName())).booleanValue()); flight.remove(player.getName()); Health.remove(player.getName()); foodLevel.remove(player.getName()); potions.remove(player.getName()); xpLevel.remove(player.getName()); xp.remove(player.getName()); locations.remove(player.getName()); armourContents.remove(player.getName()); inventoryContents.remove(player.getName()); gameModes.remove(player.getName()); }
public static void startGame() { for (int i = 1; i <= 8; i++) { if (i > inqueue.size()) { break; } Player p = Bukkit.getPlayer(inqueue.get(i - 1)); p.setAllowFlight(false); p.setFlying(false); if (p.getGameMode() != GameMode.SURVIVAL) { p.setGameMode(GameMode.SURVIVAL); } Location loc = Game.getLocation("Spawn" + i).add(0.5, 1, 0.5); p.teleport(loc); p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 2)); invs.put(p.getName(), p.getInventory().getContents()); armors.put(p.getName(), p.getInventory().getArmorContents()); p.getInventory().clear(); p.getInventory().setBoots(null); p.getInventory().setLeggings(null); p.getInventory().setChestplate(null); p.getInventory().setHelmet(null); p.updateInventory(); p.setWalkSpeed(0.2f); ParticleEffect.FIREWORKS_SPARK.display(0.5f, 1f, 0.5f, 0.05f, 20, loc, 100); ingame.add(p.getName()); } inqueue.removeAll(ingame); sendToAll(Game.tag + "§eGame starting."); for (int i = 1; i <= inqueue.size(); i++) { int util = i - 1; Player p = Bukkit.getPlayer(inqueue.get(util)); p.sendMessage( Game.tag + "§eA game has started, you have been moved to §b" + i + "§e in queue."); } }
private void removeFlight(Player p) { if (disableFlight && p.getGameMode() != GameMode.CREATIVE) { if (p.getAllowFlight()) couldFly.add(p.getName()); if (p.isFlying()) hadFlight.add(p.getName()); p.setFlying(false); p.setAllowFlight(false); } }
@EventHandler public void onGamemodeChange(PlayerGameModeChangeEvent e) { if (e.getNewGameMode().equals(GameMode.ADVENTURE)) { Player p = e.getPlayer(); p.setAllowFlight(true); p.setFlying(false); } }
@EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); p.sendMessage(ChatColor.GREEN + "Welcome to the server!"); p.teleport(p.getWorld().getSpawnLocation()); p.setGameMode(GameMode.ADVENTURE); p.setAllowFlight(true); p.setFlying(false); }
private void fixFlying(Player player) { if (couldFly.contains(player.getName())) { couldFly.remove(player.getName()); player.setAllowFlight(true); } if (hadFlight.contains(player.getName())) { hadFlight.remove(player.getName()); player.setFlying(true); } }
@SuppressWarnings("deprecation") public void run() { for (Player p : c.getServer().getOnlinePlayers()) { for (ItemStack is : p.getInventory().getContents()) { if (is == null || is.getType() == Material.AIR || !is.hasItemMeta()) continue; if (!is.getItemMeta().hasLore()) continue; if (!c.hasCustomEnchant(is.getItemMeta().getLore())) continue; boolean b = false; for (String s : is.getItemMeta().getLore()) { if (!c.isCustomEnchant(s)) continue; if (s.startsWith(ChatColor.RESET + "Repair ")) b = true; } if (!b) continue; if (is.getDurability() > 0) is.setDurability((short) (is.getDurability() - 1)); } boolean hasChestplateOn = false; for (ItemStack is : p.getInventory().getArmorContents()) { if (is == null || !is.getType().name().endsWith("CHESTPLATE") || !is.hasItemMeta()) continue; if (!is.getItemMeta().hasLore()) continue; if (!c.hasCustomEnchant(is.getItemMeta().getLore())) continue; boolean b = false; for (String s : is.getItemMeta().getLore()) { if (!c.isCustomEnchant(s)) continue; if (s.startsWith(ChatColor.RESET + "Flying ")) b = true; } if (!b) continue; if (!hasChestplateOn) { if (!p.isFlying()) { p.sendMessage(ChatColor.GOLD + "Flying enabled!"); } p.setAllowFlight(true); p.setFlying(true); hasChestplateOn = true; } } if (!hasChestplateOn && p.getGameMode() != GameMode.CREATIVE && p.isFlying()) { p.setFlying(false); p.setAllowFlight(false); } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJump(PlayerMoveEvent event) { Location from = event.getFrom(); Location to = event.getTo(); if (to.getBlockY() > from.getBlockY()) { Player player = event.getPlayer(); if (FOPM_TFM_Util.isDoubleJumper(player)) { player.setAllowFlight(true); } } }
@Override public void run(final CommandSender cs, String label, String[] args) { if (r.checkArgs(args, 0) == false) { if (!(r.isPlayer(cs))) { return; } if (!r.perm(cs, "uc.fly", false, true)) { return; } Player p = (Player) cs; if (p.getAllowFlight() == true) { p.setAllowFlight(false); r.sendMes(cs, "flySelf", "%Status", r.mes("off")); } else { p.setAllowFlight(true); p.setFlySpeed(0.1F); r.sendMes(cs, "flySelf", "%Status", r.mes("on")); } } else { if (!r.perm(cs, "uc.fly.others", false, true)) { return; } Player target = r.searchPlayer(args[0]); if (target != null) { if (target.getAllowFlight() == true) { target.setAllowFlight(false); r.sendMes( target, "flyOthersOther", "%Status", r.mes("off"), "%Player", r.getDisplayName(cs)); r.sendMes(cs, "flyOthersSelf", "%Status", r.mes("off"), "%Player", target.getName()); } else { target.setAllowFlight(true); r.sendMes( target, "flyOthersOther", "%Status", r.mes("on"), "%Player", r.getDisplayName(cs)); r.sendMes(cs, "flyOthersSelf", "%Status", r.mes("on"), "%Player", target.getName()); } } else { r.sendMes(cs, "playerNotFound", "%Player", args[0]); } } }
@EventHandler(priority = EventPriority.NORMAL) public void dmg(final EntityDamageEvent event) { Entity e = event.getEntity(); if (e instanceof Player) { if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { Player p = (Player) e; if (p.hasPermission("cooljump.jump")) { event.setCancelled(true); p.setAllowFlight(true); } } } }
@EventHandler public static void onFly(PlayerToggleFlightEvent event) { Player p = event.getPlayer(); if (p.getGameMode() != GameMode.CREATIVE && event.isFlying()) { event.setCancelled(true); Vector jump = p.getLocation().getDirection().multiply(0.4).setY(1.1); p.setVelocity(p.getVelocity().add(jump)); p.setAllowFlight(false); p.setFallDistance(1); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 100, 1); ParticleEffect.CLOUD.display(1, 1, 1, 1, 20, p.getLocation(), 20); } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 0) { ((Player) sender).setAllowFlight(!((Player) sender).getAllowFlight()); sender.sendMessage( ChatColor.GOLD + "Toggled fly for " + ChatColor.RED + sender.getName() + ChatColor.GOLD + ". Flight: " + ChatColor.RED + ((Player) sender).getAllowFlight()); return true; } else { String pla = args[0]; Player p = Bukkit.getPlayer(pla); if (p == null) { sender.sendMessage(ChatColor.RED + "That player is not online."); return true; } p.setSaturation(20); p.setAllowFlight(!p.getAllowFlight()); p.sendMessage(ChatColor.GOLD + "Allowed Flight: " + ChatColor.RED + p.getAllowFlight()); sender.sendMessage( ChatColor.GOLD + "Toggled flight for " + ChatColor.RED + p.getName() + ChatColor.GOLD + ". Allowed Flight: " + ChatColor.RED + p.getAllowFlight()); return true; } }
@SuppressWarnings("deprecation") public void saveState() { bukkitPlayer.setGameMode(GameMode.SURVIVAL);//Set to survival //Define player states variables ItemStack[] contents = bukkitPlayer.getInventory().getContents(); ItemStack helmet = bukkitPlayer.getInventory().getHelmet(); ItemStack chestplate = bukkitPlayer.getInventory().getChestplate(); ItemStack leggings = bukkitPlayer.getInventory().getLeggings(); ItemStack boots = bukkitPlayer.getInventory().getBoots(); float exhaustion = bukkitPlayer.getExhaustion(); float saturation = bukkitPlayer.getSaturation(); int foodLevel = bukkitPlayer.getFoodLevel(); double health = bukkitPlayer.getHealth(); GameMode gm = bukkitPlayer.getGameMode(); Collection<PotionEffect> potionEffects = bukkitPlayer.getActivePotionEffects(); float exp = bukkitPlayer.getExp(); int level = bukkitPlayer.getLevel(); boolean fly = bukkitPlayer.getAllowFlight(); //Save state state = new PlayerState(contents, helmet, chestplate, leggings, boots, exhaustion, saturation, foodLevel, health, gm, potionEffects, exp, level, fly); //Set to default state bukkitPlayer.setFoodLevel(20); bukkitPlayer.setHealth(20.0); bukkitPlayer.setAllowFlight(false);//Disable fly mode (Essentials etc.) bukkitPlayer.setFireTicks(0); bukkitPlayer.getInventory().clear(); bukkitPlayer.getInventory().setArmorContents(new ItemStack[4]); bukkitPlayer.setLevel(0); bukkitPlayer.setExp(0); for (PotionEffect effect : bukkitPlayer.getActivePotionEffects()) { bukkitPlayer.removePotionEffect(effect.getType()); } bukkitPlayer.sendMessage(I18N._("stateSaved")); bukkitPlayer.updateInventory(); }
public static void clearupperson(Player p) { p.setAllowFlight(false); p.setLevel(0); p.setExp(0); p.setFoodLevel(20); p.setSaturation(10); p.setHealth(20D); PlayerInventory pi = p.getInventory(); pi.clear(); pi.setHeldItemSlot(0); ItemStack Air = new ItemStack(Material.AIR); pi.setHelmet(Air); pi.setChestplate(Air); pi.setLeggings(Air); pi.setBoots(Air); for (PotionEffect effect : p.getActivePotionEffects()) p.removePotionEffect(effect.getType()); }
@EventHandler public void onFly(PlayerToggleFlightEvent e) { final Player p = e.getPlayer(); Runnable jump2 = new Runnable() { public void run() { p.setLevel(2); p.setFallDistance(-100); } }; Runnable jump1 = new Runnable() { public void run() { p.setLevel(1); p.setFallDistance(-100); } }; Runnable jump = new Runnable() { public void run() { p.setAllowFlight(true); p.setFlying(false); p.setLevel(0); p.setFallDistance(-100); } }; if (p.getGameMode().equals(GameMode.ADVENTURE) && e.isFlying() == true) { p.setFlying(false); p.setAllowFlight(false); p.setLevel(3); for (Player all : Bukkit.getOnlinePlayers()) { all.playSound(p.getLocation(), Sound.WITHER_SHOOT, 0.1f, 0.1f); } p.setVelocity(p.getLocation().getDirection().multiply(3).setY(p.getVelocity().getY() + 1.5)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump2, 20L); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump1, 40L); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump, 60L); } }
public static void saveInventory(Player player) { armourContents.put(player.getName(), player.getInventory().getArmorContents()); inventoryContents.put(player.getName(), player.getInventory().getContents()); locations.put(player.getName(), player.getLocation()); xp.put(player.getName(), Float.valueOf(player.getExp())); xpLevel.put(player.getName(), Integer.valueOf(player.getLevel())); gameModes.put(player.getName(), player.getGameMode()); potions.put(player.getName(), player.getActivePotionEffects()); foodLevel.put(player.getName(), Integer.valueOf(player.getFoodLevel())); Health.put(player.getName(), Double.valueOf(player.getHealth())); flight.put(player.getName(), Boolean.valueOf(player.getAllowFlight())); player.setAllowFlight(false); player.setHealth(20.0D); player.setFoodLevel(20); for (PotionEffect effect : player.getActivePotionEffects()) { player.removePotionEffect(effect.getType()); } player.getInventory().clear(); player.setLevel(0); player.setExp(0.0F); player.setGameMode(GameMode.SURVIVAL); }
@Override public void onDisable() { if (output) { console.sendMessage(prefix + "Disabling..."); } for (Player player : getServer().getOnlinePlayers()) { for (Player target : getServer().getOnlinePlayers()) { target.showPlayer(player); } if (user.get(player.getName()).spectating) { player.removePotionEffect(PotionEffectType.HEAL); player.setAllowFlight(false); player.setGameMode(getServer().getDefaultGameMode()); player.getInventory().clear(); if (scoreboard) { team.removePlayer(player); } loadPlayerInv(player); spawnPlayer(player); user.get(player.getName()).spectating = false; } } }
public void joinTeam(CommandSender sender, String[] args) { Player player; if (args.length >= 3) { player = getPlayerByName(args[2]); } else { player = getPlayerFromCommandSender(sender); } TeamManager teamManager = plugin.getTeamManager(); if (teamManager.isTeam(args[1])) { teamManager.addPlayer(player, args[1]); if (plugin.getGameManager().isGameInProgress()) { teamManager.setKills(player, 0); teamManager.setDeaths(player, 0); teamManager.setSpectating(player, 0); if (!player.getGameMode().equals(GameMode.CREATIVE)) { player.setFlying(false); player.setAllowFlight(false); } if (teamManager.hasSpawn(player)) { player.teleport(plugin.getTeamManager().getSpawn(player)); } boolean keepInventory = args.length == 4 ? parseBoolean(args[3]) : false; if (!keepInventory) { teamManager.kitPlayer(player); } } notifyAdmins(sender, String.format("Added %s to team %s", player.getName(), args[1])); } else { throw new CommandException(String.format("No team was found by the name of %s", args[1])); } }
private void checkCoords(PlayerMoveEvent event, Player player, boolean isTeleport) { plugin.debug("FlyingListener Check Coords : " + isTeleport); if (!player.getAllowFlight()) return; SimpleIsland isle = plugin.getPlayerIsland(player); final SimpleIsland isleh = plugin.getHelpingIsland(player); if (isle == null && isleh != null && plugin.getOurConfig().isHelperAllowed("home")) isle = isleh; if (isle != null) { if (plugin.isInsideIslandCuboid(event.getFrom(), isle) && !plugin.isInsideIslandCuboid(event.getTo(), isle)) { if (isTeleport) { plugin.showMessage(player, ChatColor.AQUA + plugin.getLoc("info-flying-dis-tele")); player.setAllowFlight(false); } else { plugin.showMessage(player, ChatColor.AQUA + plugin.getLoc("info-flying-dis")); event.setCancelled(true); } } } }
@EventHandler public void onPlayerJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); if (Main.hasNewVersion() && p.isOp()) p.sendMessage( ChatColor.translateAlternateColorCodes( '&', Config.getConfig().getString("check-version.warning-message"))); if (Config.getConfig().getBoolean("broadcast.player-join.enabled")) { if (Config.getConfig().getBoolean("broadcast.player-join.hide")) { e.setJoinMessage(null); } else { e.setJoinMessage( ChatColor.translateAlternateColorCodes( '&', Config.getConfig() .getString("broadcast.player-join.message") .replaceAll("%player%", p.getName()))); } } if (Config.getConfig().getBoolean("join-message.enabled")) { for (String message : Config.getConfig().getStringList("join-message.text")) { p.sendMessage( ChatColor.translateAlternateColorCodes( '&', message.replaceAll("%player%", p.getName()))); } } if (p.hasPlayedBefore()) { if (Config.getConfig().getBoolean("teleport-to-spawn-on.join")) { Utils.teleportToSpawn(p); } } else { if (Config.getConfig().getBoolean("teleport-to-spawn-on.first-join")) Utils.teleportToSpawn(p); if (Config.getConfig().getBoolean("broadcast.first-join.enabled")) Bukkit.broadcastMessage( ChatColor.translateAlternateColorCodes( '&', Config.getConfig() .getString("broadcast.first-join.message") .replaceAll("%player%", p.getName()))); if (Config.getConfig().getBoolean("first-join-message.enabled")) { for (String message : Config.getConfig().getStringList("first-join-message.text")) { p.sendMessage( ChatColor.translateAlternateColorCodes( '&', message.replaceAll("%player%", p.getName()))); } } } int gm = Config.getConfig().getInt("options.set-gamemode-on-join.gamemode"); if (Config.getConfig().getBoolean("options.set-gamemode-on-join.enabled")) { if (gm == 0) { p.setGameMode(GameMode.SURVIVAL); } else if (gm == 1) { p.setGameMode(GameMode.CREATIVE); } else if (gm == 2) { p.setGameMode(GameMode.ADVENTURE); } else if (gm == 3) { p.setGameMode(GameMode.SPECTATOR); } } if (Config.getConfig().getBoolean("options.set-fly-on-join.enabled") && gm != 3) p.setAllowFlight(Config.getConfig().getBoolean("options.set-fly-on-join.fly")); if (Config.getConfig().getBoolean("options.set-max-health-on-join")) p.setHealth(20.0); if (Config.getConfig().getBoolean("options.set-max-food-level-on-join")) p.setFoodLevel(20); }