Add KGenerators support

This commit is contained in:
TomTom 2024-08-01 10:32:21 +02:00
parent f97bbf3e93
commit faf001fdc8
5 changed files with 54 additions and 3 deletions

View File

@ -11,6 +11,7 @@ repositories {
maven("https://redempt.dev/")
maven("https://repo.artillex-studios.com/releases/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
@ -19,6 +20,7 @@ dependencies {
implementation("dev.jorel:commandapi-bukkit-shade:9.5.0")
implementation("org.bstats:bstats-bukkit:3.0.2")
compileOnly("com.github.ben-manes.caffeine:caffeine:3.1.8")
compileOnly("me.kryniowesegryderiusz:kgenerators-core:7.3")
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
compileOnly("org.apache.commons:commons-lang3:3.14.0")
compileOnly("com.github.Redempt:Crunch:2.0.3")

View File

@ -1,6 +1,7 @@
package com.artillexstudios.axminions.integrations.implementation.block;
import com.artillexstudios.axminions.integrations.Integration;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
@ -11,12 +12,20 @@ public final class BlockIntegration extends Integration<BlockIntegrable> {
public BlockIntegration() {
this.register(new DefaultBlockIntegrable());
if (Bukkit.getPluginManager().getPlugin("KGenerators") != null) {
this.register(new KGeneratorsIntegrable());
}
}
public Collection<ItemStack> lootAndBreak(Location location, ItemStack itemStack) {
for (BlockIntegrable integration : this.integrations()) {
Collection<ItemStack> items = integration.lootAndBreak(location, itemStack);
if (items == null || items.isEmpty()) {
if (items == null) {
return null;
}
if (items.isEmpty()) {
continue;
}

View File

@ -0,0 +1,31 @@
package com.artillexstudios.axminions.integrations.implementation.block;
import me.kryniowesegryderiusz.kgenerators.Main;
import me.kryniowesegryderiusz.kgenerators.generators.locations.objects.GeneratorLocation;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
import java.util.List;
public final class KGeneratorsIntegrable implements BlockIntegrable {
@Override
public Collection<ItemStack> lootAndBreak(Location location, ItemStack itemStack) {
if (!Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
return null;
}
GeneratorLocation generatorLocation = Main.getPlacedGenerators().getLoaded(location);
if (generatorLocation != null) {
if (!generatorLocation.isBlockPossibleToMine(location)) {
return null;
}
generatorLocation.scheduleGeneratorRegeneration();
return List.of(generatorLocation.getGenerator().drawGeneratedObject().getCustomDrops().getItem());
}
return List.of();
}
}

View File

@ -5,7 +5,9 @@ import com.artillexstudios.axminions.minions.Minion;
import com.artillexstudios.axminions.minions.actions.effects.Effect;
import com.artillexstudios.axminions.utils.ItemCollection;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
import java.util.Map;
public final class BreakEffect extends Effect<Location, ItemCollection> {
@ -16,7 +18,12 @@ public final class BreakEffect extends Effect<Location, ItemCollection> {
@Override
public ItemCollection run(Minion minion, Location argument) {
return new ItemCollection(Integrations.BLOCK.lootAndBreak(argument, minion.tool()));
Collection<ItemStack> items = Integrations.BLOCK.lootAndBreak(argument, minion.tool());
if (items == null) {
return null;
}
return new ItemCollection(items);
}
@Override

View File

@ -2,4 +2,6 @@ name: "AxMinions"
main: "com.artillexstudios.axminions.AxMinionsPlugin"
version: "${version}"
api-version: "1.18"
folia-supported: true
folia-supported: true
softdepend:
- KGenerators