Skip to content

Commit

Permalink
Add custom tab manager for team MMR display
Browse files Browse the repository at this point in the history
  • Loading branch information
Pugzy authored Jul 4, 2021
1 parent 616c55d commit 66f145e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/rip/bolt/ingame/Ingame.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onEnable() {

apiManager = new APIManager();

rankedManager = new RankedManager();
rankedManager = new RankedManager(this);

Bukkit.getPluginManager().registerEvents(rankedManager, this);
Bukkit.getPluginManager().registerEvents(rankedManager.getPlayerWatcher(), this);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/rip/bolt/ingame/config/AppData.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public static Duration forfeitAfter() {
public static Duration matchStartDuration() {
return parseDuration(Ingame.get().getConfig().getString("match-start-duration", "180s"));
}

public static boolean customTabEnabled() {
return Ingame.get().getConfig().getBoolean("custom-tab-enabled", true);
}
}
5 changes: 4 additions & 1 deletion src/main/java/rip/bolt/ingame/ranked/RankedManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import rip.bolt.ingame.Ingame;
import rip.bolt.ingame.api.definitions.BoltMatch;
import rip.bolt.ingame.api.definitions.Team;
Expand All @@ -40,6 +41,7 @@ public class RankedManager implements Listener {
private final PlayerWatcher playerWatcher;
private final RankManager rankManager;
private final StatsManager statsManager;
private final TabManager tabManager;
private final MatchSearch poll;

private TournamentFormat format;
Expand All @@ -48,10 +50,11 @@ public class RankedManager implements Listener {
private Duration cycleTime = Duration.ofSeconds(0);
private boolean manuallyCanceled;

public RankedManager() {
public RankedManager(Plugin plugin) {
playerWatcher = new PlayerWatcher(this);
rankManager = new RankManager(this);
statsManager = new StatsManager(this);
tabManager = new TabManager(plugin);
MatchPreloader.create();

poll = new MatchSearch(this::setupMatch);
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/rip/bolt/ingame/ranked/TabManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package rip.bolt.ingame.ranked;

import org.bukkit.plugin.Plugin;
import rip.bolt.ingame.config.AppData;
import rip.bolt.ingame.utils.RankedTeamTabEntry;
import tc.oc.pgm.tablist.FreeForAllTabEntry;
import tc.oc.pgm.tablist.MapTabEntry;
import tc.oc.pgm.tablist.MatchFooterTabEntry;
import tc.oc.pgm.tablist.MatchTabManager;
import tc.oc.pgm.util.tablist.PlayerTabEntry;

public class TabManager {

public TabManager(Plugin plugin) {

IngameTabManager matchTabManager;

if (AppData.customTabEnabled()) {
matchTabManager = new IngameTabManager(plugin);
plugin.getServer().getPluginManager().registerEvents(matchTabManager, plugin);
}
}

public static class IngameTabManager extends MatchTabManager {

public IngameTabManager(Plugin plugin) {
super(
plugin,
PlayerTabEntry::new,
RankedTeamTabEntry::new,
MapTabEntry::new,
MatchTabManager::headerFactory,
MatchFooterTabEntry::new,
FreeForAllTabEntry::new);
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ forfeit:
# duration to countdown before starting match
match-start-duration: "300s"

# if custom tab list should be used
custom-tab-enabled: true

# website page links (remove section to remove references)
web:
match: https://localhost:3000/matches/{matchId}
Expand Down

0 comments on commit 66f145e

Please sign in to comment.