public void createDuel(Player p1, Player p2, String mode) { Duel duel = new Duel(this.plugin, p1.getName(), p2.getName(), mode); this.invites.removeAll(p1.getName()); this.invites.removeAll(p2.getName()); p1.getInventory().clear(); p2.getInventory().clear(); p1.updateInventory(); p2.updateInventory(); p1.setHealth(20.0D); p2.setHealth(20.0D); this.duels.add(duel); duel.setTaskID(Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, duel, 0L, 10L)); for (String s : ovo) { Player p = Bukkit.getPlayerExact(s); if ((!p.getName().equals(p1.getName())) && (!p.getName().equals(p2.getName()))) { p1.hidePlayer(p); p2.hidePlayer(p); } } }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) { Player p = event.getPlayer(); if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) { if (p.getItemInHand().getType() == Material.EYE_OF_ENDER) { for (Player other : Bukkit.getServer().getOnlinePlayers()) { other.hidePlayer(p); p.hidePlayer(other); Inventory inventory = p.getInventory(); inventory.setItem(8, new ItemStack(Material.ENDER_PEARL, 1)); } } else if (p.getItemInHand().getType() == Material.ENDER_PEARL) { for (Player other : Bukkit.getServer().getOnlinePlayers()) { other.showPlayer(p); p.showPlayer(other); Inventory inventory = p.getInventory(); inventory.setItem(8, new ItemStack(Material.EYE_OF_ENDER, 1)); } } else if (p.getItemInHand().getType() == Material.GOLD_AXE) { p.launchProjectile(EnderPearl.class); } } else { } }
public static void addSpectator(Player p) { p.teleport(new Location(Bukkit.getWorld("world"), -303, 28, -304)); p.setGameMode(GameMode.CREATIVE); spectators.add(p); for (Player pl : Bukkit.getOnlinePlayers()) { pl.hidePlayer(p); } for (Player pl : spectators) { p.hidePlayer(pl); } p.teleport(new Location(Bukkit.getWorld("world"), -303, 28, -304)); p.getInventory() .setItem(0, itemStack(Material.COMPASS, 1, null, "§aTeleporter", "Right click to use")); }
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); for (String name : invisibles.keySet()) { Player p = PlayerNameUtils.getPlayerExact(name); if (p != null && !name.equals(player.getName())) { player.hidePlayer(p); } } if (invisibles.containsKey(player.getName())) { for (Player p : Bukkit.getOnlinePlayers()) { p.hidePlayer(player); } } }
public boolean onCommand(CommandSender s, Command c, String l, String[] args) { // if(l.equalsIgnoreCase("vanish")) { if (!(s instanceof Player)) { Util.print(Messages.noConsole); return true; } Player player = (Player) s; if (!Util.hasPermission(player, "vanish")) { Util.sendMessage(player, Messages.noPermission); return true; } player.getWorld().createExplosion(player.getLocation(), 0.0F, false); if (!Util.isVanished(player)) { Util.setVanished(player, true); Util.sendMessage(player, Messages.nowVanished); for (Player online : Adminify.mainClass.getServer().getOnlinePlayers()) { online.hidePlayer(player); } return true; } Util.setVanished(player, false); for (Player online : Adminify.mainClass.getServer().getOnlinePlayers()) { online.showPlayer(player); } Util.sendMessage(player, Messages.noVanished); // } return true; }
@Override public void setVanished(boolean set) { vanished = set; if (set) { for (Player p : ess.getServer().getOnlinePlayers()) { if (!Permissions.VANISH_SEE_OTHERS.isAuthorized(ess.getUserMap().getUser(p))) { p.hidePlayer(getPlayer()); } } ess.getVanishedPlayers().add(getName()); if(Permissions.VANISH_EFFECT.isAuthorized(this)) { getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false)); } } else { for (Player p : ess.getServer().getOnlinePlayers()) { p.showPlayer(getPlayer()); } ess.getVanishedPlayers().remove(getName()); if(Permissions.VANISH_EFFECT.isAuthorized(this)) { getPlayer().removePotionEffect(PotionEffectType.INVISIBILITY); } } }
@Override public void set(Player player, EventData data, Boolean value) throws BailException { if (value == null) return; Player otherPlayer = otherPlayerDP.get(data); if (otherPlayer == null) return; if (value.booleanValue() == true) player.showPlayer(otherPlayer); else player.hidePlayer(otherPlayer); }
public void updateName(Player player, String team) { // Update the name disguise(player, team); Player[] players = Bukkit.getOnlinePlayers(); for (Player p : players) { if (p != player) { // Refresh the packet! p.hidePlayer(player); p.showPlayer(player); } } // setName(player, ChatColor.stripColor(n)); }
public static void changeLobby(Player p, int i, boolean teleport) { LobbyList.put(p.getUniqueId(), i); for (Player o : Bukkit.getOnlinePlayers()) { p.showPlayer(o); if (LobbyList.containsKey(o.getUniqueId())) { if (LobbyList.get(o.getUniqueId()) != i) { p.hidePlayer(o); o.hidePlayer(p); } else { o.showPlayer(p); } } else { p.hidePlayer(o); o.hidePlayer(p); } } p.setExp(0); p.setLevel(getLobby(p)); if (teleport) { p.teleport(GameAPI.getSpawnLocation()); p.getWorld().playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 7); } }
public void execute(final Player p, Entity unused, float f) { if (isCooldown(p)) { return; } else { SkillMgr.addCooldown(p, getName(), cooldown); } if (!isLevel(p)) { return; } if (RaceMgr.getRace(p.getName()).hasData("invis")) { return; } for (Player other : Bukkit.getOnlinePlayers()) { other.hidePlayer(p); } Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCraft.plugin, new Runnable() { public void run() { RaceMgr.getRace(p.getName()).setData("invis", null); for (final Player other : Bukkit.getOnlinePlayers()) { Player hide = EntityMgr.getOnlinePlayer(other.getName()); Player look = EntityMgr.getOnlinePlayer(p.getName()); if (hide != null && look != null) { if (look.equals(hide)) { continue; } if (look.getWorld() == hide.getWorld()) { if (HookVanish.canSee(other, p)) { other.showPlayer(p); } } } } } }, lasts); //XXX: Config - Notify when they go invisible and visible //if () { //invis p.sendMessage(MMOCraft.prefix + I18n._("skillinvison", new Object[] {})); SoundEffects.PORTAL_TRAVEL.play(p, p.getLocation(), 0.3f, 2.0f); //} //if () { //vis int tid = Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCraft.plugin, new Runnable() { public void run() { if (p != null) { p.sendMessage(MMOCraft.prefix + I18n._("skillinvisoff", new Object[] {})); SoundEffects.PORTAL_TRIGGER.play(p, p.getLocation(), 25f, 2.5f); } } }, lasts); RaceMgr.getRace(p.getName()).setData("invis", tid); //} //XXX }
public void addSpectator(final Player p) { if (mode != GameMode.INGAME) { msgmgr.sendMessage(PrefixType.WARNING, "You can only spectate running games!", p); return; } p.teleport(SettingsManager.getInstance().getSpawnPoint(gameID, 1).add(0, 10, 0)); HookManager.getInstance().runHook("PLAYER_SPECTATE", "player-" + p.getName()); for (Player pl : Bukkit.getOnlinePlayers()) { pl.hidePlayer(p); } Bukkit.getServer() .getScheduler() .scheduleSyncDelayedTask( GameManager.getInstance().getPlugin(), new Runnable() { @SuppressWarnings("deprecation") public void run() { p.setFlying(false); p.setAllowFlight(false); p.setWalkSpeed(0.2F); p.setFireTicks(0); p.getInventory().clear(); p.getEquipment().setArmorContents(null); p.updateInventory(); showMenu(p); for (PotionEffect effect : p.getActivePotionEffects()) { p.removePotionEffect(effect.getType()); } } }, 1L); spectators.add(p.getName()); msgmgr.sendMessage( PrefixType.INFO, "You are now spectating! Use /sg spectate again to return to the lobby.", p); msgmgr.sendMessage( PrefixType.INFO, "Right click while holding shift to teleport to the next ingame player, left click to go back.", p); nextspec.put(p, 0); }
private void makeInvisible(Player player) { // make player invisible for (Player p : Bukkit.getOnlinePlayers()) { p.hidePlayer(player); } // detarget monsters Creature creature; for (Entity e : player.getNearbyEntities(30, 30, 30)) { if (e instanceof Creature) { creature = (Creature) e; if (creature.getTarget() != null && creature.getTarget().equals(player)) { creature.setTarget(null); } } } }
/** * Flicker the player for anyone who can see him. * * @param player */ public static void refreshPlayer(Player player) { TagAPI.check(); if (player == null) { throw new TagAPIException("Can't submit null player!"); } if (!player.isOnline()) { throw new TagAPIException("Can't submit offline player!"); } final ShowBomb bomb = TagAPI.instance.new ShowBomb(); for (final Player otherGuy : player.getWorld().getPlayers()) { if ((!otherGuy.equals(player)) && otherGuy.canSee(player)) { otherGuy.hidePlayer(player); bomb.queue(TagAPI.instance.new RefreshPair(otherGuy, player)); } } TagAPI.instance.getServer().getScheduler().scheduleSyncDelayedTask(TagAPI.instance, bomb, 2); }
/** * Flicker the player for a player who can see him. * * @param player * @param forWhom */ public static void refreshPlayer(Player player, Player forWhom) { TagAPI.check(); if (player == null) { throw new TagAPIException("Can't submit null player!"); } if (forWhom == null) { throw new TagAPIException("Can't submit null forWhom!"); } if (player.equals(forWhom)) { throw new TagAPIException("Can't submit player on self!"); } final ShowBomb bomb = TagAPI.instance.new ShowBomb(); if (forWhom.canSee(player) && player.getWorld().equals(forWhom.getWorld())) { forWhom.hidePlayer(player); bomb.queue(TagAPI.instance.new RefreshPair(forWhom, player)); } TagAPI.instance.getServer().getScheduler().scheduleSyncDelayedTask(TagAPI.instance, bomb, 2); }
@EventHandler public void onPlayerLogin(PlayerLoginEvent event) // If the player is connected. { Player player = event.getPlayer(); // Show all the players on the server to the connected player. Player[] server_players = Bukkit.getOnlinePlayers(); List<Player> server_players_list = Arrays.asList(server_players); player.showPlayer((Player) server_players_list); // Hide players who use invisibility. List<String> hide_player = Invisible.invisible_player; player.hidePlayer((Player) hide_player); if (Invisible.invisible_player.contains(player.getName())) { // Remove invisibility, if the connected player was invisible. Invisible.invisible_player.remove(player.getName()); ((Player) server_players_list).showPlayer(player); } }
public static void hidePlayer(Player player) { for (Player p : server.getOnlinePlayers()) { p.hidePlayer(player); } }
void enableSpectate(Player spectator, CommandSender sender) { if (user.get(spectator.getName()).spectating) { // Spectate mode wasn't on if (sender instanceof Player && spectator.getName().equals(sender.getName())) { spectator.sendMessage(prefix + "You are already spectating!"); } else { sender.sendMessage( prefix + ChatColor.RED + spectator.getDisplayName() + ChatColor.GOLD + " is already spectating!"); } } else { // teleport them to the global lobby spawnPlayer(spectator); // hide them from everyone for (Player target : getServer().getOnlinePlayers()) { target.hidePlayer(spectator); } // gamemode and inventory spectator.setGameMode(GameMode.ADVENTURE); savePlayerInv(spectator); spectator.setAllowFlight(true); spectator.setFoodLevel(20); // disable interaction user.get(spectator.getName()).spectating = true; PotionEffect heal = new PotionEffect(PotionEffectType.HEAL, Integer.MAX_VALUE, 1000, true); spectator.addPotionEffect(heal); // give them compass if toggle on if (compass) { ItemStack compass = new ItemStack(Material.COMPASS, 1); ItemMeta compassMeta = (ItemMeta) compass.getItemMeta(); compassMeta.setDisplayName(ChatColor.BLUE + "Teleporter"); compass.setItemMeta(compassMeta); spectator.getInventory().addItem(compass); } // give them clock (only for arena mode and if toggle is on) if (clock) { String mode = setup.getConfig().getString("mode"); if (mode.equals("arena")) { ItemStack book = new ItemStack(Material.WATCH, 1); ItemMeta bookMeta = (ItemMeta) book.getItemMeta(); bookMeta.setDisplayName(ChatColor.DARK_RED + "Arena chooser"); book.setItemMeta(bookMeta); spectator.getInventory().addItem(book); } } // set the prefix in the tab list if the toggle is on if (scoreboard) { team.addPlayer(spectator); } // manage messages if spectator was enabled if (sender instanceof Player && spectator.getName().equals(sender.getName())) { if (output) { spectator.sendMessage(prefix + "Spectator mode " + ChatColor.RED + "enabled"); } } else if (sender instanceof Player && !spectator.getName().equals(sender.getName())) { if (output) { spectator.sendMessage( prefix + "Spectator mode " + ChatColor.RED + "enabled" + ChatColor.GOLD + " by " + ChatColor.RED + ((Player) sender).getDisplayName()); } sender.sendMessage( prefix + "Spectator mode " + ChatColor.RED + "enabled" + ChatColor.GOLD + " for " + ChatColor.RED + spectator.getDisplayName()); } else { if (output) { spectator.sendMessage( prefix + "Spectator mode " + ChatColor.RED + "enabled" + ChatColor.GOLD + " by " + ChatColor.DARK_RED + "Console"); } sender.sendMessage( prefix + "Spectator mode " + ChatColor.RED + "enabled" + ChatColor.GOLD + " for " + ChatColor.RED + spectator.getDisplayName()); } } }
@EventHandler public void on(PlayerJoinEvent e) { final Player p = e.getPlayer(); Tablist tab = new Tablist(); tab.setFooter("§3OreBattle v1.0"); tab.setHeader("§a" + Bukkit.getServerName()); tab.send(p); if (Devathlon.Status == GameStatus.Lobby) { /*TagManager tm = new TagManager(p); tm.changeTag(tm.getTagByPermissions()); tm.setTag();*/ e.setJoinMessage( "§7> " + p.getDisplayName() + " §3hat das Spiel betreten. (" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + ")"); if (Bukkit.getOnlinePlayers().size() == 5 && Devathlon.Timer > 10) { Devathlon.Timer = 10; } clearupperson(p); createPlayerStats(p); p.getInventory() .setItem( 0, createItemstack(Material.COMPASS, "§9Teamauswahl §7<Rechtsklick>", 1, (byte) 0)); p.getInventory() .setItem( 8, createItemstack( Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0)); if (Devathlon.sql == true) { p.getInventory() .setItem( 4, createItemstack(Material.NETHER_STAR, "§9Kitauswahl §7<Rechtsklick>", 1, (byte) 0)); } p.getInventory().setHeldItemSlot(0); p.teleport(OreBattle_Command.getLocation("Lobby", true)); p.sendMessage(Devathlon.prefix + "§3Willkommen bei OreBattle v1.0"); } else { e.setJoinMessage(""); p.getInventory().clear(); p.getInventory() .setItem( 0, createItemstack(Material.REDSTONE_BLOCK, "§cTeam Rot §7<Rechtsklick>", 1, (byte) 0)); p.getInventory() .setItem( 1, createItemstack(Material.LAPIS_BLOCK, "§9Team Blau §7<Rechtsklick>", 1, (byte) 0)); p.getInventory() .setItem( 8, createItemstack( Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0)); TagManager tm = new TagManager(p); tm.changeTag("7"); tm.setTag(); p.setPlayerListName("§7[§cX§7] §8| §7" + p.getName()); p.setDisplayName("§7[§cX§7] " + p.getName()); Global.spectator.add(p); for (Player all : Bukkit.getOnlinePlayers()) { all.hidePlayer(p); for (Player spec : Global.spectator) { spec.showPlayer(p); p.showPlayer(spec); } } p.setAllowFlight(true); p.setFlying(true); p.sendMessage(Devathlon.prefix + "§3Du bist jetzt Spectator."); p.teleport(OreBattle_Command.getLocation("Spectator", true)); } }
public boolean onCommand( CommandSender sender, Command command, String commandLabel, String[] args) { Player p = (Player) sender; String aAdmin = sender.getName(); if (commandLabel.equalsIgnoreCase("admin")) { if (p.hasPermission("vAdmin.use")) { if (!(adminMode.contains(aAdmin))) { adminMode.add(aAdmin); p.sendMessage(ChatColor.GREEN + "" + ChatColor.ITALIC + "You are now in Admin mode."); p.getInventory().clear(); p.setGameMode(GameMode.CREATIVE); p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 2)); ItemStack wds = new ItemStack(Material.COMPASS); ItemMeta wdsMeta = wds.getItemMeta(); ItemStack wdw = new ItemStack(Material.BOOK); ItemMeta wdwMeta = wdw.getItemMeta(); ItemStack td = new ItemStack(Material.RED_ROSE); ItemMeta tdMeta = td.getItemMeta(); ItemStack dl = new ItemStack(Material.CLAY_BALL); ItemMeta dlMeta = dl.getItemMeta(); ItemStack al = new ItemStack(Material.DIAMOND_SWORD); ItemMeta alMeta = dl.getItemMeta(); wdsMeta.setDisplayName(ChatColor.RED + "Teleporter"); wds.setItemMeta(wdsMeta); wdwMeta.setDisplayName(ChatColor.GREEN + "Inventory Checker"); wdw.setItemMeta(wdwMeta); tdMeta.setDisplayName(ChatColor.GOLD + "Nearest Player"); td.setItemMeta(tdMeta); dlMeta.setDisplayName(ChatColor.AQUA + "Invisibility"); dl.setItemMeta(dlMeta); alMeta.setDisplayName(ChatColor.YELLOW + "Admin Mode"); al.setItemMeta(alMeta); p.getInventory().setItem(0, wds); p.getInventory().setItem(1, wdw); p.getInventory().setItem(4, al); p.getInventory().setItem(7, td); p.getInventory().setItem(8, dl); for (Player players : Bukkit.getOnlinePlayers()) { if (players.hasPermission("vAdmin.use")) { players.showPlayer(p); } else { players.hidePlayer(p); } } } else { adminMode.remove(aAdmin); p.sendMessage( ChatColor.AQUA + "" + ChatColor.ITALIC + "You are no longer in admin mode."); p.getInventory().clear(); p.removePotionEffect(PotionEffectType.NIGHT_VISION); for (Player players : Bukkit.getOnlinePlayers()) { players.showPlayer(p); } } } else { p.sendMessage(ChatColor.RED + "Nice try."); } } else if (commandLabel.equalsIgnoreCase("vis")) { if (adminMode.contains(p.getName())) { if (!(vis.contains(sender.getName()))) { vis.add(sender.getName()); for (Player players : Bukkit.getOnlinePlayers()) { players.showPlayer(p); } p.sendMessage(ChatColor.BLUE + "You are now visble to everyone."); } else { if (vis.contains(sender.getName())) { vis.remove(sender.getName()); p.sendMessage(ChatColor.BLUE + "You are no longer visble to everyone."); for (Player players : Bukkit.getOnlinePlayers()) { players.hidePlayer(p); } } } } } return true; }
public static void spec(final Player p) { Global.spectator.add(p); for (Player all : Bukkit.getOnlinePlayers()) { all.hidePlayer(p); for (Player spec : Global.spectator) { spec.showPlayer(p); p.showPlayer(spec); } } if (Global.team1.contains(p)) { Global.team1.remove(p); p.sendMessage( Devathlon.prefix + "§3Du konntest nicht respawnen, da das gegnerische Team bereits " + Global.points + " Punkte erreicht hat"); } if (Global.team2.contains(p)) { Global.team2.remove(p); p.sendMessage( Devathlon.prefix + "§3Du konntest nicht respawnen, da das gegnerische Team bereits " + Global.points + " Punkte erreicht hat"); } if (Global.kit1.contains(p)) { Global.kit1.remove(p); } if (Global.kit2.contains(p)) { Global.kit2.remove(p); } if (Global.kit3.contains(p)) { Global.kit3.remove(p); } Bukkit.getScheduler() .runTaskLater( plugin, new Runnable() { @Override public void run() { p.spigot().respawn(); p.teleport(OreBattle_Command.getLocation("Spectator", true)); p.getInventory().clear(); p.getInventory() .setItem( 0, playerjoinevent.createItemstack( Material.REDSTONE_BLOCK, "§cTeam Rot §7<Rechtsklick>", 1, (byte) 0)); p.getInventory() .setItem( 1, playerjoinevent.createItemstack( Material.LAPIS_BLOCK, "§9Team Blau §7<Rechtsklick>", 1, (byte) 0)); p.getInventory() .setItem( 8, playerjoinevent.createItemstack( Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0)); p.setAllowFlight(true); p.setFlying(true); TagManager tm = new TagManager(p); tm.changeTag("7"); tm.setTag(); p.setPlayerListName("§7[§cX§7] §8| §7" + p.getName()); p.setDisplayName("§7" + p.getName()); } }, 20L); }
private Results action(Player p_player) { switch (type) { case ALWAYSFLY: if (p_player.hasMetadata("ZeltCmds_Player_AlwaysFly")) { p_player.removeMetadata("ZeltCmds_Player_AlwaysFly", this.getPlugin()); p_player.setAllowFlight(p_player.getGameMode().equals(GameMode.CREATIVE)); return Results.OFF; } else { p_player.setMetadata( "ZeltCmds_Player_AlwaysFly", new FixedMetadataValue(this.getPlugin(), "true")); p_player.setAllowFlight(true); p_player.setFlying(true); return Results.ON; } case BUILD: if (p_player.hasMetadata("ZeltCmds_Player_Build")) { p_player.removeMetadata("ZeltCmds_Player_Build", this.getPlugin()); return Results.OFF; } else { p_player.setMetadata( "ZeltCmds_Player_Build", new FixedMetadataValue(this.getPlugin(), "true")); return Results.ON; } case FLY: if (p_player.getAllowFlight()) { p_player.setAllowFlight(false); return Results.OFF; } else { p_player.setAllowFlight(true); return Results.ON; } case FREEZE: if (p_player.hasMetadata("ZeltCmds_Player_Freeze")) { p_player.removeMetadata("ZeltCmds_Player_Freeze", this.getPlugin()); return Results.OFF; } else { p_player.setMetadata( "ZeltCmds_Player_Freeze", new FixedMetadataValue(this.getPlugin(), "true")); return Results.ON; } case HIDE: if (p_player.hasMetadata("ZeltCmds_Player_Hide")) { p_player.removeMetadata("ZeltCmds_Player_Hide", this.getPlugin()); for (Player player : p_player.getServer().getOnlinePlayers()) { if (!player.equals(p_player)) { player.hidePlayer(p_player); } } return Results.OFF; } else { p_player.setMetadata( "ZeltCmds_Player_Hide", new FixedMetadataValue(this.getPlugin(), "true")); for (Player player : p_player.getServer().getOnlinePlayers()) { if (!player.equals(p_player)) { player.showPlayer(p_player); } } return Results.ON; } case MUTE: if (p_player.hasMetadata("ZeltCmds_Player_Mute")) { p_player.removeMetadata("ZeltCmds_Player_Mute", this.getPlugin()); return Results.OFF; } else { p_player.setMetadata( "ZeltCmds_Player_Mute", new FixedMetadataValue(this.getPlugin(), "true")); return Results.ON; } } return Results.ERROR; }
public static void hideAllFrom(Player player) { for (Player p : server.getOnlinePlayers()) { player.hidePlayer(p); } }
public static void spectateOn(final Player player, final Player target) { if (getPlugin().CommandExecutor.isSpectating.get(player.getName()) != null) { if (getPlugin().CommandExecutor.isSpectating.get(player.getName())) { spectateOff(player); } } player.sendMessage("§7You are now spectating " + target.getName() + "."); getPlugin().CommandExecutor.origLocation.put(player.getName(), player.getLocation()); getPlugin().CommandExecutor.isSpectating.put(player.getName(), true); getPlugin().CommandExecutor.isBeingSpectated.put(target.getName(), true); if (getPlugin().CommandExecutor.spectator.get(target.getName()) == null) { getPlugin().CommandExecutor.spectator.put(target.getName(), player.getName()); } else { getPlugin() .CommandExecutor .spectator .put( target.getName(), getPlugin().CommandExecutor.spectator.get(target.getName()) + "," + player.getName()); } getPlugin().CommandExecutor.target.put(player.getName(), target.getName()); player .getPlayer() .teleport( getPlugin() .getServer() .getPlayer(getPlugin().CommandExecutor.target.get(player.getName()))); getPlugin().CommandExecutor.senderHunger.put(player.getName(), player.getFoodLevel()); getPlugin().CommandExecutor.senderHealth.put(player.getName(), player.getHealth()); if (getPlugin().CommandExecutor.isInv.get(player.getName()) == null || getPlugin().CommandExecutor.isInv.get(player.getName())) { getPlugin() .CommandExecutor .senderInv .put(player.getName(), player.getInventory().getContents()); getPlugin() .CommandExecutor .senderArm .put(player.getName(), player.getInventory().getArmorContents()); player.getInventory().clear(); player.getInventory().setContents(target.getInventory().getContents()); player.getInventory().setArmorContents(target.getInventory().getArmorContents()); } ArrayList<Player> spectateablePlayers = getSpectateablePlayers(); spectateablePlayers.remove(player); int tempPlayerNumber = 0; for (Player p : spectateablePlayers) { if (getPlugin().CommandExecutor.target.get(player.getName()).equals(p.getName())) { break; } tempPlayerNumber++; } getPlugin().CommandExecutor.playerNumber.put(player.getName(), tempPlayerNumber); for (Player player1 : getPlugin().getServer().getOnlinePlayers()) { player1.hidePlayer(player); } target.hidePlayer(player); player.hidePlayer(target); }
public void task() { Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName); GamemodeCheck gamemodeCheck = new GamemodeCheck(); plugin .getServer() .getScheduler() .runTaskTimerAsynchronously( plugin, () -> plugin .getServer() .getScheduler() .runTask( plugin, () -> { if (!rocketPower.isEmpty()) { for (Map.Entry<UUID, Integer> entry : rocketPower.entrySet()) { Player player = Bukkit.getPlayer(entry.getKey()); if (gamemodeCheck.check( player, GameMode.SURVIVAL, GameMode.ADVENTURE)) if (player.getWorld().getName().equals("world")) if (rocketVariant.containsKey(player.getUniqueId())) if (player.isFlying()) { Variant bootVariant = rocketVariant.get(player.getUniqueId()); PotionEffect[] effects = bootVariant.getPotionEffects(); for (PotionEffect effect : player.getActivePotionEffects()) player.removePotionEffect(effect.getType()); if (effects != null) { for (PotionEffect effect : effects) { rocketEffects.add(player.getUniqueId()); player.addPotionEffect(effect); } } if (bootVariant.equals(STEALTH)) for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.hidePlayer(player); } else if (rocketEffects.contains(player.getUniqueId())) { for (PotionEffect effect : player.getActivePotionEffects()) player.removePotionEffect(effect.getType()); for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.showPlayer(player); rocketEffects.remove(player.getUniqueId()); } } } }), 0, 0); }