Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
73197bf
editorconfig - prevent wildcard imports
ShaneBeee Apr 9, 2025
4c2b552
Update MC 1.21.4 to 1.21.5
ShaneBeee Apr 12, 2025
21dd32f
ItemParser - remove old code
ShaneBeee Apr 12, 2025
6f54621
build.gradle.kts - update CommandAPI
ShaneBeee Apr 12, 2025
9e00c47
ItemParser - add support for hidden components
ShaneBeee Apr 12, 2025
cc88e32
ItemParser - add some 1.21.4 support (minimal)
ShaneBeee Apr 12, 2025
a771ae9
Validate.java - remove unused class
ShaneBeee Apr 12, 2025
ad21afc
GamePlayerData - remove todo
ShaneBeee Apr 12, 2025
336e3d8
GameManager - remove useless variables
ShaneBeee Apr 12, 2025
722d60e
Game - teleport players into arena when the game is ready to go
ShaneBeee Apr 12, 2025
6073c3c
Game - fix error when stopping game if players have joined but arent …
ShaneBeee Apr 12, 2025
5635fae
KillManager - fix spectators keeping items after death
ShaneBeee Apr 12, 2025
38fcfad
language.yml - fix typo
ShaneBeee Apr 12, 2025
c42f842
CustomArg - better handling of invalid game arg
ShaneBeee Apr 12, 2025
99b3f45
Game - cleanup winners/rewards
ShaneBeee Apr 13, 2025
4032886
Game - fix ability to double join a gam
ShaneBeee Apr 13, 2025
cf5f74e
PlayerManager - small cleanup
ShaneBeee Apr 13, 2025
621e153
HungerGames - change up metrics for config
ShaneBeee Apr 13, 2025
b9639a0
Config - more cleanup
ShaneBeee Apr 13, 2025
01786aa
Leaderboard - overhaul
ShaneBeee Apr 13, 2025
d995299
Cleanup to fix guidelines
ShaneBeee Apr 13, 2025
7b25c25
NBTApi - fix javadoc
ShaneBeee Apr 13, 2025
bd578a5
build.gradle.kts - update paper docs
ShaneBeee Apr 13, 2025
c5177e7
Change some access
ShaneBeee Apr 13, 2025
f55484a
Game - change block log
ShaneBeee Apr 13, 2025
63faa4d
ListCommand - add option to see players in any game
ShaneBeee Apr 13, 2025
c775e5a
EditCommand - combine chest refill subs
ShaneBeee Apr 13, 2025
889716a
language.yml - fix command in debug string
ShaneBeee Apr 13, 2025
9059dce
GameLobbyWall - fill null error
ShaneBeee Apr 13, 2025
08271cf
GameLobbyWall - support all sign types
ShaneBeee Apr 13, 2025
ab93818
GameLobbyWall - allow for customizing lobby signs (all lines)
ShaneBeee Apr 13, 2025
00f891c
Listeners - fix up pre-game listeners
ShaneBeee Apr 13, 2025
32b2c6e
Kits - add preselect kits
ShaneBeee Apr 13, 2025
2c1b5cd
method cleanup
ShaneBeee Apr 13, 2025
a8025ff
GameBlockData - change how random bonus chests are chosen
ShaneBeee Apr 13, 2025
f388306
PlayerSession - prevent overlapping
ShaneBeee Apr 14, 2025
123cab9
GameManager - check overlapping when loading arenas
ShaneBeee Apr 14, 2025
1226dca
ArenaConfig - more error messages when arenas fail to load
ShaneBeee Apr 14, 2025
b9279cb
language - more lang cleanup
ShaneBeee Apr 14, 2025
8c9cdce
ForceStartCommand - rework ordering
ShaneBeee Apr 14, 2025
7bd7c2b
MainCommand - add help
ShaneBeee Apr 14, 2025
d942737
Switch to paper-plugin.yml
ShaneBeee Apr 14, 2025
7f43a1b
main package info not needed
ShaneBeee Apr 14, 2025
4664bc1
build.gradle.kts - change shading location
ShaneBeee Apr 14, 2025
e88b270
Tasks - add Folia based task stuff
ShaneBeee Apr 14, 2025
f89613c
SessionCommand - add command/listener to end player sessions
ShaneBeee Apr 14, 2025
98670c7
language.yml - fix casing
ShaneBeee Apr 14, 2025
42358ad
TeamCommand - better handling of player suggestions
ShaneBeee Apr 14, 2025
b47ee3d
Game - fix winning reward number format
ShaneBeee Apr 14, 2025
313e4f2
build.gradle.kts - update CommandAPI and NBT-API
ShaneBeee May 9, 2025
57f5503
KillManager - update PlayerDeathEvent params
ShaneBeee May 9, 2025
5d381de
paper-plugin.yml - update api-version
ShaneBeee May 9, 2025
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 .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true
ij_continuation_indent_size = 4
[*.yml]
indent_size = 2
[*.java]
ij_java_class_count_to_use_import_on_demand = 999999
ij_java_names_count_to_use_import_on_demand = 999999
18 changes: 9 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ plugins {
// Version of HungerGames
val projectVersion = "5.0.0-beta1"
// Where this builds on the server
val serverLocation = "1-21-4"
val serverLocation = "1-21-5"
// Minecraft version to build against
val minecraftVersion = "1.21.4"
val minecraftVersion = "1.21.5"

java.sourceCompatibility = JavaVersion.VERSION_21

Expand Down Expand Up @@ -41,7 +41,7 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:${minecraftVersion}-R0.1-SNAPSHOT")

// Command Api
implementation("dev.jorel:commandapi-bukkit-shade:9.7.0")
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:10.0.1")

// bStats
implementation("org.bstats:bstats-bukkit:3.1.0")
Expand All @@ -53,7 +53,7 @@ dependencies {
compileOnly("me.clip:placeholderapi:2.11.6")

// NBT-API
implementation("de.tr7zw:item-nbt-api:2.14.2-SNAPSHOT") {
implementation("de.tr7zw:item-nbt-api:2.15.0") {
isTransitive = false
}

Expand All @@ -77,7 +77,7 @@ tasks {
}
processResources {
val prop = ("version" to projectVersion)
filesMatching("plugin.yml") {
filesMatching("paper-plugin.yml") {
expand(prop)
}
}
Expand All @@ -91,16 +91,16 @@ tasks {
exclude("com/shanebeestudios/hg/plugin/commands")
exclude("com/shanebeestudios/hg/plugin/listeners")
(options as StandardJavadocDocletOptions).links(
"https://jd.papermc.io/paper/1.21.1/",
"https://jd.papermc.io/paper/1.21.5/",
"https://jd.advntr.dev/api/4.17.0/",
"https://tr7zw.github.io/Item-NBT-API/v2-api/"
)

}
shadowJar {
relocate("fr.mrmicky.fastboard", "com.shanebeestudios.hg.api.fastboard")
relocate("dev.jorel.commandapi", "com.shanebeestudios.hg.api.commandapi")
relocate("de.tr7zw.changeme.nbtapi", "com.shanebeestudios.hg.api.nbt")
relocate("fr.mrmicky.fastboard", "com.shanebeestudios.hg.shaded-api.fastboard")
relocate("dev.jorel.commandapi", "com.shanebeestudios.hg.shaded-api.commandapi")
relocate("de.tr7zw.changeme.nbtapi", "com.shanebeestudios.hg.shaded-api.nbt")
relocate("org.bstats", "com.shanebeestudios.hg.api.metrics")
archiveFileName = "HungerGames-${projectVersion}.jar"
}
Expand Down
115 changes: 95 additions & 20 deletions src/main/java/com/shanebeestudios/hg/api/command/CustomArg.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.shanebeestudios.hg.api.command;

import com.shanebeestudios.hg.api.data.PlayerData;
import com.shanebeestudios.hg.api.game.Game;
import com.shanebeestudios.hg.api.game.GameTeam;
import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.plugin.HungerGames;
import com.shanebeestudios.hg.plugin.configs.Language;
import com.shanebeestudios.hg.plugin.managers.GameManager;
import dev.jorel.commandapi.CommandAPI;
import com.shanebeestudios.hg.plugin.managers.PlayerManager;
import dev.jorel.commandapi.arguments.Argument;
import dev.jorel.commandapi.arguments.ArgumentSuggestions;
import dev.jorel.commandapi.arguments.CustomArgument;
import dev.jorel.commandapi.arguments.EntitySelectorArgument;
import dev.jorel.commandapi.arguments.StringArgument;
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
import dev.jorel.commandapi.executors.ExecutionInfo;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;

import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;

public abstract class CustomArg {

private static Language LANG;
private static GameManager GAME_MANAGER;
private static PlayerManager PLAYER_MANAGER;

/**
* Initialize GameManager constant
Expand All @@ -25,20 +33,10 @@ public abstract class CustomArg {
* @param gameManager GameManager instance
*/
@ApiStatus.Internal
public static void init(GameManager gameManager) {
public static void init(HungerGames plugin, GameManager gameManager) {
LANG = plugin.getLang();
GAME_MANAGER = gameManager;
}

/**
* @hidden
*/
public static Game getGame(ExecutionInfo<?, ?> info) throws WrapperCommandSyntaxException {
Game game = info.args().getByClass("game", Game.class);
if (game == null) {
String raw = info.args().getRaw("game");
throw CommandAPI.failWithString("invalid game '" + raw + "'");
}
return game;
PLAYER_MANAGER = plugin.getPlayerManager();
}

/**
Expand All @@ -47,10 +45,87 @@ public static Game getGame(ExecutionInfo<?, ?> info) throws WrapperCommandSyntax
public static final CustomArg GAME = new CustomArg() {
@Override
public Argument<?> get(String name) {
return new CustomArgument<>(new StringArgument(name), info ->
GAME_MANAGER.getGame(info.input().toLowerCase(Locale.ROOT)))
.includeSuggestions(ArgumentSuggestions.stringCollectionAsync(info ->
CompletableFuture.supplyAsync(GAME_MANAGER::getGameNames)));
return new CustomArgument<>(new StringArgument(name), info -> {
String gameName = info.input().toLowerCase(Locale.ROOT);
Game game = GAME_MANAGER.getGame(gameName);
if (game == null) {
String msg = LANG.command_base_invalid_game.replace("<arena>", gameName);
Util.throwCustomArgException(msg);
}
return game;
}).includeSuggestions(ArgumentSuggestions.stringCollectionAsync(info ->
CompletableFuture.supplyAsync(GAME_MANAGER::getGameNames)));
}
};

public static final CustomArg GAME_PLAYER_FOR_TEAM = new CustomArg() {
@Override
public Argument<?> get(String name) {
return new CustomArgument<>(new EntitySelectorArgument.OnePlayer(name), info -> {
Player player = info.currentInput();
if (PLAYER_MANAGER.getGame(player) == null) {
String msg = LANG.command_team_player_not_available.replace("<player>", player.getName());
Util.throwCustomArgException(msg);
}
return player;
}).replaceSuggestions(ArgumentSuggestions.stringCollectionAsync(info -> {
if (!(info.sender() instanceof Player player)) return null;

// No player data = no game
PlayerData playerData = PLAYER_MANAGER.getPlayerData(player);
if (playerData == null) return null;

// Not in game = no team
Game game = playerData.getGame();
if (game == null) return null;

// No team = no invite
GameTeam gameTeam = game.getGameScoreboard().getGameTeam(player);
if (gameTeam == null) return null;

// Only leader can invite players
if (gameTeam.getLeader() != player) return null;

List<String> names = game.getGamePlayerData().getPlayers().stream()
.filter(p -> !gameTeam.isOnTeam(p) && !gameTeam.isPending(p))
.map(Player::getName)
.toList();
return CompletableFuture.supplyAsync(() -> names);
}));
}
};

public static final CustomArg GAME_PLAYER_ON_TEAM = new CustomArg() {
@Override
public Argument<?> get(String name) {
return new CustomArgument<>(new EntitySelectorArgument.OnePlayer(name), info -> {
Player player = info.currentInput();
if (PLAYER_MANAGER.getGame(player) == null) {
String msg = LANG.command_team_player_not_available.replace("<player>", player.getName());
Util.throwCustomArgException(msg);
}
return player;
}).replaceSuggestions(ArgumentSuggestions.stringCollectionAsync(info -> {
if (!(info.sender() instanceof Player player)) return null;

// No player data = no game
PlayerData playerData = PLAYER_MANAGER.getPlayerData(player);
if (playerData == null) return null;

// Not in game = no team
Game game = playerData.getGame();
if (game == null) return null;

// No team = no team members
GameTeam gameTeam = game.getGameScoreboard().getGameTeam(player);
if (gameTeam == null) return null;

List<String> names = gameTeam.getPlayers().stream()
.filter(teamMember -> teamMember != player)
.map(Player::getName)
.toList();
return CompletableFuture.supplyAsync(() -> names);
}));
}
};

Expand Down
45 changes: 33 additions & 12 deletions src/main/java/com/shanebeestudios/hg/api/data/KitData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.plugin.HungerGames;
import com.shanebeestudios.hg.plugin.configs.Language;
import com.shanebeestudios.hg.plugin.managers.PlayerManager;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;

/**
Expand All @@ -18,38 +20,53 @@
@SuppressWarnings("unused")
public class KitData {

private final PlayerManager playerManager = HungerGames.getPlugin().getPlayerManager();
private final Language lang = HungerGames.getPlugin().getLang();
private final HashMap<String, KitEntry> kitEntries = new HashMap<>();
private final Map<String, KitEntry> kitEntries = new HashMap<>();
private final Map<Player, KitEntry> preselectedKits = new HashMap<>();

public boolean hasKitPermission(Player player, String kitName) {
KitEntry kitEntry = this.kitEntries.get(kitName);
return kitEntry == null || kitEntry.hasKitPermission(player);
}

/**
* Give a player the default kit
* Give a player a preselected or default kit
* <p>If the player selected a kit in the KitGui before the game
* started, they will get this.
* Otherwise, if there is a default kit set up they will get that.</p>
*
* @param player Player to give kit to
*/
public void giveDefaultKit(Player player) {
if (this.kitEntries.containsKey("default")) {
setKit(player, "default");
public void givePreselectedOrDefaultKit(Player player) {
if (this.preselectedKits.containsKey(player)) {
KitEntry kitEntry = this.preselectedKits.get(player);
this.preselectedKits.remove(player);
kitEntry.setInventoryContent(player);
} else if (this.kitEntries.containsKey("default")) {
setKit(player, this.kitEntries.get("default"));
Util.sendPrefixedMessage(player, this.lang.kits_give_default);
}
}

/**
* Set a kit for a player
*
* @param player The player to set the kit for
* @param kitName The name of the kit to set
* @param player The player to set the kit for
* @param kitEntry The kit to set
*/
public void setKit(Player player, String kitName) {
if (!this.kitEntries.containsKey(kitName)) {
Util.sendMessage(player, "<red>" + kitName + this.lang.kits_doesnt_exist);
Util.sendMessage(player, "Available Kits:" + getKitListString(player));
public void setKit(Player player, KitEntry kitEntry) {
PlayerData playerData = this.playerManager.getPlayerData(player);
// This shouldn't happen, but just in case
if (playerData == null) return;

if (playerData.hasGameStared()) {
kitEntry.setInventoryContent(player);
this.preselectedKits.remove(player);
} else {
this.kitEntries.get(kitName).setInventoryContent(player);
this.preselectedKits.put(player, kitEntry);
Util.sendPrefixedMessage(player, this.lang.kits_kit_gui_pre_select
.replace("<kit>", kitEntry.getName()));
}
}

Expand Down Expand Up @@ -132,4 +149,8 @@ public void clearKits() {
this.kitEntries.clear();
}

public void clearPreselectedKits() {
this.preselectedKits.clear();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shanebeestudios.hg.api.data;

import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.api.game.Game;
import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.plugin.permission.Permissions;
import com.shanebeestudios.hg.plugin.permission.Permissions.Permission;
import org.bukkit.entity.Player;
Expand Down
Loading
Loading