Skip to content

Commit 9980cee

Browse files
committed
TrueOG Release v1.1
TrueOG Version 1.1 (Core 1.3.1) has the following new features and bug fixes: - Multiple configurable lobby types - Updated /hbcreatelobby to require a lobby type - Added /hbreloadconfigs to reload the configs without a server restart - Added silent game state update that doesn't call its event - Game state is now set to dead during lobby shutdown - Updated HB join messages to include live games - Updated HB join messages to send a message when there are no available lobbies - World Manager will nolonger error when a greater max voting maps is configured. It will default to the max it can pick from.
1 parent 97ed7c9 commit 9980cee

File tree

13 files changed

+263
-51
lines changed

13 files changed

+263
-51
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ The plugin currently does not generate this automatically and therefore it must
2121
- /hbforcestart [time] - force the game to start at a specified time - theherobrine.command.forcestart
2222
- /hbdropshard - force the shard carrier to drop the shard +10 blocks on the x-axis - theherobrine.command.dropshard
2323
- /hbjoin [lobby id] - allows players to join a lobby - no permission
24-
- /hbcreatelobby - create a new lobby - theherobrine.command.createlobby
24+
- /hbcreatelobby <configuration id> - create a new lobby - theherobrine.command.createlobby
2525
- /hbdeletelobby <lobby id> - delete a lobby - theherobrine.command.deletelobby
2626
- /hbspectate - switch from playing to spectating whilst in-lobby - theherobrine.command.spectate
27+
- /hbreloadconfigs - reload lobby configs - theherobrine.reloadconfigs
2728

2829
### Kit Permissions
2930
Requiring permissions for classic and unlockable kits can be set in the config.yml.
@@ -38,18 +39,33 @@ Requiring permissions for classic and unlockable kits can be set in the config.y
3839
- Sorcerer - theherobrine.kit.unlockable.sorcerer
3940

4041
### Other Permissions
41-
- theherobrine.overfill - allow players to join above the limit
42+
- theherobrine.overfill - allow players to join above the limit
43+
44+
## Lobby Setup
45+
Within your `plugins/TheHerobrine-OG` folder you should have a folder called "lobbies". Within this, you can have yaml files for each of your lobby configurations. This is an example configuration:
46+
```yaml
47+
id: "default" # Used internally for identification, and by the map base (see below)
48+
prefix: "HB" # Lobby prefix to be used.
49+
minPlayers: 8 # Min players to start a game
50+
maxPlayers: 13 # Max players
51+
startTime: 90 # How long until the game starts when the min is reached
52+
allowOverfill: false # Can players with the permission overfill the max?
53+
votingMaps: 4 # How many maps should be selected for voting, this should be no more than the amount in the map base config
54+
endVotingAt: 10 # What time does voting end? (in the starting countdown)
55+
autoStartAmount: 1 # How many lobbies should be auto started on boot?
56+
```
57+
This file and directory will be automatically created if they do not exist. (A default config will be created if there is zero in the folder.)
4258
4359
## Map Setup
44-
Your base server directory should include a folder called `maps` (or whatever set in the config.yml). Within this folder, there should be a file called `maps.yaml`. This is how a demo `maps.yaml` should look:
60+
Your base server directory should include a folder called `maps` (or whatever set in the config.yml). Within this folder, there should be a file for each of your configs (mentioned above) called `<config id>.yaml`. This is how it should look:
4561
```yaml
4662
maps:
4763
- map1
4864
- map2
4965
- map3
5066
```
5167

52-
In your `maps` directory, there should be a folder with the name listed in `maps.yaml` with the world data and a file called `mapdata.yaml`.
68+
In your `maps` directory, there should be a folder with the name listed in `<config id>.yaml` with the world data and a file called `mapdata.yaml`.
5369
This files contains map information and the location of the survivor's spawn, herobrine's spawn, the alter location and the shard location.
5470
This is what an example file should look like:
5571
```yaml

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "uk.hotten.herobrine"
12-
version = "1.3.1-1.0"
12+
version = "1.3.1-1.1"
1313

1414
repositories {
1515
mavenLocal()

src/main/java/uk/hotten/herobrine/HerobrinePluginOG.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ public void onEnable() {
3737
getCommand("hbjoin").setExecutor(new JoinLobbyCommand());
3838
getCommand("hbjoin").setTabCompleter(new JoinLobbyCompleter());
3939
getCommand("hbcreatelobby").setExecutor(new CreateLobbyCommand());
40+
getCommand("hbcreatelobby").setTabCompleter(new CreateLobbyCompleter());
4041
getCommand("hbdeletelobby").setExecutor(new DeleteLobbyCommand());
4142
getCommand("hbdeletelobby").setTabCompleter(new DeleteLobbyCompleter());
4243
getCommand("hbspectate").setExecutor(new SpectateCommand());
44+
getCommand("hbreloadconfigs").setExecutor(new ReloadConfigsCommand());
4345

4446
ScoreboardLib.setPluginInstance(this);
4547

src/main/java/uk/hotten/herobrine/commands/CreateLobbyCommand.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,28 @@
55
import org.bukkit.command.CommandExecutor;
66
import org.bukkit.command.CommandSender;
77
import uk.hotten.herobrine.lobby.LobbyManager;
8+
import uk.hotten.herobrine.lobby.data.LobbyConfig;
89
import uk.hotten.herobrine.utils.Message;
910

1011
public class CreateLobbyCommand implements CommandExecutor {
1112

1213
@Override
1314
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
14-
sender.sendMessage(Message.format("Creating lobby..."));
15-
String lobby = LobbyManager.getInstance().createLobby();
15+
if (args == null || args.length == 0) {
16+
sender.sendMessage(Message.format(ChatColor.RED + "Correct Usage: /hbcreatelobby <configuration id>"));
17+
sendAvailable(sender);
18+
return true;
19+
}
20+
21+
LobbyConfig lobbyConfig = LobbyManager.getInstance().getLobbyConfig(args[0]);
22+
if (lobbyConfig == null) {
23+
sender.sendMessage(Message.format(ChatColor.RED + args[0] + " is not a valid configuration."));
24+
sendAvailable(sender);
25+
return true;
26+
}
27+
28+
sender.sendMessage(Message.format("Creating lobby from config '" + lobbyConfig.getId() + "'..."));
29+
String lobby = LobbyManager.getInstance().createLobby(lobbyConfig);
1630
if (lobby == null) {
1731
sender.sendMessage(Message.format(ChatColor.RED + "Failed to create lobby, please contact your administrator."));
1832
return true;
@@ -21,4 +35,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
2135
sender.sendMessage(Message.format(ChatColor.GREEN + "Lobby " + lobby + " created successfully."));
2236
return true;
2337
}
38+
39+
private void sendAvailable(CommandSender sender) {
40+
sender.sendMessage(Message.format(ChatColor.RED + "The following types are available:"));
41+
LobbyManager.getInstance().getLobbyConfigsIds().forEach(id -> sender.sendMessage(Message.format(ChatColor.RED + " - " + id)));
42+
}
2443
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package uk.hotten.herobrine.commands;
2+
3+
import org.bukkit.command.Command;
4+
import org.bukkit.command.CommandSender;
5+
import org.bukkit.command.TabCompleter;
6+
import uk.hotten.herobrine.lobby.LobbyManager;
7+
8+
import java.util.List;
9+
10+
public class CreateLobbyCompleter implements TabCompleter {
11+
12+
@Override
13+
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
14+
15+
if (args.length == 1) {
16+
return LobbyManager.getInstance().getLobbyConfigsIds();
17+
}
18+
19+
return null;
20+
}
21+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package uk.hotten.herobrine.commands;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
import uk.hotten.herobrine.lobby.LobbyManager;
8+
import uk.hotten.herobrine.utils.Console;
9+
import uk.hotten.herobrine.utils.Message;
10+
11+
public class ReloadConfigsCommand implements CommandExecutor {
12+
13+
@Override
14+
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
15+
sender.sendMessage(Message.format(ChatColor.YELLOW + "Note: This will not affect already created lobbies!"));
16+
sender.sendMessage(Message.format("Reloading lobby configurations..."));
17+
try {
18+
LobbyManager.getInstance().checkAndLoadConfigs(false);
19+
20+
sender.sendMessage(Message.format(ChatColor.GREEN + "Successfully loaded " + LobbyManager.getInstance().getLobbyConfigsIds().size() + " lobby configuration(s)."));
21+
} catch (Exception e) {
22+
sender.sendMessage(Message.format(ChatColor.RED + "Failed to reload lobby configuration files. Please contact your administrator."));
23+
Console.error("Failed to reload config files.");
24+
e.printStackTrace();
25+
}
26+
return true;
27+
}
28+
}

src/main/java/uk/hotten/herobrine/game/GameManager.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ public GameManager(JavaPlugin plugin, GameLobby gameLobby, RedisManager redis, P
108108
gameState = GameState.BOOTING;
109109
shardState = ShardState.WAITING;
110110

111-
requiredToStart = plugin.getConfig().getInt("minPlayers");
112-
maxPlayers = plugin.getConfig().getInt("maxPlayers");
113-
startTimer = plugin.getConfig().getInt("startTime");
114-
allowOverfill = plugin.getConfig().getBoolean("allowOverfill");
111+
requiredToStart = gameLobby.getLobbyConfig().getMinPlayers();
112+
maxPlayers = gameLobby.getLobbyConfig().getMaxPlayers();
113+
startTimer = gameLobby.getLobbyConfig().getStartTime();
114+
allowOverfill = gameLobby.getLobbyConfig().isAllowOverfill();
115115
networkName = plugin.getConfig().getString("networkName");
116116
networkWeb = plugin.getConfig().getString("networkWeb");
117117
boolean lockClassicKits = plugin.getConfig().getBoolean("lockClassicKits");
@@ -182,6 +182,13 @@ public void run() {
182182
}.runTask(plugin);
183183
}
184184

185+
// Should only be used in GameLobby's shutdown to force the state to dead.
186+
public void setGameStateSilently(GameState newState) {
187+
GameState old = gameState;
188+
gameState = newState;
189+
Console.debug(gameLobby, "Game state silently updated to " + newState.toString() + "(from " + old.toString() + ")!");
190+
}
191+
185192
public void setShardState(ShardState newState) {
186193
new BukkitRunnable() {
187194

@@ -205,7 +212,7 @@ public void startWaiting() {
205212

206213
// In case the timer decreased from players leaving and a world was loaded
207214
Bukkit.getServer().getScheduler().runTask(plugin, () -> gameLobby.getWorldManager().clean(false));
208-
startTimer = plugin.getConfig().getInt("startTime");
215+
startTimer = getGameLobby().getLobbyConfig().getStartTime();
209216

210217
waitingRunnable = new WaitingRunnable(this).runTaskTimerAsynchronously(plugin, 0, 10);
211218
}

src/main/java/uk/hotten/herobrine/lobby/GameLobby.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import uk.hotten.herobrine.data.RedisManager;
1515
import uk.hotten.herobrine.game.GameManager;
1616
import uk.hotten.herobrine.game.runnables.MapVotingRunnable;
17+
import uk.hotten.herobrine.lobby.data.LobbyConfig;
1718
import uk.hotten.herobrine.stat.StatManager;
1819
import uk.hotten.herobrine.utils.Console;
20+
import uk.hotten.herobrine.utils.GameState;
1921
import uk.hotten.herobrine.world.WorldManager;
2022

2123
import java.util.ArrayList;
@@ -24,6 +26,7 @@ public class GameLobby {
2426

2527
private JavaPlugin plugin;
2628

29+
@Getter private LobbyConfig lobbyConfig;
2730
@Getter private String lobbyId;
2831

2932
@Getter private GameManager gameManager;
@@ -35,8 +38,9 @@ public class GameLobby {
3538

3639
@Getter private ArrayList<Player> players;
3740

38-
public GameLobby(JavaPlugin plugin, String lobbyId) {
41+
public GameLobby(JavaPlugin plugin, LobbyConfig lobbyConfig, String lobbyId) {
3942
this.plugin = plugin;
43+
this.lobbyConfig = lobbyConfig;
4044
this.lobbyId = lobbyId;
4145
}
4246

@@ -73,6 +77,7 @@ public void shutdown(boolean removeSelf, boolean recreate) {
7377
Console.info("Lobby " + lobbyId + " is shutting down...");
7478
HandlerList.unregisterAll(gameManager.getGmListener());
7579
HandlerList.unregisterAll(worldManager);
80+
gameManager.setGameStateSilently(GameState.DEAD);
7681
gameManager.updateTags(GameManager.ScoreboardUpdateAction.BEGONETHOT);
7782
gameManager.getScoreboards().values().forEach(Scoreboard::deactivate);
7883
gameManager.getScoreboards().clear();
@@ -85,6 +90,6 @@ public void shutdown(boolean removeSelf, boolean recreate) {
8590
Console.info("Lobby " + lobbyId + " has shutdown.");
8691

8792
if (recreate)
88-
LobbyManager.getInstance().createLobby();
93+
LobbyManager.getInstance().createLobby(lobbyConfig);
8994
}
9095
}

0 commit comments

Comments
 (0)