Removed 1.15 support
This commit is contained in:
@@ -23,7 +23,6 @@ import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory;
|
||||
import com.willfp.eco.internal.factory.EcoRunnableFactory;
|
||||
import com.willfp.eco.internal.integration.PlaceholderIntegrationPAPI;
|
||||
import com.willfp.eco.internal.scheduling.EcoScheduler;
|
||||
import com.willfp.eco.util.Prerequisite;
|
||||
import lombok.Getter;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.util;
|
||||
package com.willfp.eco.core;
|
||||
|
||||
import com.willfp.eco.core.proxy.ProxyConstants;
|
||||
import com.willfp.eco.util.ClassUtils;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -14,15 +14,6 @@ public class Prerequisite {
|
||||
* All existing prerequisites are registered on creation.
|
||||
*/
|
||||
private static final List<Prerequisite> VALUES = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Requires the server to be running minecraft version 1.16 or higher.
|
||||
*/
|
||||
public static final Prerequisite MINIMUM_1_16 = new Prerequisite(
|
||||
() -> !ProxyConstants.NMS_VERSION.contains("15"),
|
||||
"Requires minimum server version of 1.16"
|
||||
);
|
||||
|
||||
/**
|
||||
* Requires the server to be running an implementation of paper.
|
||||
*/
|
||||
@@ -1,164 +0,0 @@
|
||||
package com.willfp.eco.core.fast;
|
||||
|
||||
import com.willfp.eco.internal.fast.AbstractFastItemStackHandler;
|
||||
import com.willfp.eco.internal.fast.FastItemStackHandlerFactory;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class FastItemStack {
|
||||
/**
|
||||
* The ItemStack handler.
|
||||
*/
|
||||
private static FastItemStackHandlerFactory factory;
|
||||
|
||||
/**
|
||||
* The ItemStack to interface with.
|
||||
*/
|
||||
private final AbstractFastItemStackHandler handle;
|
||||
|
||||
/**
|
||||
* Create a new fast ItemStack.
|
||||
*
|
||||
* @param itemStack The ItemStack.
|
||||
*/
|
||||
public FastItemStack(@NotNull final ItemStack itemStack) {
|
||||
this.handle = factory.create(itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enchantments on the item.
|
||||
*
|
||||
* @return The enchantments.
|
||||
*/
|
||||
public Map<Enchantment, Integer> getEnchantments() {
|
||||
return handle.getEnchantments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level of a specific enchantment.
|
||||
*
|
||||
* @param enchantment The enchantments.
|
||||
* @return The level, or 0 if not found.
|
||||
*/
|
||||
public int getEnchantmentLevel(@NotNull final Enchantment enchantment) {
|
||||
return handle.getEnchantmentLevel(enchantment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lore of an item.
|
||||
*
|
||||
* @return The lore.
|
||||
*/
|
||||
public List<String> getLore() {
|
||||
return handle.getLore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the lore of an item.
|
||||
*
|
||||
* @param lore The lore.
|
||||
*/
|
||||
public void setLore(@NotNull final List<String> lore) {
|
||||
handle.setLore(lore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item flags on an item.
|
||||
*
|
||||
* @return The item flags.
|
||||
*/
|
||||
public Set<ItemFlag> getItemFlags() {
|
||||
return handle.getItemFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item flags on an item.
|
||||
*
|
||||
* @param flags The flags.
|
||||
*/
|
||||
public void setItemFlags(@NotNull final Set<ItemFlag> flags) {
|
||||
handle.setItemFlags(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a key in persistent meta.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param type The type.
|
||||
* @param value The value.
|
||||
* @param <T> The type.
|
||||
* @param <Z> The type.
|
||||
*/
|
||||
public <T, Z> void writePersistentKey(@NotNull final NamespacedKey key,
|
||||
@NotNull final PersistentDataType<T, Z> type,
|
||||
@NotNull final Z value) {
|
||||
handle.writePersistentKey(key, type, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a key from persistent meta.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param type The type.
|
||||
* @param <T> The type.
|
||||
* @param <Z> The type.
|
||||
* @return The value.
|
||||
*/
|
||||
public <T, Z> Z readPersistentKey(@NotNull final NamespacedKey key,
|
||||
@NotNull final PersistentDataType<T, Z> type) {
|
||||
return handle.readPersistentKey(key, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get persistent meta keys.
|
||||
*
|
||||
* @return The keys.
|
||||
*/
|
||||
public Set<NamespacedKey> getPersistentKeys() {
|
||||
return handle.getPersistentKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name
|
||||
*
|
||||
* @return The display name.
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return handle.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display name.
|
||||
*
|
||||
* @param name The name.
|
||||
*/
|
||||
public void setDisplayName(@NotNull final String name) {
|
||||
handle.setDisplayName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply changes.
|
||||
*/
|
||||
public void apply() {
|
||||
handle.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the ItemStack handler factory.
|
||||
*
|
||||
* @param handlerFactory The handler factory.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void initialize(@NotNull final FastItemStackHandlerFactory handlerFactory) {
|
||||
factory = handlerFactory;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.willfp.eco.internal.fast;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface AbstractFastItemStackHandler {
|
||||
Map<Enchantment, Integer> getEnchantments();
|
||||
|
||||
int getEnchantmentLevel(@NotNull Enchantment enchantment);
|
||||
|
||||
List<String> getLore();
|
||||
|
||||
void setLore(@NotNull List<String> lore);
|
||||
|
||||
Set<ItemFlag> getItemFlags();
|
||||
|
||||
void setItemFlags(@NotNull Set<ItemFlag> flags);
|
||||
|
||||
<T, Z> void writePersistentKey(@NotNull NamespacedKey key,
|
||||
@NotNull PersistentDataType<T, Z> type,
|
||||
@NotNull Z value);
|
||||
|
||||
<T, Z> Z readPersistentKey(@NotNull NamespacedKey key,
|
||||
@NotNull PersistentDataType<T, Z> type);
|
||||
|
||||
Set<NamespacedKey> getPersistentKeys();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
void setDisplayName(@NotNull String name);
|
||||
|
||||
void apply();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.internal.fast;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface FastItemStackHandlerFactory {
|
||||
/**
|
||||
* Create new FastItemStackHandler.
|
||||
*
|
||||
* @param itemStack The ItemStack to handle.
|
||||
* @return The handler.
|
||||
*/
|
||||
AbstractFastItemStackHandler create(@NotNull ItemStack itemStack);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.willfp.eco.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@UtilityClass
|
||||
public class PlayerUtils {
|
||||
/**
|
||||
* If the meta set function has been set.
|
||||
*/
|
||||
private boolean initialized = false;
|
||||
|
||||
/**
|
||||
* The cooldown function.
|
||||
*/
|
||||
private Function<Player, Double> cooldownFunction = null;
|
||||
|
||||
/**
|
||||
* Get the attack cooldown for a player.
|
||||
*
|
||||
* @param player The player's attack cooldown.
|
||||
* @return A value between 0 and 1, with 1 representing full power.
|
||||
*/
|
||||
public double getAttackCooldown(@NotNull final Player player) {
|
||||
Validate.isTrue(initialized, "Must be initialized!");
|
||||
Validate.notNull(cooldownFunction, "Must be initialized!");
|
||||
|
||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
||||
return player.getAttackCooldown();
|
||||
}
|
||||
|
||||
return cooldownFunction.apply(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the cooldown function.
|
||||
*
|
||||
* @param function The function.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public void initialize(@NotNull final Function<Player, Double> function) {
|
||||
Validate.isTrue(!initialized, "Already initialized!");
|
||||
|
||||
cooldownFunction = function;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,7 @@ public class StringUtils {
|
||||
public String translate(@NotNull final String message,
|
||||
@Nullable final Player player) {
|
||||
String processedMessage = message;
|
||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
||||
processedMessage = translateGradients(processedMessage);
|
||||
}
|
||||
processedMessage = translateGradients(processedMessage);
|
||||
processedMessage = PlaceholderManager.translatePlaceholders(processedMessage, player);
|
||||
processedMessage = translateHexColorCodes(processedMessage);
|
||||
processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage);
|
||||
|
||||
@@ -79,9 +79,6 @@ public class TeamUtils {
|
||||
MATERIAL_COLORS.forcePut(Material.LAPIS_ORE, ChatColor.BLUE);
|
||||
MATERIAL_COLORS.forcePut(Material.REDSTONE_ORE, ChatColor.RED);
|
||||
MATERIAL_COLORS.forcePut(Material.DIAMOND_ORE, ChatColor.AQUA);
|
||||
|
||||
if (Prerequisite.MINIMUM_1_16.isMet()) {
|
||||
MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED);
|
||||
}
|
||||
MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user