diff --git a/build.gradle b/build.gradle index 93a1c11..41b3fde 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '3.1.1-hotfix' +version = '3.1.2' repositories { mavenCentral() @@ -25,6 +25,7 @@ dependencies { compileOnly ('dev.dejvokep:boosted-yaml:1.3') compileOnly ('com.github.Archy-X:AureliumSkills:Beta1.3.18') compileOnly ('commons-io:commons-io:2.11.0') + compileOnly ('dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT') compileOnly ('io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT') compileOnly ('me.clip:placeholderapi:2.11.3') compileOnly ('com.github.LoneDev6:api-itemsadder:3.4.1-r4') diff --git a/src/main/java/net/momirealms/customcrops/api/customplugin/Handler.java b/src/main/java/net/momirealms/customcrops/api/customplugin/Handler.java index 60ed14e..4214444 100644 --- a/src/main/java/net/momirealms/customcrops/api/customplugin/Handler.java +++ b/src/main/java/net/momirealms/customcrops/api/customplugin/Handler.java @@ -21,12 +21,9 @@ import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.api.object.Function; import net.momirealms.customcrops.api.object.basic.ConfigManager; import net.momirealms.customcrops.api.object.pot.PotManager; -import net.momirealms.customcrops.api.object.world.SimpleLocation; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.data.type.Farmland; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; diff --git a/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformInterface.java b/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformInterface.java index 95ce27a..7f1ea23 100644 --- a/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformInterface.java +++ b/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformInterface.java @@ -124,7 +124,7 @@ public interface PlatformInterface { @Nullable default ItemFrame getItemFrameAt(Location location) { - Collection itemFrames = location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(ItemFrame.class, 0.5, 0.5, 0.5); + Collection itemFrames = location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(ItemFrame.class, 0.4, 0.5, 0.4); int i = itemFrames.size(); int j = 1; for (ItemFrame itemFrame : itemFrames) { @@ -139,7 +139,7 @@ public interface PlatformInterface { @Nullable default ItemDisplay getItemDisplayAt(Location location) { - Collection itemDisplays = location.clone().add(0.5,0.25,0.5).getNearbyEntitiesByType(ItemDisplay.class, 0.5, 0.5, 0.5); + Collection itemDisplays = location.clone().add(0.5,0.25,0.5).getNearbyEntitiesByType(ItemDisplay.class, 0.4, 0.5, 0.4); int i = itemDisplays.size(); int j = 1; for (ItemDisplay itemDisplay : itemDisplays) { @@ -163,7 +163,7 @@ public interface PlatformInterface { } default void removeInteractions(Location location) { - location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(Interaction.class, 0.5, 0.5, 0.5).forEach(Entity::remove); + location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(Interaction.class, 0.4, 0.5, 0.4).forEach(Entity::remove); } default boolean removeItemDisplay(Location location) { @@ -179,12 +179,12 @@ public interface PlatformInterface { default boolean detectAnyThing(Location location) { Block block = location.getBlock(); if (block.getType() != Material.AIR) return true; - Collection entities = location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(ItemFrame.class, 0.5, 0.5, 0.5); + Collection entities = location.clone().add(0.5,0.5,0.5).getNearbyEntitiesByType(ItemFrame.class, 0.4, 0.5, 0.4); return entities.size() != 0 || (CustomCrops.getInstance().getVersionHelper().isVersionNewerThan1_19_R3() && detectItemDisplay(location)); } default boolean detectItemDisplay(Location location) { - Collection entities = location.clone().add(0.5,0,0.5).getNearbyEntitiesByType(ItemDisplay.class, 0.5, 0.5, 0.5); + Collection entities = location.clone().add(0.5,0,0.5).getNearbyEntitiesByType(ItemDisplay.class, 0.4, 0.5, 0.4); return entities.size() != 0; } diff --git a/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformManager.java b/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformManager.java index 0bdc5c2..d58d6d7 100644 --- a/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformManager.java +++ b/src/main/java/net/momirealms/customcrops/api/customplugin/PlatformManager.java @@ -61,7 +61,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -import javax.xml.transform.sax.SAXResult; import java.util.*; public class PlatformManager extends Function { diff --git a/src/main/java/net/momirealms/customcrops/api/customplugin/oraxen/OraxenHandler.java b/src/main/java/net/momirealms/customcrops/api/customplugin/oraxen/OraxenHandler.java index 1a6f7b7..413a0dc 100644 --- a/src/main/java/net/momirealms/customcrops/api/customplugin/oraxen/OraxenHandler.java +++ b/src/main/java/net/momirealms/customcrops/api/customplugin/oraxen/OraxenHandler.java @@ -18,6 +18,9 @@ package net.momirealms.customcrops.api.customplugin.oraxen; import io.th0rgal.oraxen.api.events.*; +import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic; +import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic; +import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic; import net.momirealms.customcrops.api.customplugin.Handler; import net.momirealms.customcrops.api.customplugin.PlatformManager; import org.bukkit.entity.Entity; @@ -50,17 +53,23 @@ public class OraxenHandler extends Handler { @EventHandler public void onPlaceFurniture(OraxenFurniturePlaceEvent event) { - platformManager.onPlaceFurniture(event.getPlayer(), event.getBaseEntity().getLocation().getBlock().getLocation(), event.getMechanic().getItemID(), event); + FurnitureMechanic mechanic = event.getMechanic(); + if (mechanic == null) return; + platformManager.onPlaceFurniture(event.getPlayer(), event.getBaseEntity().getLocation().getBlock().getLocation(), mechanic.getItemID(), event); } @EventHandler public void onPlaceStringBlock(OraxenStringBlockPlaceEvent event) { - platformManager.onPlaceBlock(event.getPlayer(), event.getBlock().getLocation(), event.getMechanic().getItemID(), event); + StringBlockMechanic mechanic = event.getMechanic(); + if (mechanic == null) return; + platformManager.onPlaceBlock(event.getPlayer(), event.getBlock().getLocation(), mechanic.getItemID(), event); } @EventHandler public void onPlaceNoteBlock(OraxenNoteBlockPlaceEvent event) { - platformManager.onPlaceBlock(event.getPlayer(), event.getBlock().getLocation(), event.getMechanic().getItemID(), event); + NoteBlockMechanic mechanic = event.getMechanic(); + if (mechanic == null) return; + platformManager.onPlaceBlock(event.getPlayer(), event.getBlock().getLocation(), mechanic.getItemID(), event); } @EventHandler diff --git a/src/main/java/net/momirealms/customcrops/api/event/CropBreakEvent.java b/src/main/java/net/momirealms/customcrops/api/event/CropBreakEvent.java index 210f6ea..fa4e39a 100644 --- a/src/main/java/net/momirealms/customcrops/api/event/CropBreakEvent.java +++ b/src/main/java/net/momirealms/customcrops/api/event/CropBreakEvent.java @@ -23,7 +23,6 @@ import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,6 +35,9 @@ public class CropBreakEvent extends Event implements Cancellable { private final Location location; private final Entity entity; + /** + * This event might be called when entity breaks the crop or player triggers the break action + */ public CropBreakEvent(@Nullable Entity entity, CropConfig cropConfig, String cropItemID, Location location) { this.entity = entity; this.cropConfig = cropConfig; diff --git a/src/main/java/net/momirealms/customcrops/api/event/CropPlantEvent.java b/src/main/java/net/momirealms/customcrops/api/event/CropPlantEvent.java index 52e8ddd..51e9c71 100644 --- a/src/main/java/net/momirealms/customcrops/api/event/CropPlantEvent.java +++ b/src/main/java/net/momirealms/customcrops/api/event/CropPlantEvent.java @@ -35,6 +35,9 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable { private int point; private String crop_model; + /** + * This event might be called when player plants the crop with a seed or triggers the replant action + */ public CropPlantEvent(@NotNull Player who, ItemStack hand, Location location, String crop, int point, String crop_model) { super(who); this.hand = hand; diff --git a/src/main/java/net/momirealms/customcrops/api/event/PotBreakEvent.java b/src/main/java/net/momirealms/customcrops/api/event/PotBreakEvent.java index 0b07fe8..6940594 100644 --- a/src/main/java/net/momirealms/customcrops/api/event/PotBreakEvent.java +++ b/src/main/java/net/momirealms/customcrops/api/event/PotBreakEvent.java @@ -20,12 +20,9 @@ package net.momirealms.customcrops.api.event; import net.momirealms.customcrops.api.object.pot.PotConfig; import org.bukkit.Location; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityEvent; -import org.bukkit.event.player.PlayerEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/momirealms/customcrops/api/object/CrowTask.java b/src/main/java/net/momirealms/customcrops/api/object/CrowTask.java index 243d45a..9d593b4 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/CrowTask.java +++ b/src/main/java/net/momirealms/customcrops/api/object/CrowTask.java @@ -42,7 +42,6 @@ public class CrowTask extends BukkitRunnable { this.cropLoc = crop_location.clone(); this.timer = 0; this.fly = CustomCrops.getInstance().getIntegrationManager().build(fly_model); - ItemStack stand = CustomCrops.getInstance().getIntegrationManager().build(stand_model); this.player = player; this.entityID = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE); this.yaw = ThreadLocalRandom.current().nextInt(361) - 180; @@ -50,7 +49,7 @@ public class CrowTask extends BukkitRunnable { this.vectorUp = new Vector(relative.getX() / 75, 0.1, relative.getZ() / 75); CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getSpawnPacket(entityID, crop_location, EntityType.ARMOR_STAND)); CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getVanishArmorStandMetaPacket(entityID)); - CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, stand)); + CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, CustomCrops.getInstance().getIntegrationManager().build(stand_model))); } @Override diff --git a/src/main/java/net/momirealms/customcrops/api/object/InteractCrop.java b/src/main/java/net/momirealms/customcrops/api/object/InteractCrop.java index 048afd0..27d4900 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/InteractCrop.java +++ b/src/main/java/net/momirealms/customcrops/api/object/InteractCrop.java @@ -21,7 +21,6 @@ import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.api.object.action.Action; import net.momirealms.customcrops.api.object.requirement.Requirement; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class InteractCrop { diff --git a/src/main/java/net/momirealms/customcrops/api/object/action/BreakImpl.java b/src/main/java/net/momirealms/customcrops/api/object/action/BreakImpl.java index 5b303f4..02d6a2e 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/action/BreakImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/action/BreakImpl.java @@ -18,9 +18,12 @@ package net.momirealms.customcrops.api.object.action; import net.momirealms.customcrops.CustomCrops; +import net.momirealms.customcrops.api.event.CropBreakEvent; import net.momirealms.customcrops.api.object.ItemMode; +import net.momirealms.customcrops.api.object.crop.CropConfig; import net.momirealms.customcrops.api.object.crop.StageConfig; import net.momirealms.customcrops.api.object.world.SimpleLocation; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -37,24 +40,29 @@ public class BreakImpl implements Action { @Override public void doOn(@Nullable Player player, @Nullable SimpleLocation crop_loc, ItemMode itemMode) { - if (crop_loc == null) return; - CustomCrops.getInstance().getScheduler().callSyncMethod(() -> { + if (crop_loc == null || stage_id == null || player == null) return; + CropConfig cropConfig = CustomCrops.getInstance().getCropManager().getCropConfigByStage(stage_id); + CustomCrops.getInstance().getScheduler().runTask(() -> { Location bLoc = crop_loc.getBukkitLocation(); - if (bLoc == null) return null; + if (bLoc == null) return; + CropBreakEvent cropBreakEvent = new CropBreakEvent(player, cropConfig, stage_id, bLoc); + Bukkit.getPluginManager().callEvent(cropBreakEvent); + if (cropBreakEvent.isCancelled()) { + return; + } CustomCrops.getInstance().getPlatformInterface().removeAnyThingAt(bLoc); CustomCrops.getInstance().getWorldDataManager().removeCropData(crop_loc); - return null; - }); - if (triggerAction && stage_id != null) { - StageConfig stageConfig = CustomCrops.getInstance().getCropManager().getStageConfig(stage_id); - if (stageConfig != null) { - Action[] actions = stageConfig.getBreakActions(); - if (actions != null) { - for (Action action : actions) { - action.doOn(player, crop_loc, itemMode); + if (triggerAction) { + StageConfig stageConfig = CustomCrops.getInstance().getCropManager().getStageConfig(stage_id); + if (stageConfig != null) { + Action[] actions = stageConfig.getBreakActions(); + if (actions != null) { + for (Action action : actions) { + action.doOn(player, crop_loc, itemMode); + } } } } - } + }); } } diff --git a/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java b/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java index 1356011..6b57ef6 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java @@ -18,6 +18,7 @@ package net.momirealms.customcrops.api.object.action; import net.momirealms.customcrops.CustomCrops; +import net.momirealms.customcrops.api.event.CropPlantEvent; import net.momirealms.customcrops.api.object.ItemMode; import net.momirealms.customcrops.api.object.basic.ConfigManager; import net.momirealms.customcrops.api.object.basic.MessageManager; @@ -25,6 +26,7 @@ import net.momirealms.customcrops.api.object.crop.CropConfig; import net.momirealms.customcrops.api.object.crop.GrowingCrop; import net.momirealms.customcrops.api.object.world.SimpleLocation; import net.momirealms.customcrops.api.util.AdventureUtils; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; @@ -43,21 +45,28 @@ public class ReplantImpl implements Action { @Override public void doOn(@Nullable Player player, @Nullable SimpleLocation crop_loc, ItemMode itemMode) { + if (player == null || crop_loc == null) return; CropConfig cropConfig = CustomCrops.getInstance().getCropManager().getCropConfigByID(crop); - if (crop_loc != null && cropConfig != null) { + if (cropConfig != null) { ItemMode newCMode = cropConfig.getCropMode(); - CustomCrops.getInstance().getScheduler().callSyncMethod(() -> { + CustomCrops.getInstance().getScheduler().runTask(() -> { Location location = crop_loc.getBukkitLocation(); - if (location == null) return null; + if (location == null) return; if (ConfigManager.enableLimitation && CustomCrops.getInstance().getWorldDataManager().getChunkCropAmount(crop_loc) >= ConfigManager.maxCropPerChunk) { - if (player != null)AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.reachChunkLimit); - return null; + AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.reachChunkLimit); + return; } + + CropPlantEvent cropPlantEvent = new CropPlantEvent(player, player.getInventory().getItemInMainHand(), location, crop, point, model); + Bukkit.getPluginManager().callEvent(cropPlantEvent); + if (cropPlantEvent.isCancelled()) { + return; + } + if (!CustomCrops.getInstance().getPlatformInterface().detectAnyThing(location)) { CustomCrops.getInstance().getPlatformInterface().placeCustomItem(location, model, newCMode); CustomCrops.getInstance().getWorldDataManager().addCropData(crop_loc, new GrowingCrop(crop, point), true); } - return null; }); } } diff --git a/src/main/java/net/momirealms/customcrops/api/object/action/VanillaXPImpl.java b/src/main/java/net/momirealms/customcrops/api/object/action/VanillaXPImpl.java index 5cbda79..d4a8e12 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/action/VanillaXPImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/action/VanillaXPImpl.java @@ -19,11 +19,9 @@ package net.momirealms.customcrops.api.object.action; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; -import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.api.object.ItemMode; import net.momirealms.customcrops.api.object.world.SimpleLocation; import net.momirealms.customcrops.api.util.AdventureUtils; -import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/momirealms/customcrops/api/object/condition/CrowAttack.java b/src/main/java/net/momirealms/customcrops/api/object/condition/CrowAttack.java index 5e46d22..1758a9a 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/condition/CrowAttack.java +++ b/src/main/java/net/momirealms/customcrops/api/object/condition/CrowAttack.java @@ -45,10 +45,7 @@ public class CrowAttack implements Condition { for (Player player : Bukkit.getOnlinePlayers()) { SimpleLocation playerLoc = SimpleLocation.getByBukkitLocation(player.getLocation()); if (playerLoc.isNear(simpleLocation, 48)) { - CustomCrops.getInstance().getScheduler().callSyncMethod(() -> { - new CrowTask(player, location, fly_model, stand_model).runTaskTimerAsynchronously(CustomCrops.getInstance(), 1, 1); - return null; - }); + new CrowTask(player, location, fly_model, stand_model).runTaskTimerAsynchronously(CustomCrops.getInstance(), 1, 1); } } return true; diff --git a/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java b/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java index ec4c821..c1c991d 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java @@ -21,7 +21,6 @@ import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.api.object.Function; import net.momirealms.customcrops.api.object.basic.ConfigManager; import net.momirealms.customcrops.api.object.fertilizer.FertilizerType; -import net.momirealms.customcrops.api.object.fill.PassiveFillMethod; import net.momirealms.customcrops.api.object.hologram.FertilizerHologram; import net.momirealms.customcrops.api.object.hologram.HologramManager; import net.momirealms.customcrops.api.object.hologram.TextDisplayMeta; diff --git a/src/main/java/net/momirealms/customcrops/api/object/requirement/WeatherImpl.java b/src/main/java/net/momirealms/customcrops/api/object/requirement/WeatherImpl.java index d507d6d..d18252c 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/requirement/WeatherImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/requirement/WeatherImpl.java @@ -20,8 +20,6 @@ package net.momirealms.customcrops.api.object.requirement; import org.bukkit.World; import org.jetbrains.annotations.Nullable; -import java.util.List; - public class WeatherImpl extends AbstractRequirement implements Requirement { private final String[] weathers; diff --git a/src/main/java/net/momirealms/customcrops/api/object/scheduler/BukkitSchedulerImpl.java b/src/main/java/net/momirealms/customcrops/api/object/scheduler/BukkitSchedulerImpl.java index 8c3a2b9..b0aec6b 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/scheduler/BukkitSchedulerImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/scheduler/BukkitSchedulerImpl.java @@ -19,6 +19,7 @@ package net.momirealms.customcrops.api.object.scheduler; import net.momirealms.customcrops.CustomCrops; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Callable; @@ -41,4 +42,9 @@ public class BukkitSchedulerImpl implements SchedulerPlatform { public void runTask(Runnable runnable) { Bukkit.getScheduler().runTask(plugin, runnable); } + + @Override + public void runTask(Runnable runnable, Location location) { + runTask(runnable); + } } diff --git a/src/main/java/net/momirealms/customcrops/api/object/scheduler/FoliaSchedulerImpl.java b/src/main/java/net/momirealms/customcrops/api/object/scheduler/FoliaSchedulerImpl.java new file mode 100644 index 0000000..d764c85 --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/api/object/scheduler/FoliaSchedulerImpl.java @@ -0,0 +1,33 @@ +package net.momirealms.customcrops.api.object.scheduler; + +import net.momirealms.customcrops.CustomCrops; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +public class FoliaSchedulerImpl implements SchedulerPlatform { + + private final CustomCrops plugin; + + public FoliaSchedulerImpl(CustomCrops plugin) { + this.plugin = plugin; + } + + @Override + public Future callSyncMethod(@NotNull Callable task) { + return null; + } + + @Override + public void runTask(Runnable runnable) { + Bukkit.getGlobalRegionScheduler().execute(plugin, runnable); + } + + @Override + public void runTask(Runnable runnable, Location location) { + Bukkit.getRegionScheduler().execute(plugin, location, runnable); + } +} diff --git a/src/main/java/net/momirealms/customcrops/api/object/scheduler/SchedulerPlatform.java b/src/main/java/net/momirealms/customcrops/api/object/scheduler/SchedulerPlatform.java index 85c95cb..3a53f2b 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/scheduler/SchedulerPlatform.java +++ b/src/main/java/net/momirealms/customcrops/api/object/scheduler/SchedulerPlatform.java @@ -17,6 +17,7 @@ package net.momirealms.customcrops.api.object.scheduler; +import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Callable; @@ -27,4 +28,6 @@ public interface SchedulerPlatform { Future callSyncMethod(@NotNull Callable task); void runTask(Runnable runnable); + + void runTask(Runnable runnable, Location location); } diff --git a/src/main/java/net/momirealms/customcrops/integration/quest/BattlePassCCQuest.java b/src/main/java/net/momirealms/customcrops/integration/quest/BattlePassCCQuest.java index 92e759a..190e8d6 100644 --- a/src/main/java/net/momirealms/customcrops/integration/quest/BattlePassCCQuest.java +++ b/src/main/java/net/momirealms/customcrops/integration/quest/BattlePassCCQuest.java @@ -21,6 +21,7 @@ import io.github.battlepass.BattlePlugin; import io.github.battlepass.quests.quests.external.executor.ExternalQuestExecutor; import io.github.battlepass.registry.quest.QuestRegistry; import net.momirealms.customcrops.api.event.CropBreakEvent; +import net.momirealms.customcrops.api.event.CropPlantEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -40,7 +41,16 @@ public class BattlePassCCQuest extends ExternalQuestExecutor implements Listener public void onHarvest(CropBreakEvent event) { if (event.isCancelled()) return; if (event.getEntity() instanceof Player player) { - this.execute("harvest", player, (var1x) -> var1x.root(event.getCropItemID())); + String id = event.getCropItemID(); + String[] split = id.split(":"); + this.execute("harvest", player, (result) -> result.root(split[split.length - 1])); } } -} + + @EventHandler + public void onPlant(CropPlantEvent event) { + if (event.isCancelled()) return; + String id = event.getCrop(); + this.execute("plant", event.getPlayer(), (result) -> result.root(id)); + } +} \ No newline at end of file