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
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ val projectVersion = "5.0.0-beta3"
// Where this builds on the server
val serverLocation = "1-21-5"
// Minecraft version to build against
val minecraftVersion = "1.21.5"
val minecraftVersion = "1.21.10"

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-mojang-mapped:10.0.1")
implementation("dev.jorel:commandapi-paper-shade:11.0.1-SNAPSHOT")

// 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.15.0") {
implementation("de.tr7zw:item-nbt-api:2.15.3") {
isTransitive = false
}

Expand All @@ -63,7 +63,7 @@ dependencies {
}

// FastBoard
implementation("fr.mrmicky:fastboard:2.1.4")
implementation("fr.mrmicky:fastboard:2.1.5")
}

tasks {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/shanebeestudios/hg/api/util/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ public static boolean isCursed(ItemStack itemStack) {

public static ItemStack getTrackingStick() {
ItemStack itemStack = ItemType.STICK.createItemStack();
ItemMeta itemMeta = itemStack.getItemMeta();
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
pdc.set(Constants.TRACKING_STICK_KEY, PersistentDataType.BOOLEAN, true);
itemStack.setItemMeta(itemMeta);
itemStack.editPersistentDataContainer(pdc ->
pdc.set(Constants.TRACKING_STICK_KEY, PersistentDataType.BOOLEAN, true));

itemStack.setData(DataComponentTypes.ITEM_NAME, Util.getMini(LANG.item_tracking_stick_name));
itemStack.setData(DataComponentTypes.MAX_STACK_SIZE, 1);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/shanebeestudios/hg/plugin/HungerGames.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.shanebeestudios.hg.plugin.managers.PlayerManager;
import com.shanebeestudios.hg.plugin.managers.SessionManager;
import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig;
import dev.jorel.commandapi.CommandAPIPaperConfig;
import dev.jorel.commandapi.exceptions.UnsupportedVersionException;
import io.lumine.mythic.api.MythicProvider;
import org.bstats.bukkit.Metrics;
Expand Down Expand Up @@ -74,11 +74,10 @@ public class HungerGames extends JavaPlugin {
@Override
public void onLoad() {
try {
CommandAPI.onLoad(new CommandAPIBukkitConfig(this)
CommandAPI.onLoad(new CommandAPIPaperConfig(this)
.setNamespace("hungergames")
.verboseOutput(false)
.silentLogs(true)
.skipReloadDatapacks(true));
.silentLogs(true));
} catch (UnsupportedVersionException ignore) {
Util.log("CommandAPI does not support this version of Minecraft, will update soon.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class Config {
public static String SOUNDS_DEATH;
public static String SOUNDS_OPEN_CHEST_DROP;

// Commands
public static List<String> COMMANDS_ALLOWED_IN_GAME;

private final HungerGames plugin;
private File configFile;
private FileConfiguration config;
Expand Down Expand Up @@ -202,6 +205,9 @@ private void loadConfig() {
SOUNDS_DEATH = config.getString("sounds.death");
SOUNDS_OPEN_CHEST_DROP = config.getString("sounds.open-chest-drop");

// Commands
COMMANDS_ALLOWED_IN_GAME = config.getStringList("commands.allowed-in-game");

try {
Vault.setupEconomy();
if (Vault.ECONOMY == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.shanebeestudios.hg.api.util.Util;
import com.shanebeestudios.hg.plugin.HungerGames;
import com.shanebeestudios.hg.plugin.configs.Config;
import com.shanebeestudios.hg.plugin.permission.Permissions;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

import java.util.Locale;

/**
* Internal event listener
*/
Expand All @@ -24,17 +27,23 @@ private void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (Permissions.BYPASS_COMMAND_RESTRICTION.has(player)) return;

String[] st = event.getMessage().split(" ");
String command = st[0].toLowerCase(Locale.ROOT);
// Prevent game players running non hunger games commands
if (this.playerManager.isInGame(player) && !st[0].equalsIgnoreCase("/login")) {
if (st[0].equalsIgnoreCase("/hg") || st[0].equalsIgnoreCase("/hungergames")) {
if (this.playerManager.isInGame(player)) {
// Allow some commands from the config to be bypassed
if (Config.COMMANDS_ALLOWED_IN_GAME.contains(command.replaceFirst("/", ""))) {
return;
}
// Allow use of HungerGames commands
if (command.equalsIgnoreCase("/hg") || command.equalsIgnoreCase("/hungergames")) {
return;
}
event.setMessage("/");
event.setCancelled(true);
Util.sendMessage(player, this.lang.listener_command_handler_no_command);
}
// Prevent teleporting players out of an arena
else if (("/tp".equalsIgnoreCase(st[0]) || "/teleport".equalsIgnoreCase(st[0])) && st.length >= 2) {
else if (("/tp".equalsIgnoreCase(command) || "/teleport".equalsIgnoreCase(command)) && st.length >= 2) {
Player p = Bukkit.getServer().getPlayer(st[1]);
if (p != null) {
if (this.playerManager.hasPlayerData(p)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.shanebeestudios.hg.api.gui.SpectatorGUI;
import com.shanebeestudios.hg.api.util.Constants;
import com.shanebeestudios.hg.plugin.HungerGames;
import io.papermc.paper.persistence.PersistentDataContainerView;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -12,8 +13,6 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

public class GameCompassListener extends GameListenerBase {
Expand Down Expand Up @@ -57,10 +56,8 @@ private boolean isSpectatorCompass(PlayerInteractEvent event) {

ItemStack item = event.getItem();
if (item == null || item.getType() != Material.COMPASS) return false;
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return false;

PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
PersistentDataContainerView pdc = item.getPersistentDataContainer();
return pdc.has(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -116,10 +115,8 @@ public List<ItemStack> loadItems(ConfigurationSection config) {
public ItemStack getSpectatorCompass() {
ItemStack compass = new ItemStack(Material.COMPASS);
compass.setData(DataComponentTypes.ITEM_NAME, Util.getMini(this.lang.spectate_compass_name));
compass.editMeta(itemMeta -> {
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
pdc.set(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN, true);
});
compass.editPersistentDataContainer(pdc ->
pdc.set(Constants.SPECTATOR_COMPASS_KEY, PersistentDataType.BOOLEAN, true));
return compass;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,15 @@ spectate:
# Allow spectators to chat
chat: false

## SOUNDS
# Different sounds played in the game
sounds:
# Played when a player dies in the game
death: 'ui.toast.challenge_complete'
open-chest-drop: 'block.ender_chest.open'

## COMMANDS
commands:
# Represents commands a player is allowed to use whilst in a HungerGames arena
allowed-in-game:
- 'login'
Loading