diff --git a/pom.xml b/pom.xml
index c85e343..72119dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,6 +64,7 @@
com.intellectualsites.fawe
FAWE-Bukkit
1.16-462
+ provided
redis.clients
@@ -76,6 +77,11 @@
5.0
provided
+
+ com.github.missionarydev
+ board
+ -SNAPSHOT
+
org.apache.commons
commons-dbcp2
diff --git a/src/main/java/me/sisko/partygames/Main.java b/src/main/java/me/sisko/partygames/Main.java
index 19fc504..08032ff 100644
--- a/src/main/java/me/sisko/partygames/Main.java
+++ b/src/main/java/me/sisko/partygames/Main.java
@@ -4,22 +4,35 @@
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
+import me.missionary.board.BoardManager;
+import me.missionary.board.settings.BoardSettings;
+import me.missionary.board.settings.ScoreDirection;
import me.sisko.partygames.commands.playCommand;
import me.sisko.partygames.util.ConfigManager;
import me.sisko.partygames.util.MinigameManager;
+import me.sisko.partygames.util.ScoreboardProvider;
public class Main extends JavaPlugin {
private static Main plugin;
-
+ private BoardManager manager;
+
@Override
public void onEnable() {
plugin = this;
getLogger().info("Hello World!");
getCommand("play").setExecutor(new playCommand());
-
+
+ manager = new BoardManager(this, BoardSettings.builder().boardProvider(new ScoreboardProvider()).scoreDirection(ScoreDirection.UP).build());
+ Bukkit.getPluginManager().registerEvents(manager, this);
Bukkit.getPluginManager().registerEvents(new DefaultListener(), this);
ConfigManager.load();
MinigameManager.load();
+
+ }
+
+ @Override
+ public void onDisable() {
+ manager.onDisable();
}
public static Main getPlugin() {
diff --git a/src/main/java/me/sisko/partygames/minigames/DiggingMinigame.java b/src/main/java/me/sisko/partygames/minigames/DiggingMinigame.java
index af3e818..fd124d7 100644
--- a/src/main/java/me/sisko/partygames/minigames/DiggingMinigame.java
+++ b/src/main/java/me/sisko/partygames/minigames/DiggingMinigame.java
@@ -17,6 +17,7 @@
import me.sisko.partygames.Main;
import me.sisko.partygames.util.MinigameManager;
+import net.md_5.bungee.api.ChatColor;
public class DiggingMinigame extends Minigame {
diff --git a/src/main/java/me/sisko/partygames/minigames/TNTRunMinigame.java b/src/main/java/me/sisko/partygames/minigames/TNTRunMinigame.java
index 667ad10..318183e 100644
--- a/src/main/java/me/sisko/partygames/minigames/TNTRunMinigame.java
+++ b/src/main/java/me/sisko/partygames/minigames/TNTRunMinigame.java
@@ -213,6 +213,10 @@ public void onMove(PlayerMoveEvent e) {
} else if (!inGame.contains(e.getPlayer())) {
e.setCancelled(false);
addPlayer(e.getPlayer());
+
+ // player is in game after winning and has just died
+ } else {
+ addPlayer(e.getPlayer());
}
} else if (inGame.contains(e.getPlayer()) && gameStarted) {
@@ -243,8 +247,6 @@ public void run() {
}
}
// after game ends, winner falls down
- } else if (!gameStarted) {
- e.getPlayer().teleport(spawn);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/me/sisko/partygames/util/MinigameManager.java b/src/main/java/me/sisko/partygames/util/MinigameManager.java
index 04f0d3f..65e058a 100644
--- a/src/main/java/me/sisko/partygames/util/MinigameManager.java
+++ b/src/main/java/me/sisko/partygames/util/MinigameManager.java
@@ -33,6 +33,17 @@ public class MinigameManager {
private static Minigame currentMinigame = null;
private static BukkitRunnable timeout = null;
+ private static long endTime = 0;
+
+ public static enum GameState {
+ PREGAME,
+ INGAME,
+ POSTGAME,
+ NOGAME
+ };
+
+ private static GameState state = GameState.NOGAME;
+
public static void load() {
File dataFolder = new File(Main.getPlugin().getDataFolder().getAbsolutePath() + "/games");
@@ -96,6 +107,9 @@ public static void initializationComplete() {
// called by the minigame when done initializing
public static void prestartComplete() {
+ endTime = System.currentTimeMillis() + 10*1000;
+ state = GameState.PREGAME;
+
Bukkit.broadcastMessage("Game starting in 10 seconds...");
new BukkitRunnable(){
@@ -130,6 +144,9 @@ public void run() {
};
timeout.runTaskLater(Main.getPlugin(), currentMinigame.getTimeoutTime());
currentMinigame.start();
+
+ state = GameState.INGAME;
+ endTime = System.currentTimeMillis() + currentMinigame.getTimeoutTime()*1000/20;
}
}.runTaskLater(Main.getPlugin(), 10*20);
@@ -140,7 +157,9 @@ public static void gameComplete(final List winners) {
timeout.cancel();
timeout = null;
currentMinigame.postgame();
-
+ state = GameState.POSTGAME;
+ endTime = System.currentTimeMillis() + 10*1000;
+
Bukkit.broadcastMessage("Minigame " + currentMinigame.getName() + " complete!");
Bukkit.broadcastMessage("Map: " + currentMinigame.getMap());
Bukkit.broadcastMessage("Winners: ");
@@ -175,6 +194,7 @@ public void run() {
HandlerList.unregisterAll(currentMinigame);
currentMinigame.cleanup();
currentMinigame = null;
+ state = GameState.NOGAME;
for(Player p : Bukkit.getOnlinePlayers()) {
FileConfiguration config = Main.getPlugin().getConfig();
@@ -216,4 +236,33 @@ private static final JSONObject getJson(File f) {
}
return null;
}
+
+
+ public static final List getScoreboardLines(Player p) {
+ List lines = new ArrayList<>();
+ lines.add("&6mc.left4craft.org");
+ lines.add("&7&m-----------------");
+ lines.add("&dGame&7: &e" + currentMinigame.getName());
+ lines.add("");
+ lines.add("&dMap&7: &e" + currentMinigame.getMap());
+ lines.add("");
+
+ final long diff = 1000 + endTime - System.currentTimeMillis();
+ final int seconds = (int) Math.floor((diff%60000) / 1000);
+ final String seconds_str = seconds < 10 ? "0" + seconds : "" + seconds;
+
+ if(state == GameState.PREGAME) {
+ lines.add("&dGame starts&7: &e" + (int) Math.floor(diff/60000.) + ":" + seconds_str);
+ lines.add("");
+ } else if (state == GameState.INGAME) {
+ lines.add("&dGame finishes&7: &e" + (int) Math.floor(diff/60000.) + ":" + seconds_str);
+ lines.add("");
+ } else if (state == GameState.POSTGAME) {
+ lines.add("&dGame ends&7: &e" + (int) Math.floor(diff/60000.) + ":" + seconds_str);
+ lines.add("");
+ }
+
+ lines.add("&7&m-----------------");
+ return lines;
+ }
}
diff --git a/src/main/java/me/sisko/partygames/util/ScoreboardProvider.java b/src/main/java/me/sisko/partygames/util/ScoreboardProvider.java
new file mode 100644
index 0000000..f092a87
--- /dev/null
+++ b/src/main/java/me/sisko/partygames/util/ScoreboardProvider.java
@@ -0,0 +1,36 @@
+package me.sisko.partygames.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.entity.Player;
+
+import me.missionary.board.provider.BoardProvider;
+import net.md_5.bungee.api.ChatColor;
+
+public class ScoreboardProvider implements BoardProvider {
+
+ @Override
+ public String getTitle(Player player) {
+ return ChatColor.LIGHT_PURPLE + "Party Games";
+ }
+
+ @Override
+ public List getLines(Player player) {
+ if(MinigameManager.inGame()) {
+ return MinigameManager.getScoreboardLines(player);
+ }
+ List lines = new ArrayList<>();
+ lines.add("&6mc.left4craft.org");
+ lines.add("&7&m-----------------");
+ lines.add(ChatColor.LIGHT_PURPLE + "Name" + ChatColor.GRAY + ": " + ChatColor.YELLOW + player.getName());
+ lines.add("");
+ lines.add(ChatColor.LIGHT_PURPLE + "Wins" + ChatColor.GRAY + ": " + ChatColor.YELLOW + "5");
+ lines.add("");
+ lines.add(ChatColor.LIGHT_PURPLE + "Points" + ChatColor.GRAY + ": " + ChatColor.YELLOW + "432");
+ lines.add("");
+ lines.add("&7&m-----------------");
+ return lines;
+ }
+
+}