Support 1.17

This commit is contained in:
Brianna 2021-06-13 15:55:28 -05:00
parent bba7394942
commit 423ae8977e
2 changed files with 14 additions and 18 deletions

11
pom.xml
View File

@ -41,7 +41,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.0-SNAPSHOT</version>
<executions>
<execution>
<id>shaded</id>
@ -74,7 +74,12 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>public</id>
@ -90,7 +95,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.4</version>
<version>1.17</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,9 +1,9 @@
package com.songoda.epicenchants.utils.single;
import com.songoda.core.math.MathUtils;
import com.songoda.epicenchants.enums.EnchantResult;
import com.songoda.epicenchants.enums.TriggerType;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -14,9 +14,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -25,7 +22,6 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
public class GeneralUtils {
private static final ScriptEngine SCRIPT_ENGINE = new ScriptEngineManager().getEngineByName("JavaScript");
public static boolean chance(int chance) {
return chance((double) chance);
@ -72,10 +68,10 @@ public class GeneralUtils {
public static ItemStack getHeldItem(LivingEntity entity, Event event) {
if (entity instanceof Player) {
Player player = (Player)entity;
Player player = (Player) entity;
int slot = getHeldItemSlot(player, event);
return player.getInventory().getItem(slot);
} else if (entity.getEquipment() != null){
} else if (entity.getEquipment() != null) {
ItemStack item = entity.getEquipment().getItemInHand();
try {
@ -90,7 +86,7 @@ public class GeneralUtils {
}
public static int getHeldItemSlot(Player entity, Event event) {
Player player = (Player)entity;
Player player = (Player) entity;
int slot = player.getInventory().getHeldItemSlot();
try {
@ -104,12 +100,7 @@ public class GeneralUtils {
}
public static Object parseJS(String toParse, String type, Object def) {
try {
return SCRIPT_ENGINE.eval(toParse);
} catch (ScriptException e) {
Bukkit.getLogger().warning("[EpicEnchants] One of your " + type + " expressions is not properly formatted.");
Bukkit.getLogger().warning(toParse);
return def;
}
return MathUtils.eval("[EpicEnchants] One of your " + type + " expressions is not properly formatted.", toParse);
}
}