summaryrefslogtreewikicommitdiff
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-05-04 12:22:23 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-05-04 12:22:23 -0400
commit590ab6c0e8755f5e5fe9293bd5c7ac93bdd02b30 (patch)
tree63a0e64351c2087c6c5839a7b913bedba8c3d555
parentcustom model data (diff)
downloadkenshinshideandseek-590ab6c0e8755f5e5fe9293bd5c7ac93bdd02b30.tar.gz
kenshinshideandseek-590ab6c0e8755f5e5fe9293bd5c7ac93bdd02b30.tar.bz2
kenshinshideandseek-590ab6c0e8755f5e5fe9293bd5c7ac93bdd02b30.zip
leaveOnEnd added to config file
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java4
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/Game.java64
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Status.java3
-rw-r--r--src/main/resources/config.yml7
4 files changed, 60 insertions, 18 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index 9397cc8..589d3a2 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -74,7 +74,8 @@ public class Config {
lobbyCountdownEnabled,
seekerPing,
bungeeLeave,
- lobbyItemStartAdmin;
+ lobbyItemStartAdmin,
+ leaveOnEnd;
public static int
minPlayers,
@@ -219,6 +220,7 @@ public class Config {
teleportToExit = config.getBoolean("teleportToExit");
locale = config.getString("locale", "local");
blockedCommands = config.getStringList("blockedCommands");
+ leaveOnEnd = config.getBoolean("leaveOnEnd");
blockedInteracts = new ArrayList<>();
List<String> tempInteracts = config.getStringList("blockedInteracts");
for(String id : tempInteracts){
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
index 72a530f..c01682b 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
@@ -153,6 +153,24 @@ public class Game {
}, 20 * 30);
}
+ public static void end(WinType type){
+ if(status == Status.STANDBY || status == Status.ENDING) return;
+ status = Status.ENDING;
+ for(Player player : Board.getPlayers()) {
+ player.getInventory().clear();
+ player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
+ for(PotionEffect effect : player.getActivePotionEffects()){
+ player.removePotionEffect(effect.getType());
+ }
+ if(Version.atLeast("1.9")){
+ for(Player temp : Board.getPlayers()) {
+ Packet.setGlow(player, temp, false);
+ }
+ }
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> stop(type), 5*20);
+ }
+
public static void stop(WinType type){
if(status == Status.STANDBY) return;
tick = 0;
@@ -171,24 +189,38 @@ public class Game {
}
worldBorder.resetWorldborder("hideandseek_"+spawnWorld);
for(Player player : Board.getPlayers()) {
- 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()))
- player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
- if(lobbyLeaveItem != null)
- player.getInventory().setItem(lobbyItemLeavePosition, lobbyLeaveItem);
- for(PotionEffect effect : player.getActivePotionEffects()){
- player.removePotionEffect(effect.getType());
- }
- player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
if(Version.atLeast("1.9")){
for(Player temp : Board.getPlayers()) {
Packet.setGlow(player, temp, false);
}
}
+ 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()));
+ }
+ } 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()))
+ player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
+ if(lobbyLeaveItem != null)
+ player.getInventory().setItem(lobbyItemLeavePosition, lobbyLeaveItem);
+ for(PotionEffect effect : player.getActivePotionEffects()){
+ player.removePotionEffect(effect.getType());
+ }
+ player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
+ }
}
EventListener.temp_loc.clear();
worldLoader.unloadMap();
@@ -390,15 +422,15 @@ public class Game {
if(Board.sizeHider() < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
- stop(WinType.SEEKER_WIN);
+ end(WinType.SEEKER_WIN);
} 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);
+ end(WinType.NONE);
} else if(timeLeft < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME"));
- stop(WinType.HIDER_WIN);
+ end(WinType.HIDER_WIN);
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java
index 44a3e42..e1ffa22 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java
@@ -22,5 +22,6 @@ package net.tylermurphy.hideAndSeek.util;
public enum Status {
STANDBY,
STARTING,
- PLAYING
+ PLAYING,
+ ENDING
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index c163c2d..9a82052 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -44,6 +44,13 @@ autoJoin: false
# default: false
teleportToExit: false
+# Normally when the game ends, players are set back to the lobby to play another game.
+# You can disable this, and empty the lobby after the game finishes. This is like everyone
+# running /hs leave at the end of the game. Players will leave either to the exit position
+# or another server depending what you have `leaveType` set too.
+# default: false
+leaveOnEnd: false
+
# What do you want to happen when a player leaves the lobby. If you are running a single server, maybe you want to send
# them to the world hub. But if you are running a bungee-cord or velocity server, maybe you want to send them to the servers
# hub.