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 .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '19'
java-version: '25'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 19
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: 19
java-version: '25'
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
# Artifact name
name: HungerGames-Artifact
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# HungerGames DMZ
A new fork of ImSpoopy's [**HungerGames**](https://github.com/ImSpoopy/Hungergames)

Updating this plugin to work on 1.14.4+
See [**WIKI**](https://github.com/ShaneBeeStudios/HungerGames/wiki) for commands, permissions and setup instructions.
Designed for use on the FriedCraft MC server.

For a more detailed description of the plugin, find it on [**SpigotMC**](https://www.spigotmc.org/resources/hungergames.65942/)
Updating this plugin to work on Minecraft 26.2+
19 changes: 7 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<version>5.2.8</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>25</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -60,19 +59,19 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.11-R0.1-SNAPSHOT</version>
<version>26.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.8-SNAPSHOT</version>
<version>1.0.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.7</version>
<version>2.12.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -102,13 +101,13 @@
<dependency>
<groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId>
<version>5.9.5</version>
<version>5.12.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -126,7 +125,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.15.5</version>
<version>2.15.7</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -163,10 +162,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
<version>3.14.1</version>
</plugin>
<plugin>
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/tk/shanebee/hg/listeners/McmmoListeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -97,29 +96,6 @@ protected void blockDamageEvent(FakeBlockDamageEvent event) {
}
}

@EventHandler
private void entityDamageByEntityEvent(FakeEntityDamageByEntityEvent event) {
if (!Config.mcmmoUseSkills) {
Entity damager = event.getDamager();
Entity victim = event.getEntity();
if (playerManager.hasPlayerData(damager.getUniqueId()) || playerManager.hasPlayerData(victim.getUniqueId())) {
event.setCancelled(true);
}
}
}

@EventHandler
private void entityDamageEvent(FakeEntityDamageEvent event) {
if (!Config.mcmmoUseSkills) {
if (event.getEntity() instanceof Player) {
Player player = ((Player) event.getEntity());
if (playerManager.hasPlayerData(player.getUniqueId())) {
event.setCancelled(true);
}
}
}
}

@EventHandler
private void fishEvent(FakePlayerFishEvent event) {
if (!Config.mcmmoUseSkills) {
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/tk/shanebee/hg/managers/ItemStackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.configuration.Configuration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
Expand All @@ -12,9 +13,9 @@
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.Nullable;
import tk.shanebee.hg.HG;
import tk.shanebee.hg.data.KitEntry;
Expand Down Expand Up @@ -164,9 +165,9 @@ public ItemStack getItem(String args, boolean isStackable) {
}
} else if (s.startsWith("potion-base:") && itemMeta instanceof PotionMeta) {
s = s.replace("potion-base:", "");
PotionData potionData = PotionTypeUtils.getPotionData(s);
if (potionData != null) {
((PotionMeta) itemMeta).setBasePotionData(potionData);
PotionType potionType = PotionTypeUtils.getPotionType(s);
if (potionType != null) {
((PotionMeta) itemMeta).setBasePotionType(potionType);
}
} else if (s.startsWith("data:")) {
s = s.replace("data:", "").replace("~", " ");
Expand All @@ -181,23 +182,27 @@ public ItemStack getItem(String args, boolean isStackable) {
return item;
}

@SuppressWarnings("deprecation") //Enchantment#getName
private void enchant(ItemMeta itemMeta, String line, String enchantString) {
enchantString = enchantString.replace("enchant:", "").toUpperCase();
String[] d = enchantString.split(":");
int level = 1;
if (d.length != 1 && Util.isInt(d[1])) {
level = Integer.parseInt(d[1]);
}
for (Enchantment e : Enchantment.values()) {
if (e.getKey().getKey().equalsIgnoreCase(d[0]) || e.getName().equalsIgnoreCase(d[0])) {
for (Enchantment e : Registry.ENCHANTMENT) {
if (e.getKey().getKey().equalsIgnoreCase(d[0]) || legacyNameMatches(e, d[0])) {
itemMeta.addEnchant(e, level, true);
return;
}
}
Util.warning("Invalid enchantment: &c%s &eline: &b%s", enchantString, line);
}

@SuppressWarnings("deprecation") //Enchantment#getName has no non-deprecated replacement for legacy free-text name lookup
private boolean legacyNameMatches(Enchantment e, String name) {
return e.getName().equalsIgnoreCase(name);
}

private ItemStack itemStringToStack(String item, int amount) {
Material material;
try {
Expand Down
51 changes: 40 additions & 11 deletions src/main/java/tk/shanebee/hg/util/PotionTypeUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tk.shanebee.hg.util;

import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.Nullable;

Expand All @@ -9,7 +8,7 @@
import java.util.Map;

/**
* Util for getting {@link PotionData}
* Util for getting {@link PotionType}
*/
public enum PotionTypeUtils {

Expand Down Expand Up @@ -82,26 +81,40 @@ public static PotionType getByKey(String key) {
}

/**
* Get a PotionType based on a Bukkit key
* Get a PotionType based on a legacy Bukkit key
* <p>Some legacy Bukkit key names (eg: 'SPEED', 'JUMP', 'REGEN') no longer exist as
* {@link PotionType} constants themselves, so this resolves via the enum's own
* MC-namespace name (eg: 'SWIFTNESS', 'LEAPING', 'REGENERATION') instead of assuming
* the legacy key is still a valid constant.</p>
*
* @param bukkit Key for PotionType
* @return PotionType
* @param bukkit Legacy key for PotionType
* @return PotionType, or null if this legacy key has no modern equivalent
*/
@Nullable
public static PotionType getByBukkit(String bukkit) {
return PotionType.valueOf(bukkit.toUpperCase());
for (PotionTypeUtils p : values()) {
if (p.bukkit.equalsIgnoreCase(bukkit)) {
try {
return PotionType.valueOf(p.name());
} catch (IllegalArgumentException ex) {
return null;
}
}
}
return null;
}

/**
* Get PotionData from a String
* Get a PotionType from a String
* <p><b>Formats:</b>
* <br>POTION-TYPE (optional start with 'LONG_' or 'STRONG_')
* <br>POTION-TYPE:boolean(strong):boolean(extended)</p>
*
* @param data data string of potion type
* @return New PotionData if checks passed
* @return Resolved PotionType if checks passed
*/
@Nullable
public static PotionData getPotionData(String data) {
public static PotionType getPotionType(String data) {
String[] potionData = data.split(":");
if (potionData.length == 1) {
String pData = potionData[0].toUpperCase(Locale.ROOT);
Expand All @@ -124,7 +137,7 @@ public static PotionData getPotionData(String data) {
Util.warning("Potion can not be upgraded: &b" + data);
return null;
}
return new PotionData(potionType, extended, strong);
return resolveVariant(potionType, extended, strong);
} else if (potionData.length == 3) {
PotionType potionType = get(potionData[0]);
if (potionType == null) {
Expand All @@ -150,13 +163,29 @@ public static PotionData getPotionData(String data) {
return null;
}

return new PotionData(potionType, extended, upgraded);
return resolveVariant(potionType, extended, upgraded);
} else {
potionTypeWarning("Improper setup of potion-data: &c");
return null;
}
}

/**
* Resolve the granular {@link PotionType} constant (eg: LONG_SWIFTNESS, STRONG_SWIFTNESS)
* for a base potion type plus extended/upgraded flags, since these are now folded directly
* into the enum rather than represented as separate metadata.
*
* @param base Base potion type (already validated as extendable/upgradeable if needed)
* @param extended Whether the extended (LONG_) variant is requested
* @param upgraded Whether the upgraded (STRONG_) variant is requested
* @return Resolved PotionType
*/
private static PotionType resolveVariant(PotionType base, boolean extended, boolean upgraded) {
if (extended) return PotionType.valueOf("LONG_" + base.name());
if (upgraded) return PotionType.valueOf("STRONG_" + base.name());
return base;
}

private static void potionTypeWarning(@Nullable String warning) {
if (warning != null) Util.warning(warning);
Util.warning("&r - Check your configs");
Expand Down
Loading
Loading