summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/game/Game.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/Game.java301
1 files changed, 125 insertions, 176 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
index 5069bac..83b304d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
@@ -19,15 +19,15 @@
package net.tylermurphy.hideAndSeek.game;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import com.cryptomorin.xseries.messages.ActionBar;
import com.cryptomorin.xseries.messages.Titles;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import net.md_5.bungee.api.ChatColor;
+import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.database.Database;
+import net.tylermurphy.hideAndSeek.game.listener.RespawnHandler;
import net.tylermurphy.hideAndSeek.util.*;
import net.tylermurphy.hideAndSeek.world.WorldLoader;
import org.bukkit.*;
@@ -37,8 +37,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
-
-import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.potion.PotionEffect;
@@ -48,7 +46,8 @@ import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static net.tylermurphy.hideAndSeek.game.Game.broadcastMessage;
public class Game {
@@ -69,36 +68,36 @@ public class Game {
worldLoader = new WorldLoader(spawnWorld);
}
- public static void start(){
+ public static void start() {
Optional<Player> rand = Board.getPlayers().stream().skip(new Random().nextInt(Board.size())).findFirst();
- if(!rand.isPresent()){
+ if (!rand.isPresent()) {
Main.plugin.getLogger().warning("Failed to select random seeker.");
return;
}
String seekerName = rand.get().getName();
Player temp = Bukkit.getPlayer(seekerName);
- if(temp == null){
+ if (temp == null) {
Main.plugin.getLogger().warning("Failed to select random seeker.");
return;
}
Player seeker = Board.getPlayer(temp.getUniqueId());
- if(seeker == null){
+ if (seeker == null) {
Main.plugin.getLogger().warning("Failed to select random seeker.");
return;
}
start(seeker);
}
- public static void start(Player seeker){
- if(status == Status.STARTING || status == Status.PLAYING) return;
- if(mapSaveEnabled && worldLoader.getWorld() != null) {
+ public static void start(Player seeker) {
+ if (status == Status.STARTING || status == Status.PLAYING) return;
+ if (mapSaveEnabled && worldLoader.getWorld() != null) {
worldLoader.rollback();
- } else if(mapSaveEnabled) {
+ } else if (mapSaveEnabled) {
worldLoader.loadMap();
}
Board.reload();
for(Player temp : Board.getPlayers()) {
- if(temp.getName().equals(seeker.getName()))
+ if (temp.getName().equals(seeker.getName()))
continue;
Board.addHider(temp);
}
@@ -108,7 +107,7 @@ public class Game {
player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE);
player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
}
@@ -122,20 +121,20 @@ public class Game {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("HIDER_TEAM_NAME"), ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
}
- if(tauntEnabled)
+ if (tauntEnabled)
taunt = new Taunt();
if (glowEnabled)
glow = new Glow();
worldBorder = new Border();
worldBorder.resetWorldborder(getGameWorld());
- if(gameLength > 0)
+ if (gameLength > 0)
timeLeft = gameLength;
for(Player player : Board.getPlayers())
Board.createGameBoard(player);
Board.reloadGameBoards();
status = Status.STARTING;
int temp = gameId;
- if(countdownDisplay != CountdownDisplay.TITLE) {
+ if (countdownDisplay != CountdownDisplay.TITLE) {
sendHideCountdownMessage(messagePrefix + message("START_COUNTDOWN").addAmount(30), gameId, 0);
}
sendHideCountdownMessage(messagePrefix + message("START_COUNTDOWN").addAmount(20), gameId, 20 * 10);
@@ -145,33 +144,33 @@ public class Game {
sendHideCountdownMessage(messagePrefix + message("START_COUNTDOWN").addAmount(2), gameId, 20 * 28);
sendHideCountdownMessage(messagePrefix + message("START_COUNTDOWN").addAmount(1), gameId, 20 * 29);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, () -> {
- if(temp != gameId) return;
+ if (temp != gameId) return;
sendHideCountdownMessage(messagePrefix + message("START"), gameId, 0);
for(Player player : Board.getPlayers()) resetPlayer(player);
status = Status.PLAYING;
}, 20 * 30);
}
- public static void stop(WinType type){
- if(status == Status.STANDBY || status == Status.ENDING) return;
+ public static void stop(WinType type) {
+ if (status == Status.STANDBY || status == Status.ENDING) return;
status = Status.ENDING;
for(Player player : Board.getPlayers()) {
player.getInventory().clear();
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
- if(Version.atLeast("1.9")){
+ if (Version.atLeast("1.9")) {
for(Player temp : Board.getPlayers()) {
Packet.setGlow(player, temp, false);
}
}
}
List<UUID> players = Board.getPlayers().stream().map(Entity::getUniqueId).collect(Collectors.toList());
- if(type == WinType.HIDER_WIN){
+ if (type == WinType.HIDER_WIN) {
List<UUID> winners = Board.getHiders().stream().map(Entity::getUniqueId).collect(Collectors.toList());
Database.playerInfo.addWins(players, winners, Board.getHiderKills(), Board.getHiderDeaths(), Board.getSeekerKills(), Board.getSeekerDeaths(), type);
- } else if(type == WinType.SEEKER_WIN){
+ } else if (type == WinType.SEEKER_WIN) {
List<UUID> winners = new ArrayList<>();
winners.add(Board.getFirstSeeker().getUniqueId());
Database.playerInfo.addWins(players, winners, Board.getHiderKills(), Board.getHiderDeaths(), Board.getSeekerKills(), Board.getSeekerDeaths(), type);
@@ -179,8 +178,8 @@ public class Game {
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, Game::end, 5*20);
}
- public static void end(){
- if(status == Status.STANDBY) return;
+ public static void end() {
+ if (status == Status.STANDBY) return;
tick = 0;
countdownTime = -1;
status = Status.STANDBY;
@@ -188,65 +187,58 @@ public class Game {
timeLeft = 0;
worldBorder.resetWorldborder(getGameWorld());
for(Player player : Board.getPlayers()) {
- for(Player player2 : Board.getPlayers()){
+ for(Player player2 : Board.getPlayers()) {
player.showPlayer(player2);
}
player.setAllowFlight(false);
player.setFlying(false);
- if(Version.atLeast("1.9")){
+ if (Version.atLeast("1.9")) {
for(Player temp : Board.getPlayers()) {
Packet.setGlow(player, temp, false);
}
}
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
- if(leaveOnEnd){
+ if (leaveOnEnd) {
Board.removeBoard(player);
Board.remove(player);
player.getInventory().clear();
- if(bungeeLeave) {
- ByteArrayDataOutput out = ByteStreams.newDataOutput();
- out.writeUTF("Connect");
- out.writeUTF(leaveServer);
- player.sendPluginMessage(Main.plugin, "BungeeCord", out.toByteArray());
- } else {
- player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
- }
+ handleBungeeLeave(player);
} else {
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
Board.createLobbyBoard(player);
player.setGameMode(GameMode.ADVENTURE);
Board.addHider(player);
player.getInventory().clear();
- if(lobbyStartItem != null && (!lobbyItemStartAdmin || player.isOp()))
+ if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.isOp()))
player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
- if(lobbyLeaveItem != null)
+ if (lobbyLeaveItem != null)
player.getInventory().setItem(lobbyItemLeavePosition, lobbyLeaveItem);
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
}
}
- EventListener.temp_loc.clear();
- if(mapSaveEnabled) worldLoader.unloadMap();
+ RespawnHandler.temp_loc.clear();
+ if (mapSaveEnabled) worldLoader.unloadMap();
Board.reloadLobbyBoards();
}
- public static void join(Player player){
- if(Game.status == Status.STANDBY || Game.status == Status.ENDING) {
+ public static void join(Player player) {
+ if (Game.status == Status.STANDBY || Game.status == Status.ENDING) {
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
player.getInventory().clear();
- if(lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start")))
+ if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start")))
player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
- if(lobbyLeaveItem != null)
+ if (lobbyLeaveItem != null)
player.getInventory().setItem(lobbyItemLeavePosition, lobbyLeaveItem);
Board.addHider(player);
- if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
+ if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
else Game.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
player.setGameMode(GameMode.ADVENTURE);
@@ -256,7 +248,7 @@ public class Game {
Board.addSpectator(player);
player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
player.setGameMode(GameMode.ADVENTURE);
- for(Player player2 : Board.getPlayers()){
+ for(Player player2 : Board.getPlayers()) {
player2.hidePlayer(player);
}
Board.createGameBoard(player);
@@ -268,7 +260,7 @@ public class Game {
}
player.setFoodLevel(20);
- if(Version.atLeast("1.9")) {
+ if (Version.atLeast("1.9")) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) player.setHealth(attribute.getValue());
} else {
@@ -276,32 +268,36 @@ public class Game {
}
}
- public static void leave(Player player){
+ public static void leave(Player player) {
player.setFlying(false);
player.setAllowFlight(false);
player.setFallDistance(0.0F);
- for(Player player2 : Board.getPlayers()){
+ for(Player player2 : Board.getPlayers()) {
player2.showPlayer(player);
player.showPlayer(player2);
}
- if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
+ if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
else Game.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
- if(Board.isHider(player) && status != Status.ENDING && status != Status.STANDBY){
+ if (Board.isHider(player) && status != Status.ENDING && status != Status.STANDBY) {
hiderLeave = true;
}
Board.removeBoard(player);
Board.remove(player);
player.getInventory().clear();
- if(Game.status == Status.STANDBY) {
+ if (Game.status == Status.STANDBY) {
Board.reloadLobbyBoards();
} else {
Board.reloadGameBoards();
Board.reloadBoardTeams();
}
- for(PotionEffect effect : player.getActivePotionEffects()){
+ for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
- if(bungeeLeave) {
+ handleBungeeLeave(player);
+ }
+
+ private static void handleBungeeLeave(Player player) {
+ if (bungeeLeave) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(leaveServer);
@@ -312,25 +308,25 @@ public class Game {
}
public static void onTick() {
- if(isNotSetup()) return;
- if(status == Status.STANDBY) whileWaiting();
- else if(status == Status.STARTING) whileStarting();
- else if(status == Status.PLAYING) whilePlaying();
+ if (isNotSetup()) return;
+ if (status == Status.STANDBY) whileWaiting();
+ else if (status == Status.STARTING) whileStarting();
+ else if (status == Status.PLAYING) whilePlaying();
tick++;
}
private static void whileWaiting() {
- if(!lobbyCountdownEnabled) return;
- if(lobbyMin <= Board.size()){
- if(countdownTime == -1)
+ if (!lobbyCountdownEnabled) return;
+ if (lobbyMin <= Board.size()) {
+ if (countdownTime == -1)
countdownTime = countdown;
- if(Board.size() >= changeCountdown)
+ if (Board.size() >= changeCountdown)
countdownTime = Math.min(countdownTime, 10);
- if(tick % 20 == 0) {
+ if (tick % 20 == 0) {
countdownTime--;
Board.reloadLobbyBoards();
}
- if(countdownTime == 0){
+ if (countdownTime == 0) {
start();
}
} else {
@@ -338,8 +334,8 @@ public class Game {
}
}
- private static void whileStarting(){
- for(Player spectator : Board.getSpectators()){
+ private static void whileStarting() {
+ for(Player spectator : Board.getSpectators()) {
spectator.setFlying(spectator.getAllowFlight());
}
checkWinConditions();
@@ -351,46 +347,46 @@ public class Game {
for(Player seeker : Board.getSeekers()) {
try {
temp = (int) hider.getLocation().distance(seeker.getLocation());
- } catch (Exception e){
+ } catch (Exception e) {
//Players in different worlds, NOT OK!!!
}
- if(distance > temp) {
+ if (distance > temp) {
distance = temp;
}
}
- if(seekerPing) switch(tick%10) {
+ if (seekerPing) switch(tick%10) {
case 0:
- if(distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingLeadingVolume, seekerPingPitch);
- if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingLeadingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 3:
- if(distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingVolume, seekerPingPitch);
- if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 6:
- if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 9:
- if(distance < seekerPingLevel2) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if (distance < seekerPingLevel2) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
}
}
- for(Player spectator : Board.getSpectators()){
+ for(Player spectator : Board.getSpectators()) {
spectator.setFlying(spectator.getAllowFlight());
}
- if(tick%20 == 0) {
- if(gameLength > 0) {
+ if (tick%20 == 0) {
+ if (gameLength > 0) {
Board.reloadGameBoards();
timeLeft--;
}
- if(worldborderEnabled) worldBorder.update();
- if(tauntEnabled) taunt.update();
+ if (worldborderEnabled) worldBorder.update();
+ if (tauntEnabled) taunt.update();
if (glowEnabled) glow.update();
}
checkWinConditions();
}
- public static void resetWorldborder(String worldName){
+ public static void resetWorldBorder(String worldName) {
worldBorder = new Border();
worldBorder.resetWorldborder(worldName);
}
@@ -402,18 +398,18 @@ public class Game {
}
public static boolean isNotSetup() {
- if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true;
- if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true;
- if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true;
- if(mapSaveEnabled) {
- File destenation = new File(Main.root + File.separator + getGameWorld());
- if (!destenation.exists()) return true;
+ if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true;
+ if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true;
+ if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true;
+ if (mapSaveEnabled) {
+ File destination = new File(Main.root + File.separator + getGameWorld());
+ if (!destination.exists()) return true;
}
return saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0;
}
- public static String getGameWorld(){
- if(mapSaveEnabled) return "hideandseek_"+spawnWorld;
+ public static String getGameWorld() {
+ if (mapSaveEnabled) return "hideandseek_"+spawnWorld;
else return spawnWorld;
}
@@ -423,35 +419,35 @@ public class Game {
player.removePotionEffect(effect.getType());
}
if (Board.isSeeker(player)) {
- if(pvpEnabled)
+ if (pvpEnabled)
for(ItemStack item : Items.SEEKER_ITEMS)
player.getInventory().addItem(item);
for(PotionEffect effect : Items.SEEKER_EFFECTS)
player.addPotionEffect(effect);
} else if (Board.isHider(player)) {
- if(pvpEnabled)
+ if (pvpEnabled)
for(ItemStack item : Items.HIDER_ITEMS)
player.getInventory().addItem(item);
for(PotionEffect effect : Items.HIDER_EFFECTS)
player.addPotionEffect(effect);
- if(glowEnabled) {
+ if (glowEnabled) {
player.getInventory().addItem(glowPowerupItem);
}
}
}
- public static void removeItems(Player player){
+ public static void removeItems(Player player) {
for(ItemStack si : Items.SEEKER_ITEMS)
for(ItemStack i : player.getInventory().getContents())
- if(si.isSimilar(i)) player.getInventory().remove(i);
+ if (si.isSimilar(i)) player.getInventory().remove(i);
for(ItemStack hi : Items.HIDER_ITEMS)
for(ItemStack i : player.getInventory().getContents())
- if(hi.isSimilar(i)) player.getInventory().remove(i);
+ if (hi.isSimilar(i)) player.getInventory().remove(i);
}
- private static void checkWinConditions(){
- if(Board.sizeHider() < 1) {
- if(hiderLeave){
+ private static void checkWinConditions() {
+ if (Board.sizeHider() < 1) {
+ if (hiderLeave) {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
stop(WinType.NONE);
@@ -460,12 +456,12 @@ public class Game {
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
stop(WinType.SEEKER_WIN);
}
- } else if(Board.sizeSeeker() < 1) {
- if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
+ } else if (Board.sizeSeeker() < 1) {
+ if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
else broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
stop(WinType.NONE);
- } else if(timeLeft < 1) {
- if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
+ } else if (timeLeft < 1) {
+ if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
stop(WinType.HIDER_WIN);
}
@@ -474,14 +470,14 @@ public class Game {
private static void sendHideCountdownMessage(String message, int gameId, int delay) {
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.plugin, () -> {
- if(gameId == Game.gameId){
- for(Player player : Board.getPlayers()){
- if(countdownDisplay == CountdownDisplay.CHAT){
+ if (gameId == Game.gameId) {
+ for(Player player : Board.getPlayers()) {
+ if (countdownDisplay == CountdownDisplay.CHAT) {
player.sendMessage(message);
- } else if(countdownDisplay == CountdownDisplay.ACTIONBAR){
+ } else if (countdownDisplay == CountdownDisplay.ACTIONBAR) {
ActionBar.clearActionBar(player);
ActionBar.sendActionBar(player,message);
- } else if(countdownDisplay == CountdownDisplay.TITLE){
+ } else if (countdownDisplay == CountdownDisplay.TITLE) {
Titles.clearTitle(player);
Titles.sendTitle(player, 10, 40, 10, " ", message);
}
@@ -492,53 +488,6 @@ public class Game {
}
-class Glow {
-
- private int glowTime;
- private boolean running;
-
- public Glow() {
- this.glowTime = 0;
- }
-
- public void onProjectile() {
- if(glowStackable) glowTime += glowLength;
- else glowTime = glowLength;
- running = true;
- }
-
- private void sendPackets(){
- for(Player hider : Board.getHiders())
- for(Player seeker : Board.getSeekers())
- Packet.setGlow(hider, seeker, true);
- }
-
- protected void update() {
- if(running) {
- sendPackets();
- glowTime--;
- glowTime = Math.max(glowTime, 0);
- if (glowTime == 0) {
- stopGlow();
- }
- }
- }
-
- private void stopGlow() {
- running = false;
- for(Player hider : Board.getHiders()) {
- for (Player seeker : Board.getSeekers()) {
- Packet.setGlow(hider, seeker, false);
- }
- }
- }
-
- public boolean isRunning() {
- return running;
- }
-
-}
-
class Taunt {
private UUID tauntPlayer;
@@ -550,9 +499,9 @@ class Taunt {
}
protected void update() {
- if(delay == 0) {
- if(running) launchTaunt();
- else if(tauntLast || Board.sizeHider() > 1) executeTaunt();
+ if (delay == 0) {
+ if (running) launchTaunt();
+ else if (tauntLast || Board.sizeHider() > 1) executeTaunt();
} else {
delay--;
delay = Math.max(delay, 0);
@@ -561,7 +510,7 @@ class Taunt {
private void executeTaunt() {
Optional<Player> rand = Board.getHiders().stream().skip(new Random().nextInt(Board.size())).findFirst();
- if(!rand.isPresent()){
+ if (!rand.isPresent()) {
Main.plugin.getLogger().warning("Failed to select random seeker.");
return;
}
@@ -573,10 +522,10 @@ class Taunt {
delay = 30;
}
- private void launchTaunt(){
+ private void launchTaunt() {
Player taunted = Board.getPlayer(tauntPlayer);
- if(taunted != null) {
- if(!Board.isHider(taunted)){
+ if (taunted != null) {
+ if (!Board.isHider(taunted)) {
Main.plugin.getLogger().info("Taunted played died and is now seeker. Skipping taunt.");
tauntPlayer = null;
running = false;
@@ -584,7 +533,7 @@ class Taunt {
return;
}
World world = taunted.getLocation().getWorld();
- if(world == null){
+ if (world == null) {
Main.plugin.getLogger().severe("Game world is null while trying to launch taunt.");
tauntPlayer = null;
running = false;
@@ -612,7 +561,7 @@ class Taunt {
delay = tauntDelay;
}
- public int getDelay(){
+ public int getDelay() {
return delay;
}
@@ -631,11 +580,11 @@ class Border {
delay = 60 * worldborderDelay;
}
- void update(){
- if(delay == 30 && !running){
+ void update() {
+ if (delay == 30 && !running) {
broadcastMessage(worldborderPrefix + message("WORLDBORDER_WARN"));
- } else if(delay == 0){
- if(running){
+ } else if (delay == 0) {
+ if (running) {
delay = 60 * worldborderDelay;
running = false;
}
@@ -645,9 +594,9 @@ class Border {
}
private void decreaceWorldborder() {
- if(currentWorldborderSize == 100) return;
+ if (currentWorldborderSize == 100) return;
int change = worldborderChange;
- if(currentWorldborderSize-worldborderChange < 100){
+ if (currentWorldborderSize-worldborderChange < 100) {
change = currentWorldborderSize-100;
}
running = true;
@@ -664,7 +613,7 @@ class Border {
World world = Bukkit.getWorld(worldName);
assert world != null;
org.bukkit.WorldBorder border = world.getWorldBorder();
- if(worldborderEnabled) {
+ if (worldborderEnabled) {
border.setSize(worldborderSize);
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
currentWorldborderSize = worldborderSize;
@@ -674,7 +623,7 @@ class Border {
}
}
- public int getDelay(){
+ public int getDelay() {
return delay;
}