Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
248b9aa
update javadocs
ShaneBeee May 5, 2026
c015cdb
Update to use WeightedLists (#108)
ShaneBeee May 6, 2026
3e10f15
DeleteArenaCommand - add confirmation
ShaneBeee May 6, 2026
48e8917
GameBorderData - add multiple border centers
ShaneBeee May 6, 2026
a889672
Registries - cleanup
ShaneBeee May 6, 2026
684e7ea
Util - remove legacy check
ShaneBeee May 6, 2026
3799c07
GameSidebar - update javadocs
ShaneBeee May 15, 2026
b46d070
build.gradle.kts - updates
ShaneBeee May 15, 2026
c5997e9
other javadoc updates
ShaneBeee May 15, 2026
1188ef5
build.gradle.kts - exclude sources for server task
ShaneBeee May 15, 2026
b532758
Data - add more data
ShaneBeee May 15, 2026
f45699f
Game - fix exit location of arena not working
ShaneBeee May 15, 2026
0315726
Util - add debug with format
ShaneBeee May 15, 2026
8b4fedf
Add player tracking config options
ShaneBeee May 15, 2026
6a144a1
Add player tracking config options - part 2
ShaneBeee May 15, 2026
f4e530b
PlayerManager - fix spectators data not backing up
ShaneBeee May 15, 2026
3c8bc94
Game - dont try to stop it if its already stopped
ShaneBeee May 19, 2026
c4691da
update Rollback system
ShaneBeee May 19, 2026
f021f3e
config - update some links
ShaneBeee May 19, 2026
abfa0c9
ItemParser - clamp stack size
ShaneBeee May 19, 2026
15fbe45
Location handling - now properly using locations and world keys
ShaneBeee May 19, 2026
9da353f
Util - remove old deprecated method
ShaneBeee May 20, 2026
d1495de
Util - version check updates
ShaneBeee May 20, 2026
20f336e
Javadoc updates
ShaneBeee May 20, 2026
d5b7968
Add update checker
ShaneBeee May 21, 2026
14fead9
Update issue templates
ShaneBeee May 21, 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
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ contact_links:
- name: 💻 ShaneBee's Support Discord
url: https://discord.gg/UzBCFSQJyM
about: For general help with HungerGames ask in the HungerGames channel
- name: 💿 Modrinth Resource
url: todo
about: Read about HungerGames on Modrinth!
- name: 🛠️Modrinth Resource
url: https://modrinth.com/plugin/hungergames-sb
about: Read about and download HungerGames on Modrinth!
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/report-a-bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
label: Server Version
description: Which version of the server and MC are you using?
placeholder: |
Ex: "Paper 1.21.4"
Ex: "Paper 26.1.2"
validations:
required: true

Expand Down
16 changes: 11 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
implementation("org.bstats:bstats-bukkit:3.2.0")

// MythicMobs
compileOnly("io.lumine:Mythic-Dist:5.6.1")
compileOnly("io.lumine:Mythic-Dist:5.12.0")

// Papi
compileOnly("me.clip:placeholderapi:2.12.2")
Expand All @@ -80,7 +80,8 @@ tasks {
dependsOn("shadowJar")
from("build/libs") {
include("HungerGames-*.jar")
destinationDir = file("/Users/ShaneBee/Desktop/Server/Minecraft/${serverLocation}/plugins/")
exclude("*-sources.jar")
destinationDir = file("/Users/ShaneBee/Desktop/Server/Minecraft/Skript/${serverLocation}/plugins/")
}

}
Expand All @@ -98,12 +99,17 @@ tasks {
options.compilerArgs.add("-Xlint:deprecation")
}
javadoc {
val options = options as StandardJavadocDocletOptions
options.docTitle = "HungerGames API - $projectVersion"
options.overview = "src/main/javadoc/overview.html"
options.encoding = Charsets.UTF_8.name()

exclude("com/shanebeestudios/hg/plugin/commands")
exclude("com/shanebeestudios/hg/plugin/listeners")
(options as StandardJavadocDocletOptions).links(
"https://jd.papermc.io/paper/1.21.5/",
"https://jd.advntr.dev/api/4.17.0/",
options.links(
"https://javadoc.io/doc/org.jetbrains/annotations/latest/",
"https://jd.papermc.io/paper/26.1.2/",
"https://jd.advntr.dev/api/4.25.0/",
"https://tr7zw.github.io/Item-NBT-API/v2-api/"
)

Expand Down
58 changes: 31 additions & 27 deletions src/main/java/com/shanebeestudios/hg/api/data/ItemData.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@
package com.shanebeestudios.hg.api.data;

import com.shanebeestudios.hg.api.game.Game;
import com.shanebeestudios.hg.api.util.WeightedList;
import org.bukkit.inventory.ItemStack;

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

/**
* Holder of {@link ItemStack Items} for a {@link Game}
*/
public class ItemData {

private final Map<ChestType, List<ItemStack>> items = new HashMap<>();
private final Map<ChestType, Integer> count = new HashMap<>();
private final Map<ChestType, WeightedList<ItemStack>> weightedItems = new HashMap<>();

public ItemData() {
for (ChestType chestType : ChestType.values()) {
this.items.put(chestType, new ArrayList<>());
this.weightedItems.put(chestType, new WeightedList<>());
}
}

public void setItems(ChestType type, List<ItemStack> items) {
this.items.put(type, items);
}

public List<ItemStack> getItems(ChestType type) {
return this.items.get(type);
}

/**
* Set item count
* Add a weighted item to the item data.
*
* @param chestType ChestType to count
* @param itemCount Amount of items
* @param type Chest type
* @param item Item to add
* @param weight Weight of item
*/
public void setItemCount(ChestType chestType, int itemCount) {
this.count.put(chestType, itemCount);
public void addEntry(ChestType type, ItemStack item, int weight) {
this.weightedItems.get(type).add(item, weight);
}

/**
* Get item count by ChestType
* Get a random item.
*
* @param chestType ChestType to get count from
* @return AMount of items by ChestType
* @param type Type of chest
* @return Random item
*/
public int getItemCount(ChestType chestType) {
return this.count.get(chestType);
public ItemStack getRandomItem(ChestType type) {
return this.weightedItems.get(type).nextEntry();
}

public void setWeightedItems(ChestType type, WeightedList<ItemStack> weightedItems) {
this.weightedItems.put(type, weightedItems);
}

public WeightedList<ItemStack> getWeightedItems(ChestType type) {
return this.weightedItems.get(type);
}

/**
* Get total item count for all chest types
* Get the total item count for all chest types.
*
* @return Total item count
*/
public int getTotalItemCount() {
int count = 0;
for (int value : this.count.values()) {
count += value;
for (WeightedList<ItemStack> value : this.weightedItems.values()) {
count += value.size();
}
return count;
}

/**
* Represents the type of chests in game
* Represents the type of chests in a game.
* <p>Used for logging and refilling</p>
*/
public enum ChestType {
Expand Down Expand Up @@ -97,4 +100,5 @@ public String getName() {
return this.name;
}
}

}
40 changes: 17 additions & 23 deletions src/main/java/com/shanebeestudios/hg/api/data/MobData.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shanebeestudios.hg.api.data;

import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.ApiStatus;
import com.shanebeestudios.hg.api.util.WeightedList;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand All @@ -12,8 +12,8 @@
public class MobData {

private final Random random = new Random();
private final List<MobEntry> dayMobs = new ArrayList<>();
private final List<MobEntry> nightMobs = new ArrayList<>();
private final WeightedList<MobEntry> dayMobs = new WeightedList<>();
private final WeightedList<MobEntry> nightMobs = new WeightedList<>();
private int mobCount;

/**
Expand All @@ -22,7 +22,7 @@ public class MobData {
* @return List of MobEntries
*/
public List<MobEntry> getDayMobs() {
return ImmutableList.copyOf(this.dayMobs);
return ImmutableList.copyOf(this.dayMobs.getEntries());
}

/**
Expand All @@ -32,16 +32,17 @@ public List<MobEntry> getDayMobs() {
*/
public @Nullable MobEntry getRandomDayMob() {
if (this.dayMobs.isEmpty()) return null;
return this.dayMobs.get(this.random.nextInt(this.dayMobs.size()));
return this.dayMobs.nextEntry();
}

/**
* Add a new mob entry to the day mobs
*
* @param mobEntry Mob entry to add
* @param weight Weight of mob entry
*/
public void addDayMob(MobEntry mobEntry) {
this.dayMobs.add(mobEntry);
public void addDayMob(MobEntry mobEntry, int weight) {
this.dayMobs.add(mobEntry, weight);
}

/**
Expand All @@ -50,7 +51,7 @@ public void addDayMob(MobEntry mobEntry) {
* @return List of MobEntries
*/
public List<MobEntry> getNightMobs() {
return ImmutableList.copyOf(this.nightMobs);
return ImmutableList.copyOf(this.nightMobs.getEntries());
}

/**
Expand All @@ -60,24 +61,17 @@ public List<MobEntry> getNightMobs() {
*/
public @Nullable MobEntry getRandomNightMob() {
if (this.nightMobs.isEmpty()) return null;
return this.nightMobs.get(this.random.nextInt(this.nightMobs.size()));
return this.nightMobs.nextEntry();
}

/**
* Add a new mob entry to the night mobs
*
* @param mobEntry Mob entry to add
* @param weight Weight of mob entry
*/
public void addNightMob(MobEntry mobEntry) {
this.nightMobs.add(mobEntry);
}

/**
* @hidden
*/
@ApiStatus.Internal
public void setMobCount(int mobCount) {
this.mobCount = mobCount;
public void addNightMob(MobEntry mobEntry, int weight) {
this.nightMobs.add(mobEntry, weight);
}

/**
Expand All @@ -86,18 +80,18 @@ public void setMobCount(int mobCount) {
* @return Count of all mobs
*/
public int getMobCount() {
return this.mobCount;
return this.dayMobs.size() + this.nightMobs.size();
}

/**
* Get list of all MobEntries
* Get a list of all MobEntries
*
* @return List of MobEntries
*/
public List<MobEntry> getAllMobs() {
List<MobEntry> mobs = new ArrayList<>();
mobs.addAll(this.dayMobs);
mobs.addAll(this.nightMobs);
mobs.addAll(this.dayMobs.getEntries());
mobs.addAll(this.nightMobs.getEntries());
return mobs;
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/shanebeestudios/hg/api/data/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.plugin.HungerGames;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
Expand Down Expand Up @@ -41,6 +42,8 @@ public class PlayerData implements Cloneable {
private Location previousLocation = null;
private boolean online;
private boolean hasGameStarted;
private double waypointReceiveRange;
private Color trackingColor;

//InGame data
private GameTeam gameTeam;
Expand All @@ -59,6 +62,7 @@ public PlayerData(Player player, Game game) {
this.online = true;
}

@SuppressWarnings("DataFlowIssue")
public void backup() {
this.hasGameStarted = true;
this.inv = this.player.getInventory().getStorageContents();
Expand All @@ -73,13 +77,16 @@ public void backup() {
this.player.setLevel(0);
this.player.setExp(0);
this.scoreboard = this.player.getScoreboard();
this.waypointReceiveRange = this.player.getAttribute(Attribute.WAYPOINT_RECEIVE_RANGE).getValue();
this.trackingColor = this.player.getWaypointColor();
}

/**
* Restore a player's saved data
*
* @param player Player to restore data to
*/
@SuppressWarnings("DataFlowIssue")
public void restore(Player player) {
if (player == null || !this.hasGameStarted) return;
Util.clearInv(player);
Expand All @@ -97,6 +104,8 @@ public void restore(Player player) {
// Force back their original scoreboard
player.setScoreboard(DUMMY);
player.setScoreboard(this.scoreboard);
player.getAttribute(Attribute.WAYPOINT_RECEIVE_RANGE).setBaseValue(Math.max(0, this.waypointReceiveRange));
player.setWaypointColor(this.trackingColor);
}

// Restores later if player has an item in their inventory which changes their max health value
Expand Down
29 changes: 25 additions & 4 deletions src/main/java/com/shanebeestudios/hg/api/game/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.shanebeestudios.hg.plugin.HungerGames;
import com.shanebeestudios.hg.plugin.configs.Language;
import com.shanebeestudios.hg.plugin.managers.GameManager;

/**
* General class for storing different aspects of data for {@link Game Games}
Expand All @@ -10,30 +11,50 @@ public abstract class Data {

final Game game;
final HungerGames plugin;
final GameManager gameManager;
final Language lang;

Data(Game game) {
this.game = game;
this.plugin = game.plugin;
this.gameManager = this.plugin.getGameManager();
this.lang = game.lang;
}

/**
* Get the {@link Game} this data belongs to
* Get the {@link Game} this data belongs to.
*
* @return Game this data belongs to
*/
public Game getGame() {
return game;
return this.game;
}

/**
* Quick method to access the main plugin
* Quick method to access the main plugin.
*
* @return Instance of {@link HungerGames plugin}
*/
public HungerGames getPlugin() {
return plugin;
return this.plugin;
}

/**
* Get the {@link GameManager} for the plugin.
*
* @return Instance of {@link GameManager}
*/
public GameManager getGameManager() {
return this.gameManager;
}

/**
* Get the {@link Language} for the plugin.
*
* @return Instance of {@link Language}
*/
public Language getLang() {
return this.lang;
}

}
Loading
Loading