Added RPGHorses Antigrief integration
Fixed CustoMCrafting compatibility Updated CustomCrafting Items lookup integration Added a warning for empty recipes
This commit is contained in:
@@ -67,6 +67,9 @@ allprojects {
|
||||
|
||||
// Crunch
|
||||
maven("https://redempt.dev")
|
||||
|
||||
// LibsDisguises
|
||||
maven("https://repo.md-5.net/content/groups/public/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -94,14 +97,12 @@ allprojects {
|
||||
exclude(group = "org.spongepowered", module = "configurate-hocon")
|
||||
exclude(group = "com.darkblade12", module = "particleeffect")
|
||||
exclude(group = "com.github.cryptomorin", module = "XSeries")
|
||||
exclude(group = "org.apache.commons", module = "commons-lang3")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("org.bstats", "com.willfp.eco.shaded.bstats")
|
||||
relocate("net.kyori.adventure.text.minimessage", "com.willfp.eco.shaded.minimessage")
|
||||
relocate("redempt.crunch", "com.willfp.eco.shaded.crunch")
|
||||
}
|
||||
|
||||
compileJava {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.willfp.eco.core.items.Items;
|
||||
import com.willfp.eco.core.recipe.recipes.CraftingRecipe;
|
||||
import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe;
|
||||
import com.willfp.eco.util.NamespacedKeyUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -96,6 +97,7 @@ public final class Recipes {
|
||||
* @param permission The permission.
|
||||
* @return The recipe.
|
||||
*/
|
||||
@Nullable
|
||||
public static CraftingRecipe createAndRegisterRecipe(@NotNull final EcoPlugin plugin,
|
||||
@NotNull final String key,
|
||||
@NotNull final ItemStack output,
|
||||
@@ -109,6 +111,12 @@ public final class Recipes {
|
||||
builder.setRecipePart(i, Items.lookup(recipeStrings.get(i)));
|
||||
}
|
||||
|
||||
if (builder.isAir()) {
|
||||
Bukkit.getLogger().warning("RECIPE ERROR! " + plugin.getName() + ":" + key + " consists only");
|
||||
Bukkit.getLogger().warning("of air or invalid items! Please change that or disable this recipe.");
|
||||
return null;
|
||||
}
|
||||
|
||||
ShapedCraftingRecipe recipe = builder.build();
|
||||
recipe.register();
|
||||
|
||||
|
||||
@@ -287,6 +287,20 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if recipe parts are all air.
|
||||
*
|
||||
* @return If recipe parts are all air.
|
||||
*/
|
||||
public boolean isAir() {
|
||||
for (TestableItem recipePart : this.recipeParts) {
|
||||
if (recipePart!= null && !(recipePart instanceof EmptyTestableItem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the recipe.
|
||||
*
|
||||
|
||||
@@ -43,7 +43,7 @@ dependencies {
|
||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||
compileOnly 'com.iridium:IridiumSkyblock:3.1.2'
|
||||
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
|
||||
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:1.7.8.1'
|
||||
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
|
||||
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
|
||||
compileOnly 'io.lumine.xikage:MythicMobs:4.9.1'
|
||||
|
||||
@@ -55,6 +55,9 @@ dependencies {
|
||||
compileOnly 'com.github.sirblobman.combatlogx:api:11.0.0.0-SNAPSHOT'
|
||||
compileOnly 'com.github.sirblobman.combatlogx.expansion:newbie-helper:11.0.0.0-SNAPSHOT'
|
||||
|
||||
// LibsDisguises
|
||||
compileOnly 'LibsDisguises:LibsDisguises:10.0.26'
|
||||
|
||||
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.willfp.eco.internal.spigot.recipes;
|
||||
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
|
||||
public interface RecipeValidator {
|
||||
|
||||
boolean validate(PrepareItemCraftEvent event);
|
||||
|
||||
boolean validate(CraftItemEvent event);
|
||||
|
||||
}
|
||||
@@ -24,7 +24,17 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements Listener {
|
||||
|
||||
private static final List<RecipeValidator> VALIDATORS = new ArrayList<>();
|
||||
|
||||
public static void registerValidator(RecipeValidator validator) {
|
||||
VALIDATORS.add(validator);
|
||||
}
|
||||
|
||||
public ShapedRecipeListener(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
@@ -67,6 +77,11 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
}
|
||||
|
||||
ItemStack[] matrix = event.getInventory().getMatrix();
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
CraftingRecipe matched = Recipes.getMatch(matrix);
|
||||
|
||||
if (matched == null) {
|
||||
@@ -104,6 +119,11 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
}
|
||||
|
||||
ItemStack[] matrix = event.getInventory().getMatrix();
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
CraftingRecipe matched = Recipes.getMatch(matrix);
|
||||
|
||||
if (matched == null) {
|
||||
@@ -136,10 +156,20 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getInventory().getViewers().get(0) instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack[] matrix = event.getInventory().getMatrix();
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
CraftingRecipe matched = Recipes.getMatch(matrix);
|
||||
|
||||
if (matched == null) {
|
||||
deny(event);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -216,6 +246,10 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack itemStack = event.getInventory().getMatrix()[i];
|
||||
TestableItem part = shapedCraftingRecipe.getParts().get(i);
|
||||
@@ -256,14 +290,16 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack itemStack = event.getInventory().getMatrix()[i];
|
||||
TestableItem part = shapedCraftingRecipe.getParts().get(i);
|
||||
if (part instanceof MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -271,8 +307,6 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
if (modified.getHandle() instanceof MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +332,10 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : event.getInventory().getMatrix()) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
@@ -316,11 +354,13 @@ public class ShapedRecipeListener extends PluginDependent<EcoPlugin> implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (VALIDATORS.stream().anyMatch(validator -> validator.validate(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : event.getInventory().getMatrix()) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,24 +55,14 @@ import com.willfp.eco.internal.spigot.integrations.anticheat.AnticheatMatrix
|
||||
import com.willfp.eco.internal.spigot.integrations.anticheat.AnticheatNCP
|
||||
import com.willfp.eco.internal.spigot.integrations.anticheat.AnticheatSpartan
|
||||
import com.willfp.eco.internal.spigot.integrations.anticheat.AnticheatVulcan
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefBentoBox
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefCombatLogXV10
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefCombatLogXV11
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefDeluxeCombat
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefFactionsUUID
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefGriefPrevention
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefIridiumSkyblock
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefKingdoms
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefLands
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefSuperiorSkyblock2
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefTowny
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.AntigriefWorldGuard
|
||||
import com.willfp.eco.internal.spigot.integrations.antigrief.*
|
||||
import com.willfp.eco.internal.spigot.integrations.customentities.CustomEntitiesMythicMobs
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsCustomCrafting
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsExecutableItems
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsHeadDatabase
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsItemsAdder
|
||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsOraxen
|
||||
import com.willfp.eco.internal.spigot.integrations.customrecipes.CustomRecipeCustomCrafting
|
||||
import com.willfp.eco.internal.spigot.integrations.economy.EconomyVault
|
||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramCMI
|
||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramDecentHolograms
|
||||
@@ -208,6 +198,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
IntegrationLoader("Towny") { AntigriefManager.register(AntigriefTowny()) },
|
||||
IntegrationLoader("Lands") { AntigriefManager.register(AntigriefLands(this)) },
|
||||
IntegrationLoader("Kingdoms") { AntigriefManager.register(AntigriefKingdoms()) },
|
||||
IntegrationLoader("RPGHorses") { AntigriefManager.register(AntigriefRPGHorses()) },
|
||||
//IntegrationLoader("CrashClaim") { AntigriefManager.register(AntigriefCrashClaim()) },
|
||||
IntegrationLoader("CombatLogX") {
|
||||
val pluginManager = Bukkit.getPluginManager()
|
||||
@@ -237,7 +228,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder()) },
|
||||
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase(this)) },
|
||||
IntegrationLoader("ExecutableItems") { CustomItemsManager.register(CustomItemsExecutableItems()) },
|
||||
IntegrationLoader("CustomCrafting") { CustomItemsManager.register(CustomItemsCustomCrafting()) },
|
||||
IntegrationLoader("CustomCrafting") { CustomItemsManager.register(CustomItemsCustomCrafting()); ShapedRecipeListener.registerValidator(CustomRecipeCustomCrafting()) },
|
||||
|
||||
// Shop
|
||||
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.willfp.eco.internal.spigot.integrations.antigrief
|
||||
|
||||
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.entity.Player
|
||||
import org.plugins.rpghorses.RPGHorsesMain
|
||||
|
||||
class AntigriefRPGHorses : AntigriefWrapper {
|
||||
override fun canBreakBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canCreateExplosion(
|
||||
player: Player,
|
||||
location: Location
|
||||
): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canPlaceBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canInjure(
|
||||
player: Player,
|
||||
victim: LivingEntity
|
||||
): Boolean {
|
||||
val horse = RPGHorsesMain.getInstance().rpgHorseManager.getRPGHorse(victim)?: return true
|
||||
return horse.horseOwner.uuid.equals(player.uniqueId)
|
||||
}
|
||||
|
||||
override fun canPickupItem(player: Player, location: Location): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "RPGHorses"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.willfp.eco.internal.spigot.integrations.customrecipes
|
||||
|
||||
import com.willfp.eco.internal.spigot.recipes.RecipeValidator
|
||||
import me.wolfyscript.customcrafting.CustomCrafting
|
||||
import org.bukkit.event.inventory.CraftItemEvent
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent
|
||||
|
||||
class CustomRecipeCustomCrafting: RecipeValidator {
|
||||
override fun validate(event: CraftItemEvent): Boolean {
|
||||
if (event.inventory.viewers.isEmpty()) {
|
||||
return false
|
||||
}
|
||||
val player = event.inventory.viewers[0]
|
||||
return CustomCrafting.inst().craftManager.has(player.uniqueId)
|
||||
}
|
||||
|
||||
override fun validate(event: PrepareItemCraftEvent): Boolean {
|
||||
if (event.inventory.viewers.isEmpty()) {
|
||||
return false
|
||||
}
|
||||
val player = event.inventory.viewers[0]
|
||||
return CustomCrafting.inst().craftManager.has(player.uniqueId)
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ softdepend:
|
||||
- MythicMobs
|
||||
- CustomCrafting
|
||||
- ExecutableItems
|
||||
- RPGHorses
|
||||
libraries:
|
||||
- 'org.reflections:reflections:0.9.12'
|
||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
BIN
lib/RPGHorses.jar
Normal file
BIN
lib/RPGHorses.jar
Normal file
Binary file not shown.
BIN
lib/customcrafting-spigot-3.16.0.0-f.jar
Normal file
BIN
lib/customcrafting-spigot-3.16.0.0-f.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user