Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7fa0ecf26 | ||
|
|
a65f16cfac | ||
|
|
49965c091b | ||
|
|
5627582bd5 | ||
|
|
ab8065d06e | ||
|
|
444764e481 | ||
|
|
c240e94a6b | ||
|
|
9da28a1dff | ||
|
|
109347a601 | ||
|
|
43bef762bf | ||
|
|
69a2e0e247 | ||
|
|
874a9b4f32 | ||
|
|
5690221c27 | ||
|
|
f19b143804 | ||
|
|
bbbf19c041 |
@@ -357,15 +357,18 @@ public abstract class EcoPlugin extends JavaPlugin {
|
||||
Eco.getHandler().registerBStats(this);
|
||||
}
|
||||
|
||||
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
|
||||
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins())
|
||||
.map(Plugin::getName)
|
||||
.map(String::toLowerCase)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (enabledPlugins.contains("PlaceholderAPI")) {
|
||||
if (enabledPlugins.contains("PlaceholderAPI".toLowerCase())) {
|
||||
this.loadedIntegrations.add("PlaceholderAPI");
|
||||
PlaceholderManager.addIntegration(Eco.getHandler().createPAPIIntegration(this));
|
||||
}
|
||||
|
||||
this.loadIntegrationLoaders().forEach((integrationLoader -> {
|
||||
if (enabledPlugins.contains(integrationLoader.getPluginName())) {
|
||||
if (enabledPlugins.contains(integrationLoader.getPluginName().toLowerCase())) {
|
||||
this.loadedIntegrations.add(integrationLoader.getPluginName());
|
||||
integrationLoader.load();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.willfp.eco.core.integrations.shop;
|
||||
|
||||
import com.willfp.eco.core.integrations.Integration;
|
||||
|
||||
/**
|
||||
* Wrapper class for shop integrations.
|
||||
*/
|
||||
public interface ShopWrapper {
|
||||
public interface ShopWrapper extends Integration {
|
||||
/**
|
||||
* Register eco item provider for shop plugins.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.willfp.eco.core.items;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,6 +50,12 @@ public class CustomItem implements TestableItem {
|
||||
this.key = key;
|
||||
this.test = test;
|
||||
this.item = item;
|
||||
|
||||
Eco.getHandler().getEcoPlugin().getScheduler().runLater(() -> {
|
||||
if (!matches(getItem())) {
|
||||
Bukkit.getLogger().severe("Item with key " + key + " is invalid!");
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -178,7 +178,10 @@ public final class Items {
|
||||
List<Predicate<ItemStack>> predicates = new ArrayList<>();
|
||||
|
||||
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);
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -16,8 +17,8 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public class EnchantmentArgParser implements LookupArgParser {
|
||||
@Override
|
||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
Map<Enchantment, Integer> requiredEnchantments = new HashMap<>();
|
||||
|
||||
for (String enchantArg : args) {
|
||||
@@ -37,6 +38,10 @@ public class EnchantmentArgParser implements LookupArgParser {
|
||||
requiredEnchantments.put(enchantment, level);
|
||||
}
|
||||
|
||||
if (requiredEnchantments.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
||||
requiredEnchantments.forEach((enchantment, integer) -> storageMeta.addStoredEnchant(enchantment, integer, true));
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.items.TestableItem;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -19,6 +20,6 @@ public interface LookupArgParser {
|
||||
* @param meta The ItemMeta to modify.
|
||||
* @return The predicate test to apply to the modified item.
|
||||
*/
|
||||
Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
||||
@NotNull ItemMeta meta);
|
||||
@Nullable Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
||||
@NotNull ItemMeta meta);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -13,8 +14,8 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public class TextureArgParser implements LookupArgParser {
|
||||
@Override
|
||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
String skullTexture = null;
|
||||
|
||||
for (String arg : args) {
|
||||
@@ -34,6 +35,10 @@ public class TextureArgParser implements LookupArgParser {
|
||||
SkullUtils.setSkullTexture(skullMeta, skullTexture);
|
||||
}
|
||||
|
||||
if (skullTexture == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String finalSkullTexture = skullTexture;
|
||||
return test -> {
|
||||
if (!test.hasItemMeta()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.recipe.parts;
|
||||
|
||||
import com.willfp.eco.core.items.TestableItem;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -82,6 +82,10 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
||||
ShapedRecipe shapedRecipe = new ShapedRecipe(this.getKey(), this.getOutput());
|
||||
shapedRecipe.shape("012", "345", "678");
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char character = String.valueOf(i).toCharArray()[0];
|
||||
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());
|
||||
displayedRecipe.shape("012", "345", "678");
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char character = String.valueOf(i).toCharArray()[0];
|
||||
ItemStack item = parts.get(i).getItem();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -10,18 +11,37 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
@UtilityClass
|
||||
public class LightningUtils {
|
||||
|
||||
/**
|
||||
* Strike lightning on player without fire.
|
||||
*
|
||||
* @param victim The entity to smite.
|
||||
* @param damage The damage to deal.
|
||||
* @param silent If the lightning sound should be played locally
|
||||
*/
|
||||
public void strike(@NotNull final LivingEntity victim,
|
||||
final double damage,
|
||||
final boolean silent) {
|
||||
Location loc = victim.getLocation();
|
||||
|
||||
if (silent) {
|
||||
victim.getWorld().spigot().strikeLightningEffect(loc, true);
|
||||
victim.getWorld().playSound(loc, Sound.ENTITY_LIGHTNING_BOLT_IMPACT, 1, 1);
|
||||
} else {
|
||||
victim.getWorld().strikeLightningEffect(loc);
|
||||
}
|
||||
|
||||
victim.damage(damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Strike lightning on a victim without fire.
|
||||
*
|
||||
* @param victim The entity to smite.
|
||||
* @param damage The damage to deal.
|
||||
*/
|
||||
public void strike(@NotNull final LivingEntity victim,
|
||||
final double damage) {
|
||||
Location loc = victim.getLocation();
|
||||
|
||||
victim.getWorld().strikeLightningEffect(loc);
|
||||
|
||||
victim.damage(damage);
|
||||
strike(victim, damage, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.willfp.eco.spigot.eventlisteners.*
|
||||
import com.willfp.eco.spigot.gui.GUIListener
|
||||
import com.willfp.eco.spigot.integrations.anticheat.*
|
||||
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.CustomItemsOraxen
|
||||
import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
||||
@@ -90,6 +89,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
|
||||
override fun handleAfterLoad() {
|
||||
CustomItemsManager.registerAllItems()
|
||||
ShopManager.registerEcoProvider()
|
||||
}
|
||||
|
||||
override fun loadIntegrationLoaders(): List<IntegrationLoader> {
|
||||
@@ -123,10 +123,9 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
// Custom Items
|
||||
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
||||
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder(this)) },
|
||||
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase()) },
|
||||
|
||||
// Shop
|
||||
IntegrationLoader("ShopGuiPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
|
||||
// Misc
|
||||
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }
|
||||
|
||||
@@ -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).toList()) {
|
||||
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"
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,15 @@ import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import io.th0rgal.oraxen.items.OraxenItems
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import java.util.*
|
||||
import java.util.function.Predicate
|
||||
|
||||
class CustomItemsOraxen : CustomItemsWrapper {
|
||||
override fun registerAllItems() {
|
||||
for (item in OraxenItems.getItems()) {
|
||||
val stack = item.build()
|
||||
val id: String = OraxenItems.getIdByItem(item)
|
||||
val id: String = Objects.requireNonNullElse(OraxenItems.getIdByItem(item), "")
|
||||
if (id.isEmpty()) continue
|
||||
val key: NamespacedKey = NamespacedKeyUtils.create("oraxen", id.lowercase())
|
||||
CustomItem(
|
||||
key, Predicate { test: ItemStack ->
|
||||
|
||||
@@ -28,4 +28,8 @@ class ShopShopGuiPlus : ShopWrapper {
|
||||
return Items.getCustomItem(itemStack1)?.key == Items.getCustomItem(itemStack2)?.key
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "ShopGUIPlus"
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ softdepend:
|
||||
- PlaceholderAPI
|
||||
- mcMMO
|
||||
- CombatLogX
|
||||
- ShopGuiPlus
|
||||
- ShopGUIPlus
|
||||
- ItemsAdder
|
||||
- Oraxen
|
||||
- HeadDatabase
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.7.1
|
||||
version = 6.7.5
|
||||
plugin-name = eco
|
||||
Reference in New Issue
Block a user