mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 11:29:19 +00:00
Check point for future big changes
This commit is contained in:
@@ -36,6 +36,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -100,6 +101,18 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBlockFalling(EntityChangeBlockEvent event) {
|
||||
if (event.getEntity() instanceof FallingBlock fallingBlock) {
|
||||
final Block block = event.getBlock();
|
||||
final Location location = block.getLocation();
|
||||
Optional<CustomCropsBlock> customCropsBlock = CustomCropsPlugin.get().getWorldManager().getBlockAt(SimpleLocation.of(location));
|
||||
if (customCropsBlock.isPresent()) {
|
||||
fallingBlock.setCancelDrop(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onInteractBlock(PlayerInteractEvent event) {
|
||||
if (event.getHand() != EquipmentSlot.HAND)
|
||||
|
||||
@@ -69,29 +69,27 @@ public interface CustomProvider {
|
||||
}
|
||||
|
||||
default CRotation removeAnythingAt(Location location) {
|
||||
if (!removeBlock(location)) {
|
||||
Collection<Entity> entities = location.getWorld().getNearbyEntities(LocationUtils.toCenterLocation(location), 0.5,0.51,0.5);
|
||||
entities.removeIf(entity -> {
|
||||
EntityType type = entity.getType();
|
||||
return type != EntityType.ITEM_FRAME
|
||||
&& (!VersionManager.isHigherThan1_19_R3() || type != EntityType.ITEM_DISPLAY);
|
||||
});
|
||||
if (entities.size() == 0) return CRotation.NONE;
|
||||
CRotation previousCRotation;
|
||||
Entity first = entities.stream().findFirst().get();
|
||||
if (first instanceof ItemFrame itemFrame) {
|
||||
previousCRotation = CRotation.getByRotation(itemFrame.getRotation());
|
||||
} else if (VersionManager.isHigherThan1_19_R3()) {
|
||||
previousCRotation = DisplayEntityUtils.getRotation(first);
|
||||
} else {
|
||||
previousCRotation = CRotation.NONE;
|
||||
}
|
||||
for (Entity entity : entities) {
|
||||
removeFurniture(entity);
|
||||
}
|
||||
return previousCRotation;
|
||||
removeBlock(location);
|
||||
Collection<Entity> entities = location.getWorld().getNearbyEntities(LocationUtils.toCenterLocation(location), 0.5,0.51,0.5);
|
||||
entities.removeIf(entity -> {
|
||||
EntityType type = entity.getType();
|
||||
return type != EntityType.ITEM_FRAME
|
||||
&& (!VersionManager.isHigherThan1_19_R3() || type != EntityType.ITEM_DISPLAY);
|
||||
});
|
||||
if (entities.isEmpty()) return CRotation.NONE;
|
||||
CRotation previousCRotation;
|
||||
Entity first = entities.stream().findFirst().get();
|
||||
if (first instanceof ItemFrame itemFrame) {
|
||||
previousCRotation = CRotation.getByRotation(itemFrame.getRotation());
|
||||
} else if (VersionManager.isHigherThan1_19_R3()) {
|
||||
previousCRotation = DisplayEntityUtils.getRotation(first);
|
||||
} else {
|
||||
previousCRotation = CRotation.NONE;
|
||||
}
|
||||
return CRotation.NONE;
|
||||
for (Entity entity : entities) {
|
||||
removeFurniture(entity);
|
||||
}
|
||||
return previousCRotation;
|
||||
}
|
||||
|
||||
default String getSomethingAt(Location location) {
|
||||
|
||||
Reference in New Issue
Block a user