mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Merge branch 'Auxilor:master' into master
This commit is contained in:
commit
25a9e34f84
@ -24,6 +24,7 @@ allprojects {
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
|
||||
maven { url 'https://oss.sonatype.org/content/groups/public/' }
|
||||
maven { url 'https://maven.enginehub.org/repo/' }
|
||||
maven { url 'https://repo.essentialsx.net/releases/' }
|
||||
maven { url 'https://ci.ender.zone/plugin/repository/project/' }
|
||||
maven { url 'https://ci.ender.zone/plugin/repository/everything/' }
|
||||
maven { url 'https://repo.md-5.net/content/repositories/snapshots/' }
|
||||
@ -48,7 +49,7 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.7.5'
|
||||
compileOnly 'com.willfp:eco:6.8.0'
|
||||
|
||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
<!-- Fields don't need javadoc -->
|
||||
<suppress files="EcoEnchants.java" checks="JavadocVariable"/>
|
||||
<suppress files="EnchantmentRequirements.java" checks="JavadocVariable"/>
|
||||
|
||||
<!-- Modified version of library -->
|
||||
<suppress files="ArmorEquipEvent.java" checks="JavadocVariable"/>
|
||||
|
@ -3,10 +3,10 @@ version rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly project(":eco-core:core-proxy")
|
||||
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
|
||||
compileOnly 'commons-io:commons-io:2.8.0'
|
||||
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
|
||||
compileOnly 'net.ess3:EssentialsX:2.18.1'
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT'
|
||||
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
|
||||
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
|
||||
}
|
@ -25,7 +25,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "deprecation"})
|
||||
public class CommandDebug extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants debug command handler.
|
||||
@ -102,7 +102,7 @@ public class CommandDebug extends Subcommand {
|
||||
|
||||
Set<EcoEnchant> withIssues = new HashSet<>();
|
||||
EcoEnchants.values().forEach(enchant -> {
|
||||
if (enchant.getRarity() == null) {
|
||||
if (enchant.getEnchantmentRarity() == null) {
|
||||
withIssues.add(enchant);
|
||||
}
|
||||
if (enchant.getTargets().isEmpty()) {
|
||||
|
@ -140,7 +140,7 @@ public class CommandEnchantinfo extends PluginCommand {
|
||||
|
||||
final String finalName = EnchantmentCache.getEntry(enchantment).getName();
|
||||
final String finalDescription = EnchantmentCache.getEntry(enchantment).getStringDescription(1);
|
||||
final EnchantmentRarity finalRarity = enchantment.getRarity();
|
||||
final EnchantmentRarity finalRarity = enchantment.getEnchantmentRarity();
|
||||
final String finalTargets = allTargets;
|
||||
final String finalConflicts = allConflicts;
|
||||
final String finalMaxLevel = maxLevel;
|
||||
|
@ -73,7 +73,7 @@ public class CommandGiverandombook extends Subcommand {
|
||||
if (!(enchantment instanceof EcoEnchant)) {
|
||||
return false;
|
||||
}
|
||||
return ((EcoEnchant) enchantment).getRarity().equals(rarity);
|
||||
return ((EcoEnchant) enchantment).getEnchantmentRarity().equals(rarity);
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -12,7 +12,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.enchantments.util.ItemConversionOptions;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -79,7 +78,7 @@ public class EnchantDisplay extends DisplayModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void display(@NotNull final ItemStack itemStack,
|
||||
public void display(@NotNull final ItemStack itemStack,
|
||||
@Nullable final Player player,
|
||||
@NotNull final Object... args) {
|
||||
if (options.isRequireTarget()) {
|
||||
@ -184,7 +183,7 @@ public class EnchantDisplay extends DisplayModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void revert(@NotNull final ItemStack itemStack) {
|
||||
public void revert(@NotNull final ItemStack itemStack) {
|
||||
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
|
||||
return;
|
||||
}
|
||||
@ -211,7 +210,7 @@ public class EnchantDisplay extends DisplayModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[] generateVarArgs(@NotNull final ItemStack itemStack) {
|
||||
public Object[] generateVarArgs(@NotNull final ItemStack itemStack) {
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (meta == null) {
|
||||
return new Object[]{false};
|
||||
|
@ -109,7 +109,7 @@ public class EnchantmentCache {
|
||||
description = StringUtils.formatList(ecoEnchant.getWrappedDescription());
|
||||
name = ecoEnchant.getDisplayName();
|
||||
type = ecoEnchant.getType();
|
||||
rarity = ecoEnchant.getRarity();
|
||||
rarity = ecoEnchant.getEnchantmentRarity();
|
||||
} else {
|
||||
description = Arrays.asList(
|
||||
WordUtils.wrap(
|
||||
|
@ -1,17 +1,20 @@
|
||||
package com.willfp.ecoenchants.enchantments;
|
||||
|
||||
import com.willfp.eco.core.Prerequisite;
|
||||
import com.willfp.eco.core.requirement.Requirement;
|
||||
import com.willfp.eco.core.requirement.Requirements;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
|
||||
import com.willfp.ecoenchants.display.EnchantmentCache;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirement;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirements;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.enchantments.util.PaperHelper;
|
||||
import com.willfp.ecoenchants.enchantments.util.Watcher;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,9 +22,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityCategory;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@ -140,7 +145,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
* The rarity of the enchantment.
|
||||
*/
|
||||
@Getter
|
||||
private EnchantmentRarity rarity;
|
||||
private EnchantmentRarity enchantmentRarity;
|
||||
|
||||
/**
|
||||
* If the enchantment is enabled.
|
||||
@ -156,7 +161,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
/**
|
||||
* All the requirements needed in order to use the enchantment.
|
||||
*/
|
||||
private final Map<EnchantmentRequirement, List<String>> requirements = new HashMap<>();
|
||||
private final Map<Requirement, List<String>> requirements = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Cached players to see if they meet requirements.
|
||||
@ -220,8 +225,8 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
*/
|
||||
public void update() {
|
||||
config.loadFromLang();
|
||||
rarity = config.getRarity();
|
||||
Validate.notNull(rarity, "Rarity specified in " + this.permissionName + " is invalid!");
|
||||
enchantmentRarity = config.getRarity();
|
||||
Validate.notNull(enchantmentRarity, "Rarity specified in " + this.permissionName + " is invalid!");
|
||||
conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts");
|
||||
grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable");
|
||||
availableFromTable = config.getBool(EcoEnchants.OBTAINING_LOCATION + "table");
|
||||
@ -233,7 +238,10 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
disabledWorldNames.clear();
|
||||
disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds"));
|
||||
disabledWorlds.clear();
|
||||
List<String> worldNames = Bukkit.getWorlds().stream().map(World::getName).map(String::toLowerCase).collect(Collectors.toList());
|
||||
List<String> worldNames = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
worldNames.add(world.getName().toLowerCase());
|
||||
}
|
||||
List<String> disabledExistingWorldNames = disabledWorldNames.stream().filter(s -> worldNames.contains(s.toLowerCase())).collect(Collectors.toList());
|
||||
disabledWorlds.addAll(Bukkit.getWorlds().stream().filter(world -> disabledExistingWorldNames.contains(world.getName().toLowerCase())).collect(Collectors.toList()));
|
||||
targets.clear();
|
||||
@ -250,11 +258,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
continue;
|
||||
}
|
||||
|
||||
EnchantmentRequirement requirement = EnchantmentRequirements.getByID(split.get(0).toLowerCase());
|
||||
|
||||
if (requirement == null) {
|
||||
continue;
|
||||
}
|
||||
Requirement requirement = Requirements.getByID(split.get(0).toLowerCase());
|
||||
|
||||
this.requirements.put(requirement, split.subList(1, split.size()));
|
||||
}
|
||||
@ -310,7 +314,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
return cachedRequirements.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
for (Map.Entry<EnchantmentRequirement, List<String>> entry : requirements.entrySet()) {
|
||||
for (Map.Entry<Requirement, List<String>> entry : requirements.entrySet()) {
|
||||
if (!entry.getKey().doesPlayerMeet(player, entry.getValue())) {
|
||||
cachedRequirements.put(player.getUniqueId(), false);
|
||||
return false;
|
||||
@ -443,4 +447,110 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
public boolean canEnchantItem(@NotNull final ItemStack itemStack) {
|
||||
return targetMaterials.contains(itemStack.getType()) || itemStack.getType().equals(Material.BOOK) || itemStack.getType().equals(Material.ENCHANTED_BOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* You should use EnchantmentCache instead.
|
||||
*
|
||||
* @param level The level.
|
||||
* @return The display name.
|
||||
* @deprecated Use {@link EnchantmentCache#getEntry(Enchantment)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NotNull Component displayName(final int level) {
|
||||
return PaperHelper.toComponent(EnchantmentCache.getEntry(this).getNameWithLevel(level));
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* You should use {@link EcoEnchant#isAvailableFromVillager()} instead.
|
||||
*
|
||||
* @return If tradeable.
|
||||
* @deprecated Use {@link EcoEnchant#isAvailableFromVillager()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return this.isAvailableFromVillager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* You should use {@link EcoEnchant#isAvailableFromLoot()} instead.
|
||||
*
|
||||
* @return If discoverable.
|
||||
* @deprecated Use {@link EcoEnchant#isAvailableFromLoot()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return this.isAvailableFromLoot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* EcoEnchants has its own systems for everything like this. Will always return 0.
|
||||
*
|
||||
* @param level The level.
|
||||
* @param entityCategory The category.
|
||||
* @return 0
|
||||
* @deprecated EcoEnchants has its own systems for this.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public float getDamageIncrease(final int level,
|
||||
@NotNull final EntityCategory entityCategory) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* EcoEnchants has its own systems for targets.
|
||||
* <p>
|
||||
* Use {@link EcoEnchant#getTargets()} instead.
|
||||
*
|
||||
* @return An empty set.
|
||||
* @deprecated Use {@link EcoEnchant#getTargets()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NotNull Set<EquipmentSlot> getActiveSlots() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* eco / EcoEnchants recodes display entirely.
|
||||
*
|
||||
* @return A translation key.
|
||||
* @deprecated Useless method, all items will be display differently using eco.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NotNull String translationKey() {
|
||||
return "ecoenchants:enchantment." + this.getKey().getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paper parity.
|
||||
* <p>
|
||||
* EcoEnchants has its own systems for rarity.
|
||||
* <p>
|
||||
* Use {@link EcoEnchant#getEnchantmentRarity()} instead.
|
||||
*
|
||||
* @return {@link io.papermc.paper.enchantments.EnchantmentRarity#COMMON}.
|
||||
* @deprecated Use {@link EcoEnchant#getEnchantmentRarity()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NotNull io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
|
||||
return io.papermc.paper.enchantments.EnchantmentRarity.COMMON;
|
||||
}
|
||||
}
|
||||
|
@ -108,18 +108,20 @@ public abstract class Artifact extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector point1 = player.getLocation().getDirection().clone();
|
||||
point1.rotateAroundY(Math.toRadians(90));
|
||||
point1.multiply(1.2);
|
||||
Location location1 = player.getLocation().clone().add(point1);
|
||||
this.getPlugin().getScheduler().runAsync(() -> {
|
||||
Vector point1 = player.getLocation().getDirection().clone();
|
||||
point1.rotateAroundY(Math.toRadians(90));
|
||||
point1.multiply(1.2);
|
||||
Location location1 = player.getLocation().clone().add(point1);
|
||||
|
||||
Vector point2 = player.getLocation().getDirection().clone();
|
||||
point2.rotateAroundY(Math.toRadians(-90));
|
||||
point2.multiply(1.2);
|
||||
Location location2 = player.getLocation().clone().add(point2);
|
||||
Vector point2 = player.getLocation().getDirection().clone();
|
||||
point2.rotateAroundY(Math.toRadians(-90));
|
||||
point2.multiply(1.2);
|
||||
Location location2 = player.getLocation().clone().add(point2);
|
||||
|
||||
player.getWorld().spawnParticle(particle, location1, 1, 0, 0, 0, 0, extra, true);
|
||||
player.getWorld().spawnParticle(particle, location2, 1, 0, 0, 0, 0, extra, true);
|
||||
player.getWorld().spawnParticle(particle, location1, 1, 0, 0, 0, 0, extra, true);
|
||||
player.getWorld().spawnParticle(particle, location2, 1, 0, 0, 0, 0, extra, true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,6 +180,6 @@ public abstract class Artifact extends EcoEnchant {
|
||||
bukkitRunnable.cancel();
|
||||
}
|
||||
projectile.getLocation().getWorld().spawnParticle(particle, projectile.getLocation(), 1, 0, 0, 0, finalColor, extra, true);
|
||||
}).runTaskTimer(4, ticks);
|
||||
}).runTaskTimerAsynchronously(4, ticks);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class Spell extends EcoEnchant {
|
||||
/**
|
||||
* Items that must be left-clicked to activate spells for.
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class EnchantmentRequirement {
|
||||
/**
|
||||
* The ID of the requirement.
|
||||
*/
|
||||
@Getter
|
||||
private final String id;
|
||||
|
||||
protected EnchantmentRequirement(@NotNull final String id) {
|
||||
this.id = id;
|
||||
|
||||
EnchantmentRequirements.addNewRequirement(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the player meets the requirement.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param args The arguments.
|
||||
* @return The requirement.
|
||||
*/
|
||||
public abstract boolean doesPlayerMeet(@NotNull Player player,
|
||||
@NotNull List<String> args);
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.requirements.RequirementHasPermission;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.requirements.RequirementPlaceholderEquals;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.requirements.RequirementPlaceholderGreaterThan;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.requirements.RequirementPlaceholderLessThan;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@UtilityClass
|
||||
@SuppressWarnings({"unused", "checkstyle:JavadocVariable"})
|
||||
public class EnchantmentRequirements {
|
||||
/**
|
||||
* All registered requirements.
|
||||
*/
|
||||
private static final BiMap<String, EnchantmentRequirement> BY_ID = HashBiMap.create();
|
||||
|
||||
public static final EnchantmentRequirement HAS_PERMISSION = new RequirementHasPermission();
|
||||
public static final EnchantmentRequirement PLACEHOLDER_EQUALS = new RequirementPlaceholderEquals();
|
||||
public static final EnchantmentRequirement PLACEHOLDER_GREATER_THAN = new RequirementPlaceholderGreaterThan();
|
||||
public static final EnchantmentRequirement PLACEHOLDER_LESS_THAN = new RequirementPlaceholderLessThan();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s.
|
||||
*
|
||||
* @return A list of all {@link EcoEnchant}s.
|
||||
*/
|
||||
public static List<EnchantmentRequirement> values() {
|
||||
return ImmutableList.copyOf(BY_ID.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link EnchantmentRequirement} matching ID.
|
||||
*
|
||||
* @param name The ID to search for.
|
||||
* @return The matching {@link EnchantmentRequirement}, or null if not found.
|
||||
*/
|
||||
public static EnchantmentRequirement getByID(@NotNull final String name) {
|
||||
return BY_ID.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new {@link EnchantmentRequirement} to EcoEnchants.
|
||||
* <p>
|
||||
* Only for internal use, requirements are automatically added in the constructor.
|
||||
*
|
||||
* @param req The {@link EnchantmentRequirement} to add.
|
||||
*/
|
||||
public static void addNewRequirement(@NotNull final EnchantmentRequirement req) {
|
||||
BY_ID.inverse().remove(req);
|
||||
BY_ID.put(req.getId(), req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove {@link EnchantmentRequirement} from EcoEnchants.
|
||||
*
|
||||
* @param req The {@link EnchantmentRequirement} to remove.
|
||||
*/
|
||||
public static void removeRequirement(@NotNull final EnchantmentRequirement req) {
|
||||
BY_ID.inverse().remove(req);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements.requirements;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirement;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequirementHasPermission extends EnchantmentRequirement {
|
||||
/**
|
||||
* Create new requirement.
|
||||
*/
|
||||
public RequirementHasPermission() {
|
||||
super("has-permission");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerMeet(@NotNull final Player player,
|
||||
@NotNull final List<String> args) {
|
||||
String permission = args.get(0);
|
||||
return player.hasPermission(permission);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements.requirements;
|
||||
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirement;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequirementPlaceholderEquals extends EnchantmentRequirement {
|
||||
/**
|
||||
* Create new requirement.
|
||||
*/
|
||||
public RequirementPlaceholderEquals() {
|
||||
super("placeholder-equals");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerMeet(@NotNull final Player player,
|
||||
@NotNull final List<String> args) {
|
||||
String placeholder = args.get(0);
|
||||
String equals = args.get(1);
|
||||
|
||||
return PlaceholderManager.translatePlaceholders(placeholder, player).equalsIgnoreCase(equals);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements.requirements;
|
||||
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirement;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequirementPlaceholderGreaterThan extends EnchantmentRequirement {
|
||||
/**
|
||||
* Create new requirement.
|
||||
*/
|
||||
public RequirementPlaceholderGreaterThan() {
|
||||
super("placeholder-greater-than");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerMeet(@NotNull final Player player,
|
||||
@NotNull final List<String> args) {
|
||||
String placeholder = args.get(0);
|
||||
double equals = Double.parseDouble(args.get(1));
|
||||
|
||||
try {
|
||||
return Double.parseDouble(PlaceholderManager.translatePlaceholders(placeholder, player)) >= equals;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.willfp.ecoenchants.enchantments.meta.requirements.requirements;
|
||||
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.ecoenchants.enchantments.meta.requirements.EnchantmentRequirement;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequirementPlaceholderLessThan extends EnchantmentRequirement {
|
||||
/**
|
||||
* Create new requirement.
|
||||
*/
|
||||
public RequirementPlaceholderLessThan() {
|
||||
super("placeholder-less-than");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerMeet(@NotNull final Player player,
|
||||
@NotNull final List<String> args) {
|
||||
String placeholder = args.get(0);
|
||||
double equals = Double.parseDouble(args.get(1));
|
||||
|
||||
try {
|
||||
return Double.parseDouble(PlaceholderManager.translatePlaceholders(placeholder, player)) < equals;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@UtilityClass
|
||||
public class AnvilMerge {
|
||||
/**
|
||||
|
@ -125,10 +125,10 @@ public class EnchantingListeners extends PluginDependent<EcoPlugin> implements L
|
||||
if (!enchantment.canEnchantItem(item)) {
|
||||
continue;
|
||||
}
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getTableProbability() * multiplier) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getEnchantmentRarity().getTableProbability() * multiplier) {
|
||||
continue;
|
||||
}
|
||||
if (enchantment.getRarity().getMinimumLevel() > cost) {
|
||||
if (enchantment.getEnchantmentRarity().getMinimumLevel() > cost) {
|
||||
continue;
|
||||
}
|
||||
if (!enchantment.isEnabled()) {
|
||||
@ -172,7 +172,7 @@ public class EnchantingListeners extends PluginDependent<EcoPlugin> implements L
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
} else {
|
||||
int maxLevel = this.getPlugin().getConfigYml().getInt("enchanting-table.maximum-obtainable-level");
|
||||
double enchantlevel1 = (cost / (double) enchantment.getRarity().getMinimumLevel()) / (maxLevel / (double) enchantment.getRarity().getMinimumLevel());
|
||||
double enchantlevel1 = (cost / (double) enchantment.getEnchantmentRarity().getMinimumLevel()) / (maxLevel / (double) enchantment.getEnchantmentRarity().getMinimumLevel());
|
||||
double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1);
|
||||
double enchantlevel3 = 1 / maxLevelDouble;
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
|
@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LootPopulator extends BlockPopulator {
|
||||
/**
|
||||
* Instance of ecoenchants.
|
||||
@ -92,11 +93,11 @@ public class LootPopulator extends BlockPopulator {
|
||||
int cap = 0;
|
||||
|
||||
for (EcoEnchant enchantment : enchantments) {
|
||||
if (enchantment == null || enchantment.getRarity() == null) {
|
||||
if (enchantment == null || enchantment.getEnchantmentRarity() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getLootProbability() * multiplier) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getEnchantmentRarity().getLootProbability() * multiplier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class VillagerListeners extends PluginDependent<EcoPlugin> implements Lis
|
||||
EcoEnchant applied = null;
|
||||
|
||||
for (EcoEnchant enchantment : enchantments) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getEnchantmentRarity().getVillagerProbability() * multiplier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ public class VillagerListeners extends PluginDependent<EcoPlugin> implements Lis
|
||||
double multiplier = 0.01;
|
||||
|
||||
for (EcoEnchant enchantment : enchantments) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) {
|
||||
if (NumberUtils.randFloat(0, 1) > enchantment.getEnchantmentRarity().getVillagerProbability() * multiplier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ItemConversions extends PluginDependent<EcoPlugin> implements Listener {
|
||||
/**
|
||||
* Pass an {@link EcoPlugin} in order to interface with it.
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.willfp.ecoenchants.enchantments.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@UtilityClass
|
||||
public class PaperHelper {
|
||||
private static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.character('§')
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Convert string to a component.
|
||||
*
|
||||
* @param string The string.
|
||||
* @return The component.
|
||||
*/
|
||||
public static Component toComponent(@NotNull final String string) {
|
||||
return SERIALIZER.deserialize(string);
|
||||
}
|
||||
}
|
@ -9,17 +9,12 @@ import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class IntegrationEssentials implements RegistrationWrapper {
|
||||
@Override
|
||||
public void registerAllEnchantments() {
|
||||
try {
|
||||
for (EcoEnchant enchantment : EcoEnchants.values()) {
|
||||
((Map<String, Enchantment>) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getKey().getKey(), enchantment);
|
||||
((Map<String, Enchantment>) FieldUtils.readDeclaredStaticField(Enchantments.class, "ENCHANTMENTS", true)).put(enchantment.getPermissionName(), enchantment);
|
||||
}
|
||||
} catch (IllegalAccessException ignored) {
|
||||
// Ignore reflective errors that won't happen.
|
||||
for (EcoEnchant enchantment : EcoEnchants.values()) {
|
||||
Enchantments.registerEnchantment(enchantment.getKey().getKey(), enchantment);
|
||||
Enchantments.registerAlias(enchantment.getPermissionName(), enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
version = 8.10.13
|
||||
version = 8.11.0
|
||||
plugin-name = EcoEnchants
|
Loading…
Reference in New Issue
Block a user