Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
109347a601 | ||
|
|
43bef762bf | ||
|
|
69a2e0e247 | ||
|
|
874a9b4f32 | ||
|
|
5690221c27 | ||
|
|
f19b143804 | ||
|
|
10a313bef5 | ||
|
|
9ae40ae09e | ||
|
|
7b4e1d8d24 | ||
|
|
7035280731 | ||
|
|
a1e3d53cd2 | ||
|
|
d7885f05c3 | ||
|
|
415c425097 | ||
|
|
cb4d992e7d | ||
|
|
cb64d088d1 | ||
|
|
bbbf19c041 |
@@ -305,10 +305,27 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
this.logger = Eco.getHandler().createLogger(this);
|
this.logger = Eco.getHandler().createLogger(this);
|
||||||
this.proxyFactory = this.proxyPackage.equalsIgnoreCase("") ? null : Eco.getHandler().createProxyFactory(this);
|
this.proxyFactory = this.proxyPackage.equalsIgnoreCase("") ? null : Eco.getHandler().createProxyFactory(this);
|
||||||
|
|
||||||
this.langYml = new LangYml(this);
|
this.langYml = this.createLangYml();
|
||||||
this.configYml = new ConfigYml(this);
|
this.configYml = this.createConfigYml();
|
||||||
|
|
||||||
Eco.getHandler().addNewPlugin(this);
|
Eco.getHandler().addNewPlugin(this);
|
||||||
|
|
||||||
|
/*
|
||||||
|
The minimum eco version check was moved here because it's very common
|
||||||
|
to add a lot of code in the constructor of plugins; meaning that the plugin
|
||||||
|
can throw errors without it being obvious to the user that the reason is
|
||||||
|
because they have an outdated version of eco installed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DefaultArtifactVersion runningVersion = new DefaultArtifactVersion(Eco.getHandler().getEcoPlugin().getDescription().getVersion());
|
||||||
|
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(this.getMinimumEcoVersion());
|
||||||
|
if (!(runningVersion.compareTo(requiredVersion) > 0 || runningVersion.equals(requiredVersion))) {
|
||||||
|
this.getLogger().severe("You are running an outdated version of eco!");
|
||||||
|
this.getLogger().severe("You must be on at least" + this.getMinimumEcoVersion());
|
||||||
|
this.getLogger().severe("Download the newest version here:");
|
||||||
|
this.getLogger().severe("https://polymart.org/download/773/recent/JSpprMspkuyecf5y1wQ2Jn8OoLQSQ_IW");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,16 +353,6 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultArtifactVersion runningVersion = new DefaultArtifactVersion(Eco.getHandler().getEcoPlugin().getDescription().getVersion());
|
|
||||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(this.getMinimumEcoVersion());
|
|
||||||
if (!(runningVersion.compareTo(requiredVersion) > 0 || runningVersion.equals(requiredVersion))) {
|
|
||||||
this.getLogger().severe("You are running an outdated version of eco!");
|
|
||||||
this.getLogger().severe("You must be on at least" + this.getMinimumEcoVersion());
|
|
||||||
this.getLogger().severe("Download the newest version here:");
|
|
||||||
this.getLogger().severe("https://polymart.org/download/773/recent/JSpprMspkuyecf5y1wQ2Jn8OoLQSQ_IW");
|
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getBStatsId() != 0) {
|
if (this.getBStatsId() != 0) {
|
||||||
Eco.getHandler().registerBStats(this);
|
Eco.getHandler().registerBStats(this);
|
||||||
}
|
}
|
||||||
@@ -571,6 +578,28 @@ public abstract class EcoPlugin extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
protected abstract List<Listener> loadListeners();
|
protected abstract List<Listener> loadListeners();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Useful for custom LangYml implementations.
|
||||||
|
* <p>
|
||||||
|
* Override if needed.
|
||||||
|
*
|
||||||
|
* @return lang.yml.
|
||||||
|
*/
|
||||||
|
protected LangYml createLangYml() {
|
||||||
|
return new LangYml(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Useful for custom ConfigYml implementations.
|
||||||
|
* <p>
|
||||||
|
* Override if needed.
|
||||||
|
*
|
||||||
|
* @return config.yml.
|
||||||
|
*/
|
||||||
|
protected ConfigYml createConfigYml() {
|
||||||
|
return new ConfigYml(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the display module for the plugin.
|
* Create the display module for the plugin.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.willfp.eco.core.proxy.ProxyFactory;
|
|||||||
import com.willfp.eco.core.scheduling.Scheduler;
|
import com.willfp.eco.core.scheduling.Scheduler;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -30,6 +31,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The scheduler.
|
* @return The scheduler.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
Scheduler createScheduler(@NotNull EcoPlugin plugin);
|
Scheduler createScheduler(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +40,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The event manager.
|
* @return The event manager.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
EventManager createEventManager(@NotNull EcoPlugin plugin);
|
EventManager createEventManager(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +49,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
NamespacedKeyFactory createNamespacedKeyFactory(@NotNull EcoPlugin plugin);
|
NamespacedKeyFactory createNamespacedKeyFactory(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,6 +58,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
MetadataValueFactory createMetadataValueFactory(@NotNull EcoPlugin plugin);
|
MetadataValueFactory createMetadataValueFactory(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,6 +67,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
RunnableFactory createRunnableFactory(@NotNull EcoPlugin plugin);
|
RunnableFactory createRunnableFactory(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +76,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
ExtensionLoader createExtensionLoader(@NotNull EcoPlugin plugin);
|
ExtensionLoader createExtensionLoader(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,6 +85,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The handler.
|
* @return The handler.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
ConfigHandler createConfigHandler(@NotNull EcoPlugin plugin);
|
ConfigHandler createConfigHandler(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,6 +94,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The logger.
|
* @return The logger.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
Logger createLogger(@NotNull EcoPlugin plugin);
|
Logger createLogger(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +103,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The integration.
|
* @return The integration.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
PlaceholderIntegration createPAPIIntegration(@NotNull EcoPlugin plugin);
|
PlaceholderIntegration createPAPIIntegration(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,6 +112,7 @@ public interface Handler {
|
|||||||
* @param plugin The plugin.
|
* @param plugin The plugin.
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
ProxyFactory createProxyFactory(@NotNull EcoPlugin plugin);
|
ProxyFactory createProxyFactory(@NotNull EcoPlugin plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,6 +120,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return The plugin.
|
* @return The plugin.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
EcoPlugin getEcoPlugin();
|
EcoPlugin getEcoPlugin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,6 +128,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
ConfigFactory getConfigFactory();
|
ConfigFactory getConfigFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,6 +136,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
DropQueueFactory getDropQueueFactory();
|
DropQueueFactory getDropQueueFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,6 +144,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return The factory.
|
* @return The factory.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
GUIFactory getGUIFactory();
|
GUIFactory getGUIFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +152,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return The cleaner.
|
* @return The cleaner.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
Cleaner getCleaner();
|
Cleaner getCleaner();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,6 +168,7 @@ public interface Handler {
|
|||||||
* @param name The name.
|
* @param name The name.
|
||||||
* @return The plugin.
|
* @return The plugin.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
EcoPlugin getPluginByName(@NotNull String name);
|
EcoPlugin getPluginByName(@NotNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,6 +176,7 @@ public interface Handler {
|
|||||||
*
|
*
|
||||||
* @return A list of plugin names in lowercase.
|
* @return A list of plugin names in lowercase.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
List<String> getLoadedPlugins();
|
List<String> getLoadedPlugins();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,6 +185,7 @@ public interface Handler {
|
|||||||
* @param itemStack The base ItemStack.
|
* @param itemStack The base ItemStack.
|
||||||
* @return The FastItemStack.
|
* @return The FastItemStack.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
FastItemStack createFastItemStack(@NotNull ItemStack itemStack);
|
FastItemStack createFastItemStack(@NotNull ItemStack itemStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*
|
*
|
||||||
* @param <T> The eco plugin type.
|
* @param <T> The eco plugin type.
|
||||||
*/
|
*/
|
||||||
public abstract class PluginDependent<T extends EcoPlugin> {
|
public abstract class PluginDependent<@NotNull T extends EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* The {@link EcoPlugin} that is stored.
|
* The {@link EcoPlugin} that is stored.
|
||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
@NotNull
|
||||||
private final T plugin;
|
private final T plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@@ -18,7 +20,7 @@ public class PlaceholderManager {
|
|||||||
/**
|
/**
|
||||||
* All registered placeholders.
|
* All registered placeholders.
|
||||||
*/
|
*/
|
||||||
private static final Set<PlaceholderEntry> REGISTERED_PLACEHOLDERS = new HashSet<>();
|
private static final Map<String, PlaceholderEntry> REGISTERED_PLACEHOLDERS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All registered placeholder integrations.
|
* All registered placeholder integrations.
|
||||||
@@ -41,8 +43,8 @@ public class PlaceholderManager {
|
|||||||
* @param expansion The {@link PlaceholderEntry} to register.
|
* @param expansion The {@link PlaceholderEntry} to register.
|
||||||
*/
|
*/
|
||||||
public static void registerPlaceholder(@NotNull final PlaceholderEntry expansion) {
|
public static void registerPlaceholder(@NotNull final PlaceholderEntry expansion) {
|
||||||
REGISTERED_PLACEHOLDERS.removeIf(placeholderEntry -> placeholderEntry.getIdentifier().equalsIgnoreCase(expansion.getIdentifier()));
|
REGISTERED_PLACEHOLDERS.remove(expansion.getIdentifier());
|
||||||
REGISTERED_PLACEHOLDERS.add(expansion);
|
REGISTERED_PLACEHOLDERS.put(expansion.getIdentifier(), expansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,14 +56,15 @@ public class PlaceholderManager {
|
|||||||
*/
|
*/
|
||||||
public static String getResult(@Nullable final Player player,
|
public static String getResult(@Nullable final Player player,
|
||||||
@NotNull final String identifier) {
|
@NotNull final String identifier) {
|
||||||
Optional<PlaceholderEntry> matching = REGISTERED_PLACEHOLDERS.stream().filter(expansion -> expansion.getIdentifier().equalsIgnoreCase(identifier)).findFirst();
|
PlaceholderEntry entry = REGISTERED_PLACEHOLDERS.get(identifier.toLowerCase());
|
||||||
if (matching.isEmpty()) {
|
if (entry == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
PlaceholderEntry entry = matching.get();
|
|
||||||
if (player == null && entry.requiresPlayer()) {
|
if (player == null && entry.requiresPlayer()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry.getResult(player);
|
return entry.getResult(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +77,10 @@ public class PlaceholderManager {
|
|||||||
*/
|
*/
|
||||||
public static String translatePlaceholders(@NotNull final String text,
|
public static String translatePlaceholders(@NotNull final String text,
|
||||||
@Nullable final Player player) {
|
@Nullable final Player player) {
|
||||||
AtomicReference<String> translatedReference = new AtomicReference<>(text);
|
String processed = text;
|
||||||
REGISTERED_INTEGRATIONS.forEach(placeholderIntegration -> translatedReference.set(placeholderIntegration.translate(translatedReference.get(), player)));
|
for (PlaceholderIntegration integration : REGISTERED_INTEGRATIONS) {
|
||||||
return translatedReference.get();
|
processed = integration.translate(processed, player);
|
||||||
|
}
|
||||||
|
return processed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.willfp.eco.core.items;
|
package com.willfp.eco.core.items;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.Eco;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -47,6 +50,12 @@ public class CustomItem implements TestableItem {
|
|||||||
this.key = key;
|
this.key = key;
|
||||||
this.test = test;
|
this.test = test;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
|
||||||
|
Eco.getHandler().getEcoPlugin().getScheduler().runLater(() -> {
|
||||||
|
if (!matches(getItem())) {
|
||||||
|
Bukkit.getLogger().severe("Item with key " + key + " is invalid!");
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ public final class Items {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
// Marked as redundant but i am covering all bases here
|
||||||
|
if (item == null || item instanceof EmptyTestableItem) {
|
||||||
return new EmptyTestableItem();
|
return new EmptyTestableItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +178,10 @@ public final class Items {
|
|||||||
List<Predicate<ItemStack>> predicates = new ArrayList<>();
|
List<Predicate<ItemStack>> predicates = new ArrayList<>();
|
||||||
|
|
||||||
for (LookupArgParser argParser : ARG_PARSERS) {
|
for (LookupArgParser argParser : ARG_PARSERS) {
|
||||||
predicates.add(argParser.parseArguments(modifierArgs, meta));
|
Predicate<ItemStack> predicate = argParser.parseArguments(modifierArgs, meta);
|
||||||
|
if (predicate != null) {
|
||||||
|
predicates.add(argParser.parseArguments(modifierArgs, meta));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
example.setItemMeta(meta);
|
example.setItemMeta(meta);
|
||||||
@@ -197,7 +201,7 @@ public final class Items {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stackAmount == 1) {
|
if (stackAmount <= 1) {
|
||||||
return item;
|
return item;
|
||||||
} else {
|
} else {
|
||||||
return new TestableStack(item, stackAmount);
|
return new TestableStack(item, stackAmount);
|
||||||
|
|||||||
@@ -6,15 +6,19 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses enchantment arguments.
|
||||||
|
*/
|
||||||
public class EnchantmentArgParser implements LookupArgParser {
|
public class EnchantmentArgParser implements LookupArgParser {
|
||||||
@Override
|
@Override
|
||||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
@NotNull final ItemMeta meta) {
|
@NotNull final ItemMeta meta) {
|
||||||
Map<Enchantment, Integer> requiredEnchantments = new HashMap<>();
|
Map<Enchantment, Integer> requiredEnchantments = new HashMap<>();
|
||||||
|
|
||||||
for (String enchantArg : args) {
|
for (String enchantArg : args) {
|
||||||
@@ -34,6 +38,10 @@ public class EnchantmentArgParser implements LookupArgParser {
|
|||||||
requiredEnchantments.put(enchantment, level);
|
requiredEnchantments.put(enchantment, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requiredEnchantments.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
||||||
requiredEnchantments.forEach((enchantment, integer) -> storageMeta.addStoredEnchant(enchantment, integer, true));
|
requiredEnchantments.forEach((enchantment, integer) -> storageMeta.addStoredEnchant(enchantment, integer, true));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,20 +4,22 @@ import com.willfp.eco.core.items.TestableItem;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An argument parser should generate the predicate as well
|
||||||
|
* as modify the ItemMeta for {@link TestableItem#getItem()}.
|
||||||
|
*/
|
||||||
public interface LookupArgParser {
|
public interface LookupArgParser {
|
||||||
/**
|
/**
|
||||||
* Parse the arguments.
|
* Parse the arguments.
|
||||||
* <p>
|
|
||||||
* An argument parser should generate the predicate as well
|
|
||||||
* as modify the ItemMeta for {@link TestableItem#getItem()}
|
|
||||||
*
|
*
|
||||||
* @param args The arguments.
|
* @param args The arguments.
|
||||||
* @param meta The ItemMeta to modify.
|
* @param meta The ItemMeta to modify.
|
||||||
* @return The predicate test to apply to the modified item.
|
* @return The predicate test to apply to the modified item.
|
||||||
*/
|
*/
|
||||||
Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
@Nullable Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
||||||
@NotNull ItemMeta meta);
|
@NotNull ItemMeta meta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,17 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse skull textures.
|
||||||
|
*/
|
||||||
public class TextureArgParser implements LookupArgParser {
|
public class TextureArgParser implements LookupArgParser {
|
||||||
@Override
|
@Override
|
||||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
@NotNull final ItemMeta meta) {
|
@NotNull final ItemMeta meta) {
|
||||||
String skullTexture = null;
|
String skullTexture = null;
|
||||||
|
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
@@ -31,6 +35,10 @@ public class TextureArgParser implements LookupArgParser {
|
|||||||
SkullUtils.setSkullTexture(skullMeta, skullTexture);
|
SkullUtils.setSkullTexture(skullMeta, skullTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skullTexture == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String finalSkullTexture = skullTexture;
|
String finalSkullTexture = skullTexture;
|
||||||
return test -> {
|
return test -> {
|
||||||
if (!test.hasItemMeta()) {
|
if (!test.hasItemMeta()) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.recipe.parts;
|
|||||||
|
|
||||||
import com.willfp.eco.core.items.TestableItem;
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -23,6 +24,8 @@ public class MaterialTestableItem implements TestableItem {
|
|||||||
* @param material The material.
|
* @param material The material.
|
||||||
*/
|
*/
|
||||||
public MaterialTestableItem(@NotNull final Material material) {
|
public MaterialTestableItem(@NotNull final Material material) {
|
||||||
|
Validate.isTrue(material != Material.AIR, "You can't have air as the type!");
|
||||||
|
|
||||||
this.material = material;
|
this.material = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.recipe.parts;
|
|||||||
|
|
||||||
import com.willfp.eco.core.items.TestableItem;
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ public class TestableStack implements TestableItem {
|
|||||||
*/
|
*/
|
||||||
public TestableStack(@NotNull final TestableItem item,
|
public TestableStack(@NotNull final TestableItem item,
|
||||||
final int amount) {
|
final int amount) {
|
||||||
Validate.isTrue(!(item instanceof TestableStack));
|
Validate.isTrue(!(item instanceof TestableStack), "You can't stack a stack!");
|
||||||
|
Validate.isTrue(!(item instanceof EmptyTestableItem), "You can't stack air!");
|
||||||
|
|
||||||
this.handle = item;
|
this.handle = item;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
|||||||
ShapedRecipe shapedRecipe = new ShapedRecipe(this.getKey(), this.getOutput());
|
ShapedRecipe shapedRecipe = new ShapedRecipe(this.getKey(), this.getOutput());
|
||||||
shapedRecipe.shape("012", "345", "678");
|
shapedRecipe.shape("012", "345", "678");
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
|
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char character = String.valueOf(i).toCharArray()[0];
|
char character = String.valueOf(i).toCharArray()[0];
|
||||||
shapedRecipe.setIngredient(character, parts.get(i).getItem().getType());
|
shapedRecipe.setIngredient(character, parts.get(i).getItem().getType());
|
||||||
}
|
}
|
||||||
@@ -89,6 +93,10 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
|||||||
ShapedRecipe displayedRecipe = new ShapedRecipe(this.getDisplayedKey(), this.getOutput());
|
ShapedRecipe displayedRecipe = new ShapedRecipe(this.getDisplayedKey(), this.getOutput());
|
||||||
displayedRecipe.shape("012", "345", "678");
|
displayedRecipe.shape("012", "345", "678");
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
|
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char character = String.valueOf(i).toCharArray()[0];
|
char character = String.valueOf(i).toCharArray()[0];
|
||||||
ItemStack item = parts.get(i).getItem();
|
ItemStack item = parts.get(i).getItem();
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class ArrowUtils {
|
|||||||
* Get the bow from an arrow.
|
* Get the bow from an arrow.
|
||||||
*
|
*
|
||||||
* @param arrow The arrow.
|
* @param arrow The arrow.
|
||||||
* @return The bow.
|
* @return The bow, or null if no bow.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemStack getBow(@NotNull final Arrow arrow) {
|
public ItemStack getBow(@NotNull final Arrow arrow) {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public class BlockUtils {
|
|||||||
* @param limit The maximum size of vein to return.
|
* @param limit The maximum size of vein to return.
|
||||||
* @return A set of all {@link Block}s.
|
* @return A set of all {@link Block}s.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Set<Block> getVein(@NotNull final Block start,
|
public Set<Block> getVein(@NotNull final Block start,
|
||||||
@NotNull final List<Material> allowedMaterials,
|
@NotNull final List<Material> allowedMaterials,
|
||||||
final int limit) {
|
final int limit) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,8 +20,9 @@ public class ListUtils {
|
|||||||
* @param <T> The type of the object stored in the list.
|
* @param <T> The type of the object stored in the list.
|
||||||
* @return The list, filled will null objects.
|
* @return The list, filled will null objects.
|
||||||
*/
|
*/
|
||||||
public <T> List<List<T>> create2DList(final int rows,
|
@NotNull
|
||||||
final int columns) {
|
public <@Nullable T> List<List<T>> create2DList(final int rows,
|
||||||
|
final int columns) {
|
||||||
List<List<T>> list = new ArrayList<>(rows);
|
List<List<T>> list = new ArrayList<>(rows);
|
||||||
while (list.size() < rows) {
|
while (list.size() < rows) {
|
||||||
List<T> row = new ArrayList<>(columns);
|
List<T> row = new ArrayList<>(columns);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.willfp.eco.util;
|
|||||||
|
|
||||||
import com.willfp.eco.core.tuples.Pair;
|
import com.willfp.eco.core.tuples.Pair;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities / API methods for menus.
|
* Utilities / API methods for menus.
|
||||||
@@ -14,6 +15,7 @@ public class MenuUtils {
|
|||||||
* @param slot The slot.
|
* @param slot The slot.
|
||||||
* @return The pair of row and columns.
|
* @return The pair of row and columns.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Pair<Integer, Integer> convertSlotToRowColumn(final int slot) {
|
public Pair<Integer, Integer> convertSlotToRowColumn(final int slot) {
|
||||||
int row = Math.floorDiv(slot, 9);
|
int row = Math.floorDiv(slot, 9);
|
||||||
int column = slot - row * 9;
|
int column = slot - row * 9;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class NamespacedKeyUtils {
|
|||||||
* @param string The string.
|
* @param string The string.
|
||||||
* @return The key.
|
* @return The key.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public NamespacedKey createEcoKey(@NotNull final String string) {
|
public NamespacedKey createEcoKey(@NotNull final String string) {
|
||||||
return Objects.requireNonNull(NamespacedKey.fromString("eco:" + string));
|
return Objects.requireNonNull(NamespacedKey.fromString("eco:" + string));
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,7 @@ public class NamespacedKeyUtils {
|
|||||||
* @param key The key.
|
* @param key The key.
|
||||||
* @return The key.
|
* @return The key.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public NamespacedKey create(@NotNull final String namespace,
|
public NamespacedKey create(@NotNull final String namespace,
|
||||||
@NotNull final String key) {
|
@NotNull final String key) {
|
||||||
return Objects.requireNonNull(NamespacedKey.fromString(namespace + ":" + key));
|
return Objects.requireNonNull(NamespacedKey.fromString(namespace + ":" + key));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
|
import lombok.experimental.NonFinal;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -109,6 +110,7 @@ public class NumberUtils {
|
|||||||
* @param number The number to convert.
|
* @param number The number to convert.
|
||||||
* @return The number, converted to a roman numeral.
|
* @return The number, converted to a roman numeral.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String toNumeral(final int number) {
|
public String toNumeral(final int number) {
|
||||||
if (number >= 1 && number <= 4096) {
|
if (number >= 1 && number <= 4096) {
|
||||||
int l = NUMERALS.floorKey(number);
|
int l = NUMERALS.floorKey(number);
|
||||||
@@ -199,6 +201,7 @@ public class NumberUtils {
|
|||||||
* @param toFormat The number to format.
|
* @param toFormat The number to format.
|
||||||
* @return Formatted.
|
* @return Formatted.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String format(final double toFormat) {
|
public String format(final double toFormat) {
|
||||||
DecimalFormat df = new DecimalFormat("0.00");
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
String formatted = df.format(toFormat);
|
String formatted = df.format(toFormat);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.apache.commons.lang.Validate;
|
|||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -47,8 +48,9 @@ public class SkullUtils {
|
|||||||
* Get the texture of a skull - in base64.
|
* Get the texture of a skull - in base64.
|
||||||
*
|
*
|
||||||
* @param meta The meta to modify.
|
* @param meta The meta to modify.
|
||||||
* @return The texture.
|
* @return The texture, potentially null.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getSkullTexture(@NotNull final SkullMeta meta) {
|
public String getSkullTexture(@NotNull final SkullMeta meta) {
|
||||||
Validate.isTrue(initialized, "Must be initialized!");
|
Validate.isTrue(initialized, "Must be initialized!");
|
||||||
Validate.notNull(metaGetConsumer, "Must be initialized!");
|
Validate.notNull(metaGetConsumer, "Must be initialized!");
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class StringUtils {
|
|||||||
* @param list The messages to format.
|
* @param list The messages to format.
|
||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public List<String> formatList(@NotNull final List<String> list) {
|
public List<String> formatList(@NotNull final List<String> list) {
|
||||||
return formatList(list, (Player) null);
|
return formatList(list, (Player) null);
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,7 @@ public class StringUtils {
|
|||||||
* @param player The player to translate placeholders with respect to.
|
* @param player The player to translate placeholders with respect to.
|
||||||
* @return The message, format.
|
* @return The message, format.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public List<String> formatList(@NotNull final List<String> list,
|
public List<String> formatList(@NotNull final List<String> list,
|
||||||
@Nullable final Player player) {
|
@Nullable final Player player) {
|
||||||
return formatList(list, player, FormatOption.WITH_PLACEHOLDERS);
|
return formatList(list, player, FormatOption.WITH_PLACEHOLDERS);
|
||||||
@@ -91,6 +93,7 @@ public class StringUtils {
|
|||||||
* @param option The format option.
|
* @param option The format option.
|
||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public List<String> formatList(@NotNull final List<String> list,
|
public List<String> formatList(@NotNull final List<String> list,
|
||||||
@NotNull final FormatOption option) {
|
@NotNull final FormatOption option) {
|
||||||
return formatList(list, null, option);
|
return formatList(list, null, option);
|
||||||
@@ -106,6 +109,7 @@ public class StringUtils {
|
|||||||
* @param option The options.
|
* @param option The options.
|
||||||
* @return The message, format.
|
* @return The message, format.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public List<String> formatList(@NotNull final List<String> list,
|
public List<String> formatList(@NotNull final List<String> list,
|
||||||
@Nullable final Player player,
|
@Nullable final Player player,
|
||||||
@NotNull final FormatOption option) {
|
@NotNull final FormatOption option) {
|
||||||
@@ -126,6 +130,7 @@ public class StringUtils {
|
|||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
* @see StringUtils#format(String, Player)
|
* @see StringUtils#format(String, Player)
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String format(@NotNull final String message) {
|
public String format(@NotNull final String message) {
|
||||||
return format(message, (Player) null);
|
return format(message, (Player) null);
|
||||||
}
|
}
|
||||||
@@ -139,6 +144,7 @@ public class StringUtils {
|
|||||||
* @param player The player to translate placeholders with respect to.
|
* @param player The player to translate placeholders with respect to.
|
||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String format(@NotNull final String message,
|
public String format(@NotNull final String message,
|
||||||
@Nullable final Player player) {
|
@Nullable final Player player) {
|
||||||
return format(message, player, FormatOption.WITH_PLACEHOLDERS);
|
return format(message, player, FormatOption.WITH_PLACEHOLDERS);
|
||||||
@@ -154,6 +160,7 @@ public class StringUtils {
|
|||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
* @see StringUtils#format(String, Player)
|
* @see StringUtils#format(String, Player)
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String format(@NotNull final String message,
|
public String format(@NotNull final String message,
|
||||||
@NotNull final FormatOption option) {
|
@NotNull final FormatOption option) {
|
||||||
return format(message, null, option);
|
return format(message, null, option);
|
||||||
@@ -169,6 +176,7 @@ public class StringUtils {
|
|||||||
* @param option The format options.
|
* @param option The format options.
|
||||||
* @return The message, formatted.
|
* @return The message, formatted.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String format(@NotNull final String message,
|
public String format(@NotNull final String message,
|
||||||
@Nullable final Player player,
|
@Nullable final Player player,
|
||||||
@NotNull final FormatOption option) {
|
@NotNull final FormatOption option) {
|
||||||
@@ -284,6 +292,7 @@ public class StringUtils {
|
|||||||
* @param object The object to convert to string.
|
* @param object The object to convert to string.
|
||||||
* @return The object stringified.
|
* @return The object stringified.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String internalToString(@Nullable final Object object) {
|
public String internalToString(@Nullable final Object object) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return "null";
|
return "null";
|
||||||
@@ -309,6 +318,7 @@ public class StringUtils {
|
|||||||
* @param prefix The substring to remove.
|
* @param prefix The substring to remove.
|
||||||
* @return The string with the prefix removed.
|
* @return The string with the prefix removed.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String removePrefix(@NotNull final String string,
|
public String removePrefix(@NotNull final String string,
|
||||||
@NotNull final String prefix) {
|
@NotNull final String prefix) {
|
||||||
if (string.startsWith(prefix)) {
|
if (string.startsWith(prefix)) {
|
||||||
@@ -323,6 +333,7 @@ public class StringUtils {
|
|||||||
* @param legacy The legacy string.
|
* @param legacy The legacy string.
|
||||||
* @return The JSON String.
|
* @return The JSON String.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String legacyToJson(@NotNull final String legacy) {
|
public String legacyToJson(@NotNull final String legacy) {
|
||||||
return GsonComponentSerializer.gson().serialize(
|
return GsonComponentSerializer.gson().serialize(
|
||||||
Component.empty().decoration(TextDecoration.ITALIC, false).append(
|
Component.empty().decoration(TextDecoration.ITALIC, false).append(
|
||||||
@@ -337,6 +348,7 @@ public class StringUtils {
|
|||||||
* @param json The JSON string.
|
* @param json The JSON string.
|
||||||
* @return The legacy string.
|
* @return The legacy string.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public String jsonToLegacy(@NotNull final String json) {
|
public String jsonToLegacy(@NotNull final String json) {
|
||||||
return LEGACY_COMPONENT_SERIALIZER.serialize(
|
return LEGACY_COMPONENT_SERIALIZER.serialize(
|
||||||
GsonComponentSerializer.gson().deserialize(json)
|
GsonComponentSerializer.gson().deserialize(json)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public class TeamUtils {
|
|||||||
* @param color The color to find the team for.
|
* @param color The color to find the team for.
|
||||||
* @return The team.
|
* @return The team.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Team fromChatColor(@NotNull final ChatColor color) {
|
public Team fromChatColor(@NotNull final ChatColor color) {
|
||||||
if (CHAT_COLOR_TEAMS.containsKey(color)) {
|
if (CHAT_COLOR_TEAMS.containsKey(color)) {
|
||||||
return CHAT_COLOR_TEAMS.get(color);
|
return CHAT_COLOR_TEAMS.get(color);
|
||||||
@@ -70,6 +71,7 @@ public class TeamUtils {
|
|||||||
* @param material The material to find the team from.
|
* @param material The material to find the team from.
|
||||||
* @return The team.
|
* @return The team.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Team getMaterialColorTeam(@NotNull final Material material) {
|
public Team getMaterialColorTeam(@NotNull final Material material) {
|
||||||
return fromChatColor(MATERIAL_COLORS.getOrDefault(material, ChatColor.WHITE));
|
return fromChatColor(MATERIAL_COLORS.getOrDefault(material, ChatColor.WHITE));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class VectorUtils {
|
|||||||
* @param vec The vector to simplify.
|
* @param vec The vector to simplify.
|
||||||
* @return The vector, simplified.
|
* @return The vector, simplified.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Vector simplifyVector(@NotNull final Vector vec) {
|
public Vector simplifyVector(@NotNull final Vector vec) {
|
||||||
double x = Math.abs(vec.getX());
|
double x = Math.abs(vec.getX());
|
||||||
double y = Math.abs(vec.getY());
|
double y = Math.abs(vec.getY());
|
||||||
@@ -76,6 +77,7 @@ public class VectorUtils {
|
|||||||
* @param radius The radius.
|
* @param radius The radius.
|
||||||
* @return An array of {@link Vector}s.
|
* @return An array of {@link Vector}s.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Vector[] getCircle(final int radius) {
|
public Vector[] getCircle(final int radius) {
|
||||||
Vector[] cached = CIRCLE_CACHE.get(radius);
|
Vector[] cached = CIRCLE_CACHE.get(radius);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
@@ -112,6 +114,7 @@ public class VectorUtils {
|
|||||||
* @param radius The radius of the square.
|
* @param radius The radius of the square.
|
||||||
* @return An array of {@link Vector}s.
|
* @return An array of {@link Vector}s.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Vector[] getSquare(final int radius) {
|
public Vector[] getSquare(final int radius) {
|
||||||
List<Vector> vectors = new ArrayList<>();
|
List<Vector> vectors = new ArrayList<>();
|
||||||
|
|
||||||
@@ -136,6 +139,7 @@ public class VectorUtils {
|
|||||||
* @param radius The radius of the cube.
|
* @param radius The radius of the cube.
|
||||||
* @return An array of {@link Vector}s.
|
* @return An array of {@link Vector}s.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public Vector[] getCube(final int radius) {
|
public Vector[] getCube(final int radius) {
|
||||||
List<Vector> vectors = new ArrayList<>();
|
List<Vector> vectors = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.bukkit.Bukkit
|
|||||||
import org.bukkit.event.HandlerList
|
import org.bukkit.event.HandlerList
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
|
||||||
class EcoEventManager constructor(private val plugin: EcoPlugin) : EventManager {
|
class EcoEventManager (private val plugin: EcoPlugin) : EventManager {
|
||||||
override fun registerListener(listener: Listener) {
|
override fun registerListener(listener: Listener) {
|
||||||
Bukkit.getPluginManager().registerEvents(listener, plugin)
|
Bukkit.getPluginManager().registerEvents(listener, plugin)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class EcoCaptivatorSlot : EcoSlot(
|
|||||||
{ _, _, _ -> }
|
{ _, _, _ -> }
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val plugin = Eco.getHandler().ecoPlugin!!
|
val plugin = Eco.getHandler().ecoPlugin
|
||||||
|
|
||||||
val allowMovingItem = SlotHandler { event, _, _ ->
|
val allowMovingItem = SlotHandler { event, _, _ ->
|
||||||
event.isCancelled = false
|
event.isCancelled = false
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.willfp.eco.spigot.eventlisteners.*
|
|||||||
import com.willfp.eco.spigot.gui.GUIListener
|
import com.willfp.eco.spigot.gui.GUIListener
|
||||||
import com.willfp.eco.spigot.integrations.anticheat.*
|
import com.willfp.eco.spigot.integrations.anticheat.*
|
||||||
import com.willfp.eco.spigot.integrations.antigrief.*
|
import com.willfp.eco.spigot.integrations.antigrief.*
|
||||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsHeadDatabase
|
|
||||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder
|
import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder
|
||||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen
|
import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen
|
||||||
import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
||||||
@@ -123,7 +122,6 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
|||||||
// Custom Items
|
// Custom Items
|
||||||
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
||||||
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder(this)) },
|
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder(this)) },
|
||||||
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase()) },
|
|
||||||
|
|
||||||
// Shop
|
// Shop
|
||||||
IntegrationLoader("ShopGuiPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
IntegrationLoader("ShopGuiPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.willfp.eco.spigot.integrations.customitems
|
|
||||||
|
|
||||||
import com.willfp.eco.core.integrations.customitems.CustomItemsWrapper
|
|
||||||
import com.willfp.eco.core.items.CustomItem
|
|
||||||
import com.willfp.eco.util.NamespacedKeyUtils
|
|
||||||
import me.arcaniax.hdb.api.HeadDatabaseAPI
|
|
||||||
import me.arcaniax.hdb.enums.CategoryEnum
|
|
||||||
import java.util.function.Predicate
|
|
||||||
|
|
||||||
class CustomItemsHeadDatabase : CustomItemsWrapper {
|
|
||||||
private val api = HeadDatabaseAPI()
|
|
||||||
|
|
||||||
override fun registerAllItems() {
|
|
||||||
for (categoryEnum in CategoryEnum.values()) {
|
|
||||||
for (head in api.getHeads(categoryEnum)) {
|
|
||||||
val stack = head.head
|
|
||||||
val id = head.id
|
|
||||||
val key = NamespacedKeyUtils.create("headdb", id.lowercase());
|
|
||||||
CustomItem(
|
|
||||||
key,
|
|
||||||
Predicate { test ->
|
|
||||||
val headId = api.getItemID(test) ?: return@Predicate false
|
|
||||||
headId.equals(id, ignoreCase = true)
|
|
||||||
},
|
|
||||||
stack
|
|
||||||
).register()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getPluginName(): String {
|
|
||||||
return "HeadDatabase"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 6.7.0
|
version = 6.7.3
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
Reference in New Issue
Block a user