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
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
`java-library`
`maven-publish`
id("io.github.0ffz.github-packages") version "1.2.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("io.github.apdevteam.github-packages") version "1.2.2"
id("io.papermc.hangar-publish-plugin") version "0.1.3"
}

repositories {
Expand All @@ -15,9 +15,9 @@ repositories {

dependencies {
api("org.jetbrains:annotations-java5:24.1.0")
compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("net.countercraft:movecraft:+")
compileOnly("it.unimi.dsi:fastutil:8.5.11")
compileOnly("it.unimi.dsi:fastutil:8.5.13")
}

group = "net.countercraft.movecraft.combat"
Expand Down Expand Up @@ -69,7 +69,7 @@ hangarPublish {
platforms {
register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) {
jar.set(tasks.jar.flatMap { it.archiveFile })
platformVersions.set(listOf("1.18.2-1.21.1"))
platformVersions.set(listOf("1.20.6-1.21.5"))
dependencies {
hangar("Movecraft") {
required.set(true)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.countercraft.movecraft.combat.MovecraftCombat;
import net.countercraft.movecraft.util.Tags;
import org.apache.commons.lang.reflect.FieldUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Field;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
Expand Down Expand Up @@ -340,36 +340,46 @@ protected boolean setIgniteOdds(Material m, int value, Object fireBlock) {
abstract Class<?> getCraftMagicNumbersClass() throws ClassNotFoundException;

protected Object getBlockClass(Material m)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
ClassNotFoundException {
if (this.magicNumbers == null) {
this.magicNumbers = this.getCraftMagicNumbersClass();
}
Method method = magicNumbers.getMethod("getBlock", Material.class);
return method.invoke(null, m);
}

protected static <T> void writeField(@NotNull Object block, @NotNull Consumer<T> whatToDoWithField, String fieldName) throws IllegalAccessException, NoSuchFieldException, ClassCastException {
Field field = FieldUtils.getField(block.getClass(), fieldName, true);
T obj = (T)field.get(block);
protected static <T> void writeField(@NotNull Object block, @NotNull Consumer<T> whatToDoWithField,
String fieldName) throws IllegalAccessException, NoSuchFieldException, ClassCastException,
InaccessibleObjectException, SecurityException {
Field field = block.getClass().getField(fieldName);
field.setAccessible(true);
T obj = (T) field.get(block);
whatToDoWithField.accept(obj);
}

protected static <T> void writeField(@NotNull Object block, T value, String fieldName) throws IllegalAccessException, NoSuchFieldException, ClassCastException {
Field field = FieldUtils.getField(block.getClass(), fieldName, true);
T obj = (T)field.get(block);
protected static <T> void writeField(@NotNull Object block, T value, String fieldName)
throws IllegalAccessException, NoSuchFieldException, ClassCastException, InaccessibleObjectException,
SecurityException {
Field field = block.getClass().getField(fieldName);
field.setAccessible(true);
field.set(block, value);
}

protected static <T> Optional<T> getFieldValueSafe(@NotNull Object instance, String fieldName) {
try {
return Optional.ofNullable(getFieldValue(instance, fieldName));
} catch(Exception ex) {
} catch (Exception ex) {
return Optional.empty();
}
}
protected static <T> T getFieldValue(@NotNull Object instance, String fieldName) throws IllegalAccessException, NoSuchFieldException, ClassCastException {
Field field = FieldUtils.getField(instance.getClass(), fieldName, true);
T obj = (T)field.get(instance);

protected static <T> T getFieldValue(@NotNull Object instance, String fieldName)
throws IllegalAccessException, NoSuchFieldException, ClassCastException, InaccessibleObjectException,
SecurityException {
Field field = instance.getClass().getField(fieldName);
field.setAccessible(true);
T obj = (T) field.get(instance);
return obj;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private boolean nextToAir(@NotNull Block b) {
public void onEntityExplode(@NotNull EntityExplodeEvent e) {
if (DurabilityOverride == null)
return;
if (e.getEntityType() != EntityType.PRIMED_TNT)
if (e.getEntityType() != EntityType.TNT)
return;

Set<Block> removeList = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private Location getCenterLocation(@NotNull Block block) {
private Set<SearchEntry> getTNT(@NotNull Block piston, @Nullable Block pistonHead, @NotNull BlockFace direction) {
Set<SearchEntry> searchResults = new HashSet<>();
for (Entity e : piston.getWorld().getEntities()) {
if (!e.isValid() || e.getType() != EntityType.PRIMED_TNT)
if (!e.isValid() || e.getType() != EntityType.TNT)
continue;

TNTPrimed tnt = (TNTPrimed) e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void run() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void entityExplodeEvent(@NotNull EntityExplodeEvent e) {
Entity tnt = e.getEntity();
if (e.getEntityType() != EntityType.PRIMED_TNT)
if (e.getEntityType() != EntityType.TNT)
return;
if (TracerRateTicks == 0)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private Vector getTNTVector() {
public void onEntitySpawn(@NotNull EntitySpawnEvent e) {
if (!DamageTracking.EnableTNTTracking)
return;
if (!e.getEntityType().equals(EntityType.PRIMED_TNT))
if (!e.getEntityType().equals(EntityType.TNT))
return;
TNTPrimed tnt = (TNTPrimed) e.getEntity();

Expand Down
Loading