private List<Spawn> getSpawnLocations(Player player) { if (Arcade.getMatches().getStatus() == ArcadeMatchStatus.RUNNING) { return player.getTeam().getSpawns(); } else { return Arcade.getTeams().getObservers().getSpawns(); } }
@EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent e) { if (e.getEntity() instanceof org.bukkit.entity.Player) { Player entity = Arcade.getServer().getPlayer(e.getEntity().getUniqueId()); if (!entity.getTeam().isFrendlyFire()) { return; } Player damager = null; Projectile projectile = null; if (e.getDamager() instanceof org.bukkit.entity.Player) { // Player vs player direct damager = Arcade.getServer().getPlayer(e.getDamager().getUniqueId()); } else if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof org.bukkit.entity.Player) { // Arrows, snowballs, etc... projectile = (Projectile) e.getDamager(); damager = Arcade.getServer() .getPlayer(((org.bukkit.entity.Player) projectile.getShooter()).getUniqueId()); } if (damager != null && entity.getTeam().equals(damager.getTeam())) { e.setCancelled(true); } if (projectile != null) { projectile.setBounce(true); } } }
@EventHandler public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent e) { e.setCancelled(true); String message = e.getMessage(); Player player = Arcade.getServer().getPlayer(e.getPlayer().getUniqueId()); ArcadeMatchStatus matchStatus = Arcade.getMatches().getStatus(); if (matchStatus != ArcadeMatchStatus.RUNNING || Arcade.getTeams().getTeams().size() == 1) { Arcade.getTeams().getObservers().getChat().sendMessage(player, message); } else { player.getTeam().getChat().sendMessage(player, message); } }
@EventHandler public void onAsyncPlayerPreLoginEvent(AsyncPlayerPreLoginEvent e) { if (Arcade.getMatches().getStatus() == ArcadeMatchStatus.RESTARTING) { e.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST); e.setKickMessage(Color.RED + "Serwer jest teraz restartowany..."); } if (this.server.isFull()) { boolean allowed = false; // TODO Mongo query to check if the player is allowed to join this server if (!allowed) { e.disallow( AsyncPlayerPreLoginEvent.Result.KICK_FULL, Color.RED + "Ten serwer jest obecnie pelny. Spróbuj " + "polaczyc sie ponownie pózniej, lub wybierz inny " + "serwer. Tylko ranga " + Color.GOLD + Color.BOLD + "VIP" + Color.RESET + Color.RED + " moze dolaczac " + "na pelne serwery."); } } }
@EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { final Player player = Arcade.getServer().getPlayer(e.getPlayer().getUniqueId()); List<Spawn> spawns = this.getSpawnLocations(player); Spawn spawn = spawns.get(this.random.nextInt(spawns.size())); PlayerRespawnMatchEvent event = new PlayerRespawnMatchEvent(player, spawn); Event.callEvent(event); e.setRespawnLocation(BukkitLocation.valueOf(event.getSpawn())); if (!event.isCancel()) { Bukkit.getScheduler() .runTaskLater( ArcadeBukkitPlugin.getPlugin(), new Runnable() { @Override public void run() { if (player == null) { return; } else if (player.isObserver()) { Arcade.getPlayerManagement().setAsObserver(player, true, true, true); } else { Arcade.getPlayerManagement() .setAsPlayer(player, KitType.RESPAWN, false, false, false); } } }, 1L); } }
@Override public void updateCurrentMap() { // check if currently running... this.current = this.getNextMap(); Rotation rotation = MiniGameServer.ONLINE.getRotation(); boolean nextMap = false; for (int i = 0; i < rotation.getMaps().size(); i++) { Map map = (Map) rotation.getMaps().toArray()[i]; if (nextMap) { this.setNextMap(map); return; } else if (map.equals(this.current)) { // TODO uuid nextMap = true; } } if (nextMap) { this.setNextMap(null); } else if (this.current.equals(Arcade.getMaps().getCurrentMap())) { this.setNextMap( (Map) rotation.getMaps().toArray()[this.random.nextInt(rotation.getMaps().size())]); } else if (this.getNextMap().getName().equals(this.current.getName())) { this.setNextMap(null); Log.log( Level.SEVERE, "Aby plugin Arcade dzialal prawidlowo wymagane sa minimum 2 rotacyjne mapy!"); } }
@Override public void setWorlds(WorldManager worlds) { Validate.notNull(worlds, "worlds can not be null"); this.worlds = worlds; try { Rotation rotation = MiniGameServer.ONLINE.getRotation(); if (this.getNextMap() != null) { this.getWorlds().load(this.getNextMap()); } else if (rotation.getMaps().isEmpty()) { Log.log( Level.SEVERE, "Brak map w rotacji serwera " + MiniGameServer.ONLINE.getShoot().getID()); } else { for (Map map : rotation.getMaps()) { if (!(map instanceof NotLoadedMap)) { this.setNextMap(map); Arcade.getServer().getScheduler().runCycle(0); return; } } } } catch (IOException ex) { new CrashHandler("cycling", ex).crash(); } }
public Rate(Player player, int rate) { super( UUID.randomUUID(), Arcade.getMaps().getCurrentMap(), player.getUUID(), rate, Servers.getOnline().getID(), System.currentTimeMillis()); this.player = player; }
@EventHandler public void onPlayerDeath(PlayerDeathEvent e) { if (e.getDeathMessage() == null) { return; } else if (e.getDeathMessage().endsWith(" died")) { e.setDeathMessage(null); } if (Arcade.getMatches().getStatus() != ArcadeMatchStatus.RUNNING) { e.getDrops().clear(); } }
public Player getPlayer() { return Arcade.getServer().getPlayer(this.getPlayersID()); }
public void updateObjectives() { Arcade.getServer().checkEndMatch(); }