Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
987f0a8
Lobby Creation Menu
drfiveminusmint Sep 28, 2026
e1573ac
Update gradle.yml
drfiveminusmint Sep 28, 2026
da05052
Reverse Rated and Unrated Colors
drfiveminusmint Sep 28, 2026
dfcd9a2
Settings Menu
drfiveminusmint Sep 30, 2026
9128892
Fix Lobby Creation menu NPE
drfiveminusmint Sep 30, 2026
e748969
Cleanup Imports
drfiveminusmint Sep 30, 2026
4bbc7ab
Cleanup Imports
drfiveminusmint Sep 30, 2026
575935b
Matchmaking Prototype
drfiveminusmint Sep 30, 2026
14a0857
Better arena generation
drfiveminusmint Sep 30, 2026
1a906fb
Add matchmaking to example format fiel
drfiveminusmint Oct 1, 2026
d458e3e
Verbose logging for matchmaking
drfiveminusmint Oct 1, 2026
6da9db4
ArenaRestockingTest respects background generation lists
drfiveminusmint Oct 1, 2026
619676a
Queue Improvements
drfiveminusmint Oct 1, 2026
a895b5b
Handle unrated players
drfiveminusmint Oct 4, 2026
c0309fd
SettingsMenu NPE
drfiveminusmint Oct 4, 2026
ad641c6
Fix FiveUI dependency
drfiveminusmint Oct 4, 2026
afb91c0
Fix evaluate additions logic
drfiveminusmint Oct 4, 2026
1e3efca
disable heuristic for testing
drfiveminusmint Oct 4, 2026
b1b70cd
debug
drfiveminusmint Oct 4, 2026
d229316
debug
drfiveminusmint Oct 4, 2026
f17a35f
Fix max players per team
drfiveminusmint Oct 4, 2026
10ffaeb
Fix time coefficient
drfiveminusmint Oct 4, 2026
dd007d3
debug messages
drfiveminusmint Oct 4, 2026
1c145c3
Fix floating point math
drfiveminusmint Oct 4, 2026
3eda513
truncation fix
drfiveminusmint Oct 4, 2026
d781177
actually add team 2 rating
drfiveminusmint Oct 4, 2026
7ee84a4
remove debug messages
drfiveminusmint Oct 4, 2026
66607c4
Queue Notifications
drfiveminusmint Oct 4, 2026
7251848
Leaderboards
drfiveminusmint Oct 5, 2026
ede88ee
Queue and Leaderboard UI
drfiveminusmint Oct 5, 2026
b9da281
fix leaderboard
drfiveminusmint Oct 6, 2026
ab9454b
Players leave queue on logout
drfiveminusmint Oct 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:

- name: Build with Gradle
run: gradle clean build --parallel
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.github.drfiveminusmint'
version = 'Alpha-2.1'
version = 'Alpha-3.0'
description = "brick ball"
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

Expand All @@ -23,11 +23,19 @@ repositories {
maven {
url = uri("https://maven.enginehub.org/repo/")
}
maven {
url = uri("https://maven.pkg.github.com/drfiveminusmint/fiveui")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.10")
compileOnly("com.sk89q.worldedit:worldedit-core:7.3.3")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.3")
compileOnly("com.github.drfiveminusmint:fiveui:alpha-1.0.3")
}
125 changes: 119 additions & 6 deletions src/main/java/com/github/drfiveminusmint/brickball/Brickball.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,31 @@
import com.github.drfiveminusmint.brickball.scheduling.BrickballScheduler;
import com.github.drfiveminusmint.brickball.scheduling.CreateMatchTask;
import com.github.drfiveminusmint.brickball.scheduling.LoadStatsTask;
import com.github.drfiveminusmint.brickball.scheduling.matchmaking.Matchmaker;
import com.github.drfiveminusmint.brickball.stats.FormatStats;
import com.github.drfiveminusmint.brickball.stats.Leaderboard;
import com.github.drfiveminusmint.brickball.ui.LobbyCreationMenu;
import com.github.drfiveminusmint.fiveUI.FiveUI;
import com.github.drfiveminusmint.fiveUI.container.Page;
import com.github.drfiveminusmint.fiveUI.element.LinkButton;
import com.github.drfiveminusmint.fiveUI.element.StaticButton;
import com.github.drfiveminusmint.fiveUI.util.ItemStackBuilder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;

Expand All @@ -30,10 +46,14 @@ public final class Brickball extends JavaPlugin {
private TemplateManager templateManager;
private MatchManager matchManager;
private LobbyList lobbyList;
private ArrayList<BrickballFormat> formats = new ArrayList<>();
private HashMap<BrickballFormat, FormatStats> perFormatStats = new HashMap();
private final ArrayList<BrickballFormat> formats = new ArrayList<>();
private final ArrayList<ArenaTemplate> backroundGenerateMaps = new ArrayList<>();
private final HashMap<BrickballFormat, FormatStats> perFormatStats = new HashMap<>();
private final HashMap<BrickballFormat, Matchmaker> matchmakers = new HashMap<>();
private final HashMap<BrickballFormat, Leaderboard> leaderboards = new HashMap<>();
private World matchWorld;
private BrickballScheduler scheduler;
private Page mainUI;
private boolean doBackgroundArenaGeneration = false;

public static Brickball getInstance() {
Expand Down Expand Up @@ -88,8 +108,10 @@ public void onEnable() {
else
getLogger().log(Level.INFO, "[Debug] Couldn't load map " + f.getName());
}
int numMatchmakers = 0;
// Load formats and stats
for (File file : formatsFolder.listFiles()) {
if (file.isDirectory()) continue;
YamlConfiguration formatConfig = new YamlConfiguration();
try {
formatConfig.load(file);
Expand All @@ -100,7 +122,19 @@ public void onEnable() {
// load stats from the CSV
File statsFile = new File(statsFolder, format.getName() + ".csv");
if (!statsFile.exists()) statsFile.createNewFile();
scheduler.submitTask(new LoadStatsTask(99, statsFile, formatStats));
scheduler.submitTask(new LoadStatsTask(99, statsFile, formatStats, format));
// create matchmakers if necessary
if (format.getDoMatchmaking()) {
Matchmaker matchmaker = new Matchmaker(format);
// stagger our matchmakers running
matchmaker.runTaskTimerAsynchronously(this, 20 + numMatchmakers++, 20);
matchmakers.put(format, matchmaker);
}
// Create leaderboards for rated modes
if (format.getIsRated()) {
Leaderboard board = new Leaderboard(format);
leaderboards.put(format, board);
}
getLogger().log(Level.INFO, "Loaded format " + format.getName());
} catch (Exception e) {
getLogger().log(Level.SEVERE, String.format("Error loading format file %s!", file.getName()));
Expand All @@ -116,27 +150,106 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new MatchEndListener(), this);

doBackgroundArenaGeneration = getConfig().getBoolean("preloadArenas", false);
for (Object o : getConfig().getList("backgroundGenerateMaps", new ArrayList<>())) {
if (o instanceof String s && templateManager.findTemplate(s) != null)
backroundGenerateMaps.add(templateManager.findTemplate(s));
}
doBackgroundArenaGeneration = !backroundGenerateMaps.isEmpty();
if (doBackgroundArenaGeneration) {
int i = 0;
for (ArenaTemplate template : templateManager.templates.values()) {
for (ArenaTemplate template : backroundGenerateMaps) {
scheduler.submitTask(new CreateMatchTask(template.getID(), -1));
}
}

// Create UI Pages
mainUI = new Page(Component.text("Brickball", NamedTextColor.DARK_RED, TextDecoration.BOLD), InventoryType.CHEST);
Page matchmakingUI = new Page(Component.text("Find Match", NamedTextColor.DARK_RED, TextDecoration.BOLD), InventoryType.CHEST);
Page leaderboardUI = new Page(Component.text("Leaderboards", NamedTextColor.GOLD, TextDecoration.BOLD), InventoryType.CHEST);

// Build main UI page
mainUI.setElement(10, new LinkButton(
new ItemStackBuilder(Material.BRICK, 1)
.name(Component.text("Find Match", NamedTextColor.YELLOW))
.itemStack(),
matchmakingUI));
mainUI.setElement(13, new LinkButton(
new ItemStackBuilder(Material.NETHER_STAR, 1)
.name(Component.text("Leaderboards", NamedTextColor.YELLOW))
.itemStack(),
leaderboardUI));
StaticButton createCustomButton = new StaticButton(new ItemStackBuilder(Material.ANVIL, 1)
.name(Component.text("Create Custom Match", NamedTextColor.YELLOW))
.itemStack());
createCustomButton.setOnClick(((player, clickableElement, clickType) -> new LobbyCreationMenu(player)));
mainUI.setElement(16, createCustomButton);

// Build matchmaking UI page
int i = 0;
for (BrickballFormat format : matchmakers.keySet()) {
StaticButton button = new StaticButton(format.getUnselectedDisplayItem());
button.setOnClick(((player, clickableElement, clickType) -> startPlayerQueue(player, format)));
matchmakingUI.setElement(i++, button);
if (i >= matchmakingUI.getInventory().getSize())
break;
}
matchmakingUI.setOnClose(((player, container) -> Bukkit.getScheduler().runTaskLater(this, () -> mainUI.display(player), 1)));

// Build leaderboards page
i = 0;
for (BrickballFormat format : leaderboards.keySet()) {
leaderboardUI.setElement(i++, new LinkButton(format.getUnselectedDisplayItem(), leaderboards.get(format).getDisplayPage()));
if (i >= leaderboardUI.getInventory().getSize())
break;
}

}

public World getMatchWorld() {return matchWorld;}
public void setMatchWorld(World world) {matchWorld = world;}
public ArrayList<BrickballFormat> getFormats() { return formats; }
public FormatStats getFormatStats(BrickballFormat format) {return perFormatStats.get(format);}

public boolean startPlayerQueue(Player player, BrickballFormat format) {
// check to see if the player can join the queue
for (Matchmaker matchmaker : matchmakers.values())
if (matchmaker.hasPlayer(player))
return false;
if (lobbyList.getLobbyByPlayer(player) != null)
return false;
// add the player to the queue
matchmakers.get(format).addPlayer(player);
player.sendMessage(Component.text("Joined the queue for ", NamedTextColor.GOLD)
.append(Component.text(format.getName(), NamedTextColor.YELLOW)));
player.sendMessage(Component.text("To leave the queue use ", NamedTextColor.GOLD)
.append( Component.text("/brickball leave", NamedTextColor.AQUA).clickEvent(ClickEvent.runCommand("/bb leave"))));
return true;
}

public boolean endPlayerQueue(Player player) {
boolean result = false;
for (Matchmaker matchmaker : matchmakers.values())
result |= matchmaker.removePlayer(player);
return result;
}

public Leaderboard getLeaderboard(BrickballFormat format) { return leaderboards.get(format); }

public boolean isBackgroundGenerationEnabled() {
return doBackgroundArenaGeneration;
}

public ArrayList<ArenaTemplate> getBackroundGenerateMaps() {
return backroundGenerateMaps;
}

public Page getMainUI() { return mainUI; }

@Override
public void onDisable() {
FiveUI.getInstance().getUIManager().unregisterInterface(mainUI);
matchManager.stopAllMatches();
scheduler.shutdown();
for (Matchmaker matchmaker : matchmakers.values())
matchmaker.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
return true;
}
if (args.length < 1) {
player.sendMessage("Usage: /brickball (join/jointeam/create/leave/map/start/pause/unpause)");
//player.sendMessage("Usage: /brickball (join/jointeam/create/leave/map/start/pause/unpause)");
Brickball.getInstance().getMainUI().display(player);
return true;
}
if (args[0].equalsIgnoreCase("join")) return joinCommand(player, args);
Expand All @@ -49,7 +50,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
if (args[0].equalsIgnoreCase("map")) return mapCommand(player, args);
if (args[0].equalsIgnoreCase("start")) return startCommand(player);
if (args[0].equalsIgnoreCase("teamColor")) return teamColorCommand(player, args);
if (args[0].equalsIgnoreCase("setting")) return settingCommand(player, args);
if (args[0].equalsIgnoreCase("settings")) return settingCommand(player, args);
if (args[0].equalsIgnoreCase("setmap")) return setMapCommand(player, args);
if (args[0].equalsIgnoreCase("setworld")) return setWorldCommand(player, args);
if (args[0].equalsIgnoreCase("admin")) return adminCommand(player, args);
Expand Down Expand Up @@ -374,7 +375,11 @@ public boolean leaveCommand(Player player) {
player.sendMessage("You have left the lobby.");
return true;
}
player.sendMessage(Component.text("You're not in a Brickball lobby.", NamedTextColor.RED));
if (Brickball.getInstance().endPlayerQueue(player)) {
player.sendMessage("You have left the queue.");
return true;
}
player.sendMessage(Component.text("You're not in a Brickball lobby or queue.", NamedTextColor.RED));
return true;
}

Expand Down Expand Up @@ -408,10 +413,6 @@ public boolean teamCommand(Player player, String[] args) {
// Alters match settings in the player's current lobby.
// These changes propagate downwards to the active match if one is present.
public boolean settingCommand(Player player, String[] args) {
if (args.length < 2) {
player.sendMessage("Usage: /brickball setting (setting) <value>");
return true;
}
Lobby lobby = Brickball.getInstance().getLobbyList().getLobbyByPlayer(player);
if (lobby == null) {
player.sendMessage(Component.text("You're not in a Brickball lobby.", NamedTextColor.RED));
Expand All @@ -425,6 +426,10 @@ public boolean settingCommand(Player player, String[] args) {
player.sendMessage(Component.text("You can't change match settings in a rated match.", NamedTextColor.RED));
return true;
}
if (args.length < 2) {
lobby.getSettingsMenu().open(player);
return true;
}
NamespacedKey key = MatchSettings.Setting.getKey(args[1]);
if (key == null) {
player.sendMessage(Component.text("Unknown match setting: " + args[1], NamedTextColor.RED));
Expand Down Expand Up @@ -584,7 +589,7 @@ public boolean startCommand(Player player) {
result.add(key.getKey());
return result;
}
if (args.length == 1) return List.of( "admin", "create", "host", "cancel", "join", "jointeam", "leave", "map", "pause", "ready", "setting", "setmap", "setworld", "start", "stats", "teamcolor", "unpause");
if (args.length == 1) return List.of( "admin", "create", "host", "cancel", "join", "jointeam", "leave", "map", "pause", "ready", "settings", "setmap", "setworld", "start", "stats", "teamcolor", "unpause");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.github.drfiveminusmint.brickball.Brickball;
import com.github.drfiveminusmint.brickball.events.event.MatchEndEvent;
import com.github.drfiveminusmint.brickball.lobby.BrickballFormat;
import com.github.drfiveminusmint.brickball.stats.Leaderboard;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

Expand All @@ -14,5 +16,8 @@ public void onMatchEnd(MatchEndEvent event) {
// update stats
BrickballFormat format = event.getFormat();
Brickball.getInstance().getFormatStats(format).updateStats(event.getResult());
// update leaderboards
final Leaderboard leaderboard = Brickball.getInstance().getLeaderboard(format);
Bukkit.getScheduler().runTaskAsynchronously(Brickball.getInstance(), leaderboard::update);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void onPlayerLogout (PlayerQuitEvent event) {
Lobby lobby = Brickball.getInstance().getLobbyList().getLobbyByPlayer(event.getPlayer());
if (lobby != null)
lobby.leave(event.getPlayer());
Brickball.getInstance().endPlayerQueue(event.getPlayer());
}

// effects that trigger when a player recieves the brick by any means
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import com.github.drfiveminusmint.brickball.Brickball;
import com.github.drfiveminusmint.brickball.arena.ArenaTemplate;
import com.github.drfiveminusmint.brickball.match.MatchSettings;
import com.github.drfiveminusmint.fiveUI.util.ItemStackBuilder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -12,11 +18,12 @@

public class BrickballFormat {
private final String name;
private final boolean isRated;
private final boolean isRated, doMatchmaking;
private final int minPlayersPerTeam, maxPlayersPerTeam;
private final MatchSettings settings;
private final List<ArenaTemplate> validMaps;
private final String requiredPermission;
private final ItemStack inactiveDisplayItem, activeDisplayItem;

public BrickballFormat(ConfigurationSection section) {
this.name = section.getString("name");
Expand All @@ -25,6 +32,7 @@ public BrickballFormat(ConfigurationSection section) {
this.minPlayersPerTeam = section.getInt("minPlayersPerTeam", 0);
this.maxPlayersPerTeam = section.getInt("maxPlayersPerTeam", 99);
this.isRated = section.getBoolean("isRated", false);
this.doMatchmaking = section.getBoolean("doMatchmaking", false);
// if there is no such section, this will return a clone of the default settings
this.settings = new MatchSettings(section.getConfigurationSection("overrideSettings"));
// an empty map list indicates all maps are allowed
Expand All @@ -37,11 +45,27 @@ public BrickballFormat(ConfigurationSection section) {
Brickball.getInstance().getLogger().log(Level.WARNING, String.format("Cannot find map '%s' for format '%s'.", s, name));
}
this.requiredPermission = section.getString("requiredPermission", "");
ConfigurationSection itemSection = section.getConfigurationSection("displayItem");
// Create the 'selected' and 'unselected' items for the lobby creation GUI
// The selected item has an enchantment glow.
ItemStackBuilder builder;
if (itemSection == null) {
builder = new ItemStackBuilder(Material.BRICK, 1);
} else {
builder = new ItemStackBuilder(Material.valueOf(itemSection.getString("type", "BRICK")), itemSection.getInt("quantity", 1))
.name(Component.text(name, (this.isRated ? NamedTextColor.RED : NamedTextColor.AQUA)))
.addLore(Component.text(itemSection.getString("lore", "")));
}
this.inactiveDisplayItem = builder.name(Component.text(name, (this.isRated ? NamedTextColor.RED : NamedTextColor.AQUA))).itemStack();
this.activeDisplayItem = builder.name(Component.text(name, (this.isRated ? NamedTextColor.RED : NamedTextColor.AQUA), TextDecoration.BOLD))
.setGlimmer(true).itemStack();
}

public String getName() { return name; }

public boolean getIsRated() {return isRated;}
public boolean getIsRated() { return isRated; }

public boolean getDoMatchmaking() { return doMatchmaking; }

public int getMinPlayersPerTeam() { return minPlayersPerTeam; }
public int getMaxPlayersPerTeam() { return maxPlayersPerTeam; }
Expand All @@ -54,4 +78,7 @@ public Collection<ArenaTemplate> getValidMaps() {
}

public String getRequiredPermission() { return requiredPermission; }

public ItemStack getUnselectedDisplayItem() { return inactiveDisplayItem; }
public ItemStack getSelectedDisplayItem() { return activeDisplayItem; }
}
Loading
Loading