mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 17:09:21 +00:00
3.4.2.1
This commit is contained in:
@@ -39,6 +39,14 @@ public abstract class VersionManager {
|
||||
return instance.isVersionNewerThan1_19_R2();
|
||||
}
|
||||
|
||||
public static boolean isHigherThan1_19() {
|
||||
return instance.isVersionNewerThan1_19();
|
||||
}
|
||||
|
||||
public static boolean isHigherThan1_20() {
|
||||
return instance.isVersionNewerThan1_20();
|
||||
}
|
||||
|
||||
public static boolean isHigherThan1_20_R2() {
|
||||
return instance.isVersionNewerThan1_20_R2();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
allprojects {
|
||||
|
||||
project.group = "net.momirealms"
|
||||
project.version = "3.4.2.0"
|
||||
project.version = "3.4.2.1"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -67,7 +67,7 @@ tasks {
|
||||
relocate ("net.kyori", "net.momirealms.customcrops.libraries")
|
||||
relocate ("org.objenesis", "net.momirealms.customcrops.libraries.objenesis")
|
||||
relocate ("org.bstats", "net.momirealms.customcrops.libraries.bstats")
|
||||
relocate ("dev.dejvokep.boostedyaml", "net.momirealms.customcrops.libraries.boostedyaml")
|
||||
relocate ("dev.dejvokep.boostedyaml", "net.momirealms.customcrops.libraries.boostedyaml")
|
||||
relocate ("net.momirealms.biomeapi", "net.momirealms.customcrops.libraries.biomeapi")
|
||||
relocate ("net.momirealms.antigrieflib", "net.momirealms.customcrops.libraries.antigrieflib")
|
||||
}
|
||||
|
||||
@@ -2287,17 +2287,16 @@ public class ItemManagerImpl implements ItemManager {
|
||||
public void handlePlayerBreakBlock(
|
||||
Player player,
|
||||
Block brokenBlock,
|
||||
String blockID,
|
||||
Cancellable event
|
||||
) {
|
||||
if (!plugin.getWorldManager().isMechanicEnabled(player.getWorld()))
|
||||
return;
|
||||
|
||||
/*
|
||||
No need to check anti-grief here as the event should be cancelled by the anti-grief plugin
|
||||
*/
|
||||
// check anti-grief
|
||||
if (!antiGrief.canBreak(player, brokenBlock.getLocation()))
|
||||
return;
|
||||
|
||||
// check blocks, no need to check item in hand
|
||||
String blockID = customProvider.getBlockID(brokenBlock);
|
||||
Optional.ofNullable(itemID2FunctionMap.get(blockID))
|
||||
.map(map -> map.get(FunctionTrigger.BREAK))
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new BreakBlockWrapper(player, brokenBlock), event));
|
||||
@@ -2340,9 +2339,9 @@ public class ItemManagerImpl implements ItemManager {
|
||||
if (!plugin.getWorldManager().isMechanicEnabled(player.getWorld()))
|
||||
return;
|
||||
|
||||
/*
|
||||
No need to check anti-grief here as the event should be cancelled by the anti-grief plugin
|
||||
*/
|
||||
// check anti-grief
|
||||
if (!antiGrief.canPlace(player, location))
|
||||
return;
|
||||
|
||||
// check furniture, no need to check item in hand
|
||||
Optional.ofNullable(itemID2FunctionMap.get(id))
|
||||
@@ -2359,9 +2358,9 @@ public class ItemManagerImpl implements ItemManager {
|
||||
if (!plugin.getWorldManager().isMechanicEnabled(player.getWorld()))
|
||||
return;
|
||||
|
||||
/*
|
||||
No need to check anti-grief here as the event should be handled by ItemsAdder/Oraxen
|
||||
*/
|
||||
// check anti-grief
|
||||
if (!antiGrief.canBreak(player, location))
|
||||
return;
|
||||
|
||||
// check furniture, no need to check item in hand
|
||||
Optional.ofNullable(itemID2FunctionMap.get(id))
|
||||
@@ -2373,9 +2372,9 @@ public class ItemManagerImpl implements ItemManager {
|
||||
if (!plugin.getWorldManager().isMechanicEnabled(player.getWorld()))
|
||||
return;
|
||||
|
||||
/*
|
||||
No need to check anti-grief here as the event should be cancelled by the anti-grief plugin
|
||||
*/
|
||||
// check anti-grief
|
||||
if (!antiGrief.canPlace(player, block.getLocation()))
|
||||
return;
|
||||
|
||||
// check furniture, no need to check item in hand
|
||||
Optional.ofNullable(itemID2FunctionMap.get(blockID))
|
||||
@@ -2383,9 +2382,9 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new PlaceBlockWrapper(player, block, blockID), event));
|
||||
}
|
||||
|
||||
public void handleEntityBreakBlock(Entity entity, Block block, Cancellable event) {
|
||||
public void handleEntityTramplingBlock(Entity entity, Block block, Cancellable event) {
|
||||
if (entity instanceof Player player) {
|
||||
handlePlayerBreakBlock(player, block, event);
|
||||
handlePlayerBreakBlock(player, block, "FARMLAND", event);
|
||||
} else {
|
||||
// if the block is a pot
|
||||
Pot pot = getPotByBlock(block);
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customcrops.mechanic.item.custom;
|
||||
import net.momirealms.customcrops.api.CustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.event.BoneMealDispenseEvent;
|
||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
||||
import net.momirealms.customcrops.api.manager.VersionManager;
|
||||
import net.momirealms.customcrops.api.manager.WorldManager;
|
||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||
import net.momirealms.customcrops.api.mechanic.requirement.State;
|
||||
@@ -49,14 +50,51 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class AbstractCustomListener implements Listener {
|
||||
|
||||
protected ItemManagerImpl itemManager;
|
||||
private final HashSet<Material> CUSTOM_MATERIAL = new HashSet<>();
|
||||
|
||||
public AbstractCustomListener(ItemManagerImpl itemManager) {
|
||||
this.itemManager = itemManager;
|
||||
this.CUSTOM_MATERIAL.addAll(
|
||||
List.of(
|
||||
Material.NOTE_BLOCK,
|
||||
Material.MUSHROOM_STEM,
|
||||
Material.BROWN_MUSHROOM_BLOCK,
|
||||
Material.RED_MUSHROOM_BLOCK,
|
||||
Material.TRIPWIRE,
|
||||
Material.CHORUS_PLANT,
|
||||
Material.CHORUS_FLOWER,
|
||||
Material.ACACIA_LEAVES,
|
||||
Material.BIRCH_LEAVES,
|
||||
Material.JUNGLE_LEAVES,
|
||||
Material.DARK_OAK_LEAVES,
|
||||
Material.AZALEA_LEAVES,
|
||||
Material.FLOWERING_AZALEA_LEAVES,
|
||||
Material.OAK_LEAVES,
|
||||
Material.SPRUCE_LEAVES,
|
||||
Material.CAVE_VINES,
|
||||
Material.TWISTING_VINES,
|
||||
Material.WEEPING_VINES,
|
||||
Material.KELP,
|
||||
Material.CACTUS
|
||||
)
|
||||
);
|
||||
if (VersionManager.isHigherThan1_19()) {
|
||||
this.CUSTOM_MATERIAL.add(
|
||||
Material.MANGROVE_LEAVES
|
||||
);
|
||||
}
|
||||
if (VersionManager.isHigherThan1_20()) {
|
||||
this.CUSTOM_MATERIAL.add(
|
||||
Material.CHERRY_LEAVES
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
@@ -92,9 +130,15 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
@EventHandler (ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
public void onBreakBlock(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Material type = block.getType();
|
||||
// custom block should be handled by other plugins' events
|
||||
if (CUSTOM_MATERIAL.contains(type))
|
||||
return;
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
player,
|
||||
event.getBlock(),
|
||||
block,
|
||||
type.name(),
|
||||
event
|
||||
);
|
||||
}
|
||||
@@ -160,7 +204,7 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
itemManager.handleEntityBreakBlock(event.getEntity(), block, event);
|
||||
itemManager.handleEntityTramplingBlock(event.getEntity(), block, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
package net.momirealms.customcrops.mechanic.item.custom.itemsadder;
|
||||
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import dev.lone.itemsadder.api.Events.CustomBlockPlaceEvent;
|
||||
import dev.lone.itemsadder.api.Events.FurnitureBreakEvent;
|
||||
import dev.lone.itemsadder.api.Events.FurnitureInteractEvent;
|
||||
import dev.lone.itemsadder.api.Events.FurniturePlaceSuccessEvent;
|
||||
import dev.lone.itemsadder.api.Events.*;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -33,6 +30,16 @@ public class ItemsAdderListener extends AbstractCustomListener {
|
||||
super(itemManager);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakCustomBlock(CustomBlockBreakEvent event) {
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getNamespacedID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceCustomBlock(CustomBlockPlaceEvent event) {
|
||||
super.onPlaceBlock(
|
||||
|
||||
@@ -20,7 +20,9 @@ package net.momirealms.customcrops.mechanic.item.custom.oraxen;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockPlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockPlaceEvent;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
@@ -32,6 +34,26 @@ public class OraxenListener extends AbstractCustomListener {
|
||||
super(itemManager);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakCustomNoteBlock(OraxenNoteBlockBreakEvent event) {
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakCustomStringBlock(OraxenStringBlockBreakEvent event) {
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceCustomBlock(OraxenNoteBlockPlaceEvent event) {
|
||||
super.onPlaceBlock(
|
||||
|
||||
Reference in New Issue
Block a user