Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
**ForceBattle** is a multiplayer gamemode where players compete to complete randomized objectives and earn points.
The player with the most points after the timer ends wins the battle!

Current supported Minecraft version: 1.21.8

**Objective types include:**
- 🔹 Collect an item
- 🔹 Kill a mob
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
spigot = "1.21.4-R0.1-SNAPSHOT"
spigot = "1.21.8-R0.1-SNAPSHOT"
gson = "2.11.0"
guice = "7.0.0"
annotations = "26.0.1"
bstats = "3.0.2"
adventureTextMinimessage = "4.17.0"
adventureTextSerializerLegacy = "4.17.0"
adventureBukkit = "4.3.4"
adventureBukkit = "4.4.1"
slf4j = "2.0.16"
logback = "1.5.18"
lombok = "1.18.32"
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/net/fameless/forcebattle/ForceBattle.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import net.fameless.forcebattle.game.NametagManager;
import net.fameless.forcebattle.game.ObjectiveManager;
import net.fameless.forcebattle.game.Timer;
import net.fameless.forcebattle.gui.LanguageGUI;
import net.fameless.forcebattle.gui.ResultGUI;
import net.fameless.forcebattle.gui.SettingsGUI;
import net.fameless.forcebattle.gui.GUIListener;
import net.fameless.forcebattle.tablist.TablistManager;
import net.fameless.forcebattle.util.BukkitUtil;
import net.fameless.forcebattle.util.ResourceUtil;
Expand All @@ -39,12 +37,6 @@ public final class ForceBattle extends JavaPlugin {
private static Timer timer;
@Getter
private static ObjectiveManager objectiveManager;
@Getter
private LanguageGUI languageGUI;
@Getter
private ResultGUI resultGUI;
@Getter
private SettingsGUI settingsGUI;

public static ForceBattle get() {
return instance;
Expand All @@ -59,18 +51,12 @@ public void onEnable() {

Caption.setCurrentLanguage(Language.ofIdentifier(getConfig().getString("lang", "en")));

this.languageGUI = new LanguageGUI();
this.resultGUI = new ResultGUI();
this.settingsGUI = new SettingsGUI();

initCore();

NametagManager.runTask();

Bukkit.getPluginManager().registerEvents(new GameListener(), this);
Bukkit.getPluginManager().registerEvents(languageGUI, this);
Bukkit.getPluginManager().registerEvents(resultGUI, this);
Bukkit.getPluginManager().registerEvents(settingsGUI, this);
Bukkit.getPluginManager().registerEvents(new GUIListener(), this);

CommandHandler.registerAll(Command.COMMANDS);
PermissionManager.registerPermissions();
Expand Down Expand Up @@ -107,6 +93,7 @@ private void initCore() {
Command.createInstances();
BossbarManager.runTask();
TablistManager.startUpdating();
//ScoreboardManager.startUpdater();
PluginUpdater.checkForUpdate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.fameless.forcebattle.game.Objective;
import net.fameless.forcebattle.game.Team;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.Format;
import net.fameless.forcebattle.util.StringUtility;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
Expand Down Expand Up @@ -96,14 +96,14 @@ private static void hideBossBar(BattlePlayer battlePlayer, HashMap<BattlePlayer,
return Caption.of(
"bossbar.format_hide_points",
TagResolver.resolver("battletype", Tag.inserting(Component.text(playerObjective.getBattleType().getPrefix()))),
TagResolver.resolver("objective", Tag.inserting(Component.text(Format.formatName(playerObjective.getObjectiveString()))))
TagResolver.resolver("objective", Tag.inserting(Component.text(StringUtility.formatName(playerObjective.getObjectiveString()))))
);
}

return Caption.of(
"bossbar.format",
TagResolver.resolver("battletype", Tag.inserting(Component.text(playerObjective.getBattleType().getPrefix()))),
TagResolver.resolver("objective", Tag.inserting(Component.text(Format.formatName(playerObjective.getObjectiveString())))),
TagResolver.resolver("objective", Tag.inserting(Component.text(StringUtility.formatName(playerObjective.getObjectiveString())))),
TagResolver.resolver("pointstype", Tag.inserting(Component.text(isPlayerInTeam ? "Team-Points" : "Points"))),
TagResolver.resolver("points", Tag.inserting(Component.text(points)))
);
Expand All @@ -117,14 +117,14 @@ private static void hideBossBar(BattlePlayer battlePlayer, HashMap<BattlePlayer,
return Caption.of(
"bossbar.team_format_hide_points",
TagResolver.resolver("battletype", Tag.inserting(Component.text(teamObjective.getBattleType().getPrefix()))),
TagResolver.resolver("objective", Tag.inserting(Component.text(Format.formatName(teamObjective.getObjectiveString()))))
TagResolver.resolver("objective", Tag.inserting(Component.text(StringUtility.formatName(teamObjective.getObjectiveString()))))
);
}

return Caption.of(
"bossbar.team_format",
TagResolver.resolver("battletype", Tag.inserting(Component.text(teamObjective.getBattleType().getPrefix()))),
TagResolver.resolver("objective", Tag.inserting(Component.text(Format.formatName(teamObjective.getObjectiveString())))),
TagResolver.resolver("objective", Tag.inserting(Component.text(StringUtility.formatName(teamObjective.getObjectiveString())))),
TagResolver.resolver("pointstype", Tag.inserting(Component.text("Team-Points"))),
TagResolver.resolver("points", Tag.inserting(Component.text(team.getPoints())))
);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/fameless/forcebattle/caption/Caption.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.Getter;
import net.fameless.forcebattle.ForceBattle;
import net.fameless.forcebattle.event.LanguageChangeEvent;
import net.fameless.forcebattle.util.Format;
import net.fameless.forcebattle.util.StringUtility;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.Tag;
Expand Down Expand Up @@ -45,7 +45,7 @@ private Caption() {

private static @NotNull String replaceDefaults(String input) {
input = input.replace("<prefix>", getString("prefix"))
.replace("<time>", Format.formatTime(ForceBattle.getTimer().getTime()))
.replace("<time>", StringUtility.formatTime(ForceBattle.getTimer().getTime()))
;
return input;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.configuration.SettingsManager;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.fameless.forcebattle.util.TabCompletions;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -54,7 +54,7 @@ public void executeCommand(CommandCaller caller, String[] args) {
@Override
public List<String> tabComplete(CommandCaller caller, String @NotNull [] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
}
return List.of();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.fameless.forcebattle.command;

import net.fameless.forcebattle.command.framework.CallerType;
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.gui.impl.SettingsGUI;
import net.fameless.forcebattle.player.BattlePlayer;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class ConfigSettingsCommand extends Command {

public ConfigSettingsCommand() {
super(
"configsettings",
List.of("menu"),
CallerType.PLAYER,
"/configsettings",
"forcebattle.settings",
"Command to open the settings menu"
);
}

@Override
public void executeCommand(@NotNull CommandCaller caller, String[] args) {
if (caller instanceof BattlePlayer player) {
new SettingsGUI().open(player);
}
}

@Override
public List<String> tabComplete(CommandCaller caller, String[] args) {
return List.of();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.game.Team;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -98,7 +98,7 @@ protected void executeCommand(CommandCaller caller, String[] args) {
@Override
public List<String> tabComplete(CommandCaller caller, String @NotNull [] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], List.of("player", "team"), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], List.of("player", "team"), new ArrayList<>());
}
return List.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.fameless.forcebattle.util.TabCompletions;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -44,7 +44,7 @@ public void executeCommand(CommandCaller caller, String[] args) {
@Override
public List<String> tabComplete(CommandCaller caller, String @NotNull [] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
}
return List.of();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/fameless/forcebattle/command/JokerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.fameless.forcebattle.util.TabCompletions;

import java.util.ArrayList;
Expand Down Expand Up @@ -76,17 +76,17 @@ protected void executeCommand(final CommandCaller caller, final String[] args) {
@Override
protected List<String> tabComplete(final CommandCaller caller, final String[] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], List.of("add", "remove"), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], List.of("add", "remove"), new ArrayList<>());
}
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
return StringUtility.copyPartialMatches(args[1], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
}
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], List.of(JokerType.PLAYERSKIP.getIdentifier(), JokerType.SWAP.getIdentifier(),
return StringUtility.copyPartialMatches(args[2], List.of(JokerType.PLAYERSKIP.getIdentifier(), JokerType.SWAP.getIdentifier(),
JokerType.TEAMSKIP.getIdentifier()), new ArrayList<>());
}
if (args.length == 4) {
return StringUtil.copyPartialMatches(args[3], List.of("amount"), new ArrayList<>());
return StringUtility.copyPartialMatches(args[3], List.of("amount"), new ArrayList<>());
}
return List.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import net.fameless.forcebattle.command.framework.CallerType;
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.gui.LanguageGUI;
import net.fameless.forcebattle.gui.impl.LanguageGUI;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.jetbrains.annotations.NotNull;

Expand All @@ -16,8 +16,6 @@

public class LanguageCommand extends Command {

private final LanguageGUI languageGUI;

public LanguageCommand() {
super(
"language",
Expand All @@ -27,8 +25,6 @@ public LanguageCommand() {
"forcebattle.lang",
"Command to change the language of the plugin"
);

this.languageGUI = ForceBattle.get().getLanguageGUI();
}

@Override
Expand All @@ -38,7 +34,7 @@ public void executeCommand(@NotNull CommandCaller caller, String @NotNull [] arg
caller.sendMessage(Caption.of(CallerType.CONSOLE.getErrorMessageKey()));
return;
}
battlePlayer.openInventory(languageGUI.getLanguageGUI());
new LanguageGUI().open(battlePlayer);
} else {
net.fameless.forcebattle.caption.Language newLanguage = net.fameless.forcebattle.caption.Language.ofIdentifier(args[0]);
if (newLanguage != null && !newLanguage.equals(Caption.getCurrentLanguage())) {
Expand All @@ -51,7 +47,7 @@ public void executeCommand(@NotNull CommandCaller caller, String @NotNull [] arg
@Override
public List<String> tabComplete(CommandCaller caller, String @NotNull [] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], List.of("en", "zh_cn", "zh_tw", "de"), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], List.of("en", "zh_cn", "zh_tw", "de"), new ArrayList<>());
}
return List.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.fameless.forcebattle.util.TabCompletions;

import java.util.ArrayList;
Expand Down Expand Up @@ -63,9 +63,9 @@ protected void executeCommand(final CommandCaller caller, final String[] args) {
@Override
protected List<String> tabComplete(final CommandCaller caller, final String[] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], List.of("add", "set", "remove"), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], List.of("add", "set", "remove"), new ArrayList<>());
} else if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
return StringUtility.copyPartialMatches(args[1], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
} else if (args.length == 3 && args[2].isEmpty()) {
return List.of("<amount>");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ protected void executeCommand(final CommandCaller caller, final String[] args) {
return;
}

System.out.println("Size: " + size);
List<BattlePlayer> players = new ArrayList<>(BattlePlayer.BATTLE_PLAYERS);
List<BattlePlayer> players = new ArrayList<>(BattlePlayer.getOnlinePlayers());
int playerAmount = players.size();
System.out.println("PlayerAmount: " + playerAmount);

if (playerAmount % size != 0) {
caller.sendMessage(Caption.of("error.no_equal_teams"));
Expand All @@ -58,7 +56,6 @@ protected void executeCommand(final CommandCaller caller, final String[] args) {

Random random = new Random();
int amountOfTeams = playerAmount / size;
System.out.println("AmountOfTeams: " + amountOfTeams);

for (int i = 0; i < amountOfTeams; i++) {
BattlePlayer player = players.get(random.nextInt(players.size()));
Expand All @@ -81,7 +78,6 @@ protected void executeCommand(final CommandCaller caller, final String[] args) {
for (BattlePlayer player : team.getPlayers()) {
names.add(player.getName() + ", ");
}
System.out.println("Team " + team.getId() + ": " + names);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.player.BattlePlayer;
import net.fameless.forcebattle.util.StringUtil;
import net.fameless.forcebattle.util.StringUtility;
import net.fameless.forcebattle.util.TabCompletions;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -46,7 +46,7 @@ public void executeCommand(CommandCaller caller, String @NotNull [] args) {
@Override
public List<String> tabComplete(CommandCaller caller, String @NotNull [] args) {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
return StringUtility.copyPartialMatches(args[0], TabCompletions.getPlayerNamesTabCompletions(), new ArrayList<>());
}
return List.of();
}
Expand Down
Loading
Loading