idk some "cool" stuff
This commit is contained in:
@@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Criteria;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
@@ -43,19 +44,21 @@ public class GamesManager {
|
||||
} else return 2;
|
||||
}
|
||||
|
||||
BlockAndSeekMap map = ConfigManager.getMap(name);
|
||||
BlockAndSeekGame game = new BlockAndSeekGame(name, map.maxPlayers());
|
||||
List<Integer> spawnCords = map.spawn();
|
||||
List<Integer> lobbyCords = map.lobby();
|
||||
BlockAndSeekMap map = MapsManager.getMap(name);
|
||||
System.out.println(map);
|
||||
BlockAndSeekGame game = new BlockAndSeekGame(name, map.getMaxPlayers(), map.getLobby());
|
||||
List<Integer> spawnCords = map.getSpawn();
|
||||
List<Integer> lobbyCords = map.getLobby();
|
||||
games.put(name, game);
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
int duration = map.duration();
|
||||
int duration = map.getDuration() + 10;
|
||||
final int seekerSpawn = duration - 15;
|
||||
int gameEnd = duration - 10;
|
||||
int waitTime = 30;
|
||||
final Location spawn = new Location(Bukkit.getWorld(name), spawnCords.getFirst(), spawnCords.get(1), spawnCords.get(2));
|
||||
final Location lobby = new Location(Bukkit.getWorld(name), lobbyCords.getFirst(), lobbyCords.get(1), lobbyCords.get(2));
|
||||
|
||||
Player seeker;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -67,15 +70,18 @@ public class GamesManager {
|
||||
player.sendActionBar(Component.text("Игроков " + playerCount + "/12")); //TODO!
|
||||
}
|
||||
|
||||
if (playerCount >= map.minPlayers()) {
|
||||
if (playerCount >= map.getMinPlayers()) {
|
||||
|
||||
if (waitTime == 0 || playerCount == map.maxPlayers()) {
|
||||
if (waitTime == 0 || playerCount == map.getMaxPlayers()) {
|
||||
game.start();
|
||||
Player seeker = game.selectRandomSeeker();
|
||||
seeker.teleport(spawn);
|
||||
seeker = game.selectRandomSeeker();
|
||||
|
||||
for (Player player : game.getHiders()) {
|
||||
player.teleport(spawn);
|
||||
RouletteCreator.createRoulette(player, null, true, map.blocks());
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
inventory.clear();
|
||||
inventory.addItem(ItemManager.getFreezeItem());
|
||||
RouletteCreator.createRoulette(player, null, true, map.getBlocks());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -91,25 +97,31 @@ public class GamesManager {
|
||||
|
||||
} else {
|
||||
|
||||
if (seekerSpawn == gameEnd) {
|
||||
seeker.teleport(spawn);
|
||||
PlayerInventory seekerInventory = seeker.getInventory();
|
||||
seekerInventory.setArmorContents(ItemManager.getSeekerArmor());
|
||||
}
|
||||
|
||||
if (game.hidersCount() == 0) {
|
||||
|
||||
for (Player player : game.getPlayers()) {
|
||||
player.showTitle(Title.title(Localization.getComponent("seekers-won"), Component.text("")));
|
||||
}
|
||||
|
||||
game.end();
|
||||
game.preEnd();
|
||||
games.remove(name);
|
||||
this.cancel();
|
||||
|
||||
}
|
||||
|
||||
for (Player player : game.getPlayers()) {
|
||||
player.sendActionBar(Localization.getComponent("game-time-left", "{time}", String.valueOf(duration)));
|
||||
player.sendActionBar(Localization.getComponent("game-time-left", "{time}", String.valueOf(gameEnd)));
|
||||
}
|
||||
|
||||
if (duration == 0) {
|
||||
if (gameEnd == 0) {
|
||||
if (game.hidersCount() == 1) {
|
||||
for (Player player : game.getPlayers()) {
|
||||
player.showTitle(Title.title(Localization.getComponent("hiders-solo-win", "{player}", player.getName()), Component.text("")));
|
||||
player.showTitle(Title.title(Localization.getComponent("hiders-solo-win", "{player}", game.getLastHider().getName()), Component.text("")));
|
||||
}
|
||||
} else {
|
||||
for (Player player : game.getPlayers()) {
|
||||
@@ -117,11 +129,14 @@ public class GamesManager {
|
||||
}
|
||||
}
|
||||
|
||||
game.end();
|
||||
game.preEnd();
|
||||
games.remove(name);
|
||||
this.cancel();
|
||||
} else duration--;
|
||||
|
||||
} else gameEnd--;
|
||||
|
||||
if (duration == 0) {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -145,7 +160,7 @@ public class GamesManager {
|
||||
scoreboard.resetScores(o);
|
||||
}
|
||||
|
||||
|
||||
|
||||
objective.getScore(" ").setScore(3);
|
||||
objective.getScore(Localization.getComponent("game-players-count", "{players}", String.valueOf(players), "{max-players}", String.valueOf(maxPlayers)).toString()).setScore(2);
|
||||
objective.getScore(" ").setScore(1);
|
||||
|
||||
Reference in New Issue
Block a user