From ee74a48dd0edc448fed192d3d19a2b32ef518edc Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Wed, 8 Feb 2023 21:46:12 +0800 Subject: [PATCH] 2.2.4 --- build.gradle | 4 +- libs/BiomeAPI.jar | Bin 0 -> 8037 bytes .../integrations/customplugin/HandlerP.java | 1 + .../oraxen/OraxenFrameHandler.java | 81 +++++-- .../oraxen/OraxenWireHandler.java | 209 ++++++++++++------ .../requirements/RequirementBiome.java | 4 +- 6 files changed, 211 insertions(+), 88 deletions(-) create mode 100644 libs/BiomeAPI.jar diff --git a/build.gradle b/build.gradle index 8e9f960..ca3a463 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '2.2.3' +version = '2.2.4' repositories { mavenCentral() @@ -74,6 +74,7 @@ dependencies { implementation('net.kyori:adventure-text-minimessage:4.12.0') implementation("de.tr7zw:item-nbt-api:2.11.1") implementation("org.bstats:bstats-bukkit:3.0.0") + implementation fileTree(dir:'libs',includes:['BiomeAPI.jar']) } def targetJavaVersion = 17 @@ -109,6 +110,7 @@ shadowJar { relocate ('de.tr7zw', 'net.momirealms.customcrops.libs.de.tr7zw') relocate ('net.kyori', 'net.momirealms.customcrops.libs.net.kyori') relocate ('org.bstats', 'net.momirealms.customcrops.libs.org.bstats') + relocate 'net.momirealms.biomeapi', 'net.momirealms.customcrops.libs.net.momirealms.biomeapi' } tasks.register("delete", Delete).get().delete("build/libs/"+project.name+"-"+project.version+".jar") diff --git a/libs/BiomeAPI.jar b/libs/BiomeAPI.jar new file mode 100644 index 0000000000000000000000000000000000000000..a9c346d1a0990a9b3fdff14650bf650dca470dfa GIT binary patch literal 8037 zcmbVRbzGF&)~2OPYDBuEhjeIZknRwKp}P@~h5?c86i`7x=^h&C?(Pn$p}~M}_|CmY zulL;h{m!@M_rA0LSnFBuo_Ei)*ItjR0x}9F0s=ZZ0>vjeZ3MU>-QD1Z0l$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xe2Q(prYNu;J`nm@V_JIP9#V8A4l`F A82|tP literal 0 HcmV?d00001 diff --git a/src/main/java/net/momirealms/customcrops/integrations/customplugin/HandlerP.java b/src/main/java/net/momirealms/customcrops/integrations/customplugin/HandlerP.java index 31ba350..00e460a 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/customplugin/HandlerP.java +++ b/src/main/java/net/momirealms/customcrops/integrations/customplugin/HandlerP.java @@ -641,6 +641,7 @@ public abstract class HandlerP extends Function { } protected boolean checkHarvestRequirements(Player player, Location location, Crop crop) { + if (player.getGameMode() == GameMode.CREATIVE) return true; PlayerCondition playerCondition = new PlayerCondition(location, player); if (crop.getHarvestRequirements() != null) { for (RequirementInterface requirement : crop.getHarvestRequirements()) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenFrameHandler.java b/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenFrameHandler.java index dcd6667..b4c12c6 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenFrameHandler.java +++ b/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenFrameHandler.java @@ -17,6 +17,9 @@ package net.momirealms.customcrops.integrations.customplugin.oraxen; +import dev.lone.itemsadder.api.CustomBlock; +import dev.lone.itemsadder.api.CustomStack; +import io.th0rgal.oraxen.api.OraxenBlocks; import io.th0rgal.oraxen.api.OraxenItems; import io.th0rgal.oraxen.api.events.OraxenFurnitureBreakEvent; import io.th0rgal.oraxen.api.events.OraxenFurnitureInteractEvent; @@ -24,6 +27,7 @@ import io.th0rgal.oraxen.api.events.OraxenNoteBlockBreakEvent; import io.th0rgal.oraxen.api.events.OraxenNoteBlockInteractEvent; import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory; import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic; +import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic; import io.th0rgal.oraxen.utils.drops.Drop; import net.momirealms.customcrops.api.crop.Crop; import net.momirealms.customcrops.config.BasicItemConfig; @@ -43,6 +47,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.persistence.PersistentDataType; @@ -136,33 +143,65 @@ public class OraxenFrameHandler extends OraxenHandler { } } +// @Override +// public void onInteractNoteBlock(OraxenNoteBlockInteractEvent event) { +// final Player player = event.getPlayer(); +// final ItemStack itemInHand = event.getItemInHand(); +// final Block block = event.getBlock(); +// +// String blockID = event.getMechanic().getItemID(); +// if (!blockID.equals(BasicItemConfig.dryPot) && !blockID.equals(BasicItemConfig.wetPot)) return; +// +// Location potLoc = block.getLocation(); +// Location seedLoc = potLoc.clone().add(0,1,0); +// +// if (super.tryMisc(player, itemInHand, potLoc)) return; +// if (event.getBlockFace() != BlockFace.UP) return; +// +// String id = OraxenItems.getIdByItem(itemInHand); +// if (id != null) { +// if (id.endsWith("_seeds")) { +// String cropName = id.substring(0, id.length() - 6); +// plantSeed(seedLoc, cropName, player, itemInHand); +// } +// } +// else if (MainConfig.enableConvert) { +// String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); +// if (cropName == null) return; +// plantSeed(seedLoc, cropName, player, itemInHand); +// } +// } + @Override - public void onInteractNoteBlock(OraxenNoteBlockInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); - final ItemStack itemInHand = event.getItemInHand(); - final Block block = event.getBlock(); - - String blockID = event.getMechanic().getItemID(); - if (!blockID.equals(BasicItemConfig.dryPot) && !blockID.equals(BasicItemConfig.wetPot)) return; - - Location potLoc = block.getLocation(); - Location seedLoc = potLoc.clone().add(0,1,0); - - if (super.tryMisc(player, itemInHand, potLoc)) return; + if (event.getHand() != EquipmentSlot.HAND) return; + super.onPlayerInteract(event); + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (event.getBlockFace() != BlockFace.UP) return; - - String id = OraxenItems.getIdByItem(itemInHand); - if (id != null) { - if (id.endsWith("_seeds")) { - String cropName = id.substring(0, id.length() - 6); + Block block = event.getClickedBlock(); + if (block == null) return; + NoteBlockMechanic noteBlockMechanic = OraxenBlocks.getNoteBlockMechanic(block); + if (noteBlockMechanic != null) { + final String blockID = noteBlockMechanic.getItemID(); + if (!blockID.equals(BasicItemConfig.wetPot) && !blockID.equals(BasicItemConfig.dryPot)) return; + Location seedLoc = block.getLocation().clone().add(0,1,0); + ItemStack itemInHand = event.getItem(); + Location potLoc = block.getLocation(); + if (super.tryMisc(player, itemInHand, potLoc)) return; + String id = OraxenItems.getIdByItem(itemInHand); + if (id != null) { + if (id.endsWith("_seeds")) { + String cropName = id.substring(0, id.length() - 6); + plantSeed(seedLoc, cropName, player, itemInHand); + } + } + else if (MainConfig.enableConvert) { + String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); + if (cropName == null) return; plantSeed(seedLoc, cropName, player, itemInHand); } } - else if (MainConfig.enableConvert) { - String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); - if (cropName == null) return; - plantSeed(seedLoc, cropName, player, itemInHand); - } } @Override diff --git a/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenWireHandler.java b/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenWireHandler.java index 037eeef..ab8a76e 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenWireHandler.java +++ b/src/main/java/net/momirealms/customcrops/integrations/customplugin/oraxen/OraxenWireHandler.java @@ -17,12 +17,12 @@ package net.momirealms.customcrops.integrations.customplugin.oraxen; +import io.th0rgal.oraxen.api.OraxenBlocks; import io.th0rgal.oraxen.api.OraxenItems; import io.th0rgal.oraxen.api.events.*; import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory; import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic; import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic; -import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory; import io.th0rgal.oraxen.utils.drops.Drop; import net.momirealms.customcrops.api.crop.Crop; import net.momirealms.customcrops.config.BasicItemConfig; @@ -40,6 +40,9 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; public class OraxenWireHandler extends OraxenHandler{ @@ -122,83 +125,159 @@ public class OraxenWireHandler extends OraxenHandler{ } } - @Override - public void onInteractNoteBlock(OraxenNoteBlockInteractEvent event) { - if (event.isCancelled()) return; - - final ItemStack itemInHand = event.getItemInHand(); - final Location potLoc = event.getBlock().getLocation(); - final Player player = event.getPlayer(); - - if (super.tryMisc(event.getPlayer(), itemInHand, potLoc)) return; - if (event.getBlockFace() != BlockFace.UP) return; - - Location seedLoc = potLoc.clone().add(0,1,0); - - String id = OraxenItems.getIdByItem(itemInHand); - if (id != null) { - if (id.endsWith("_seeds")) { - String cropName = id.substring(0, id.length() - 6); - plantSeed(seedLoc, cropName, player, itemInHand); - } - } - else if (MainConfig.enableConvert) { - String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); - if (cropName == null) return; - plantSeed(seedLoc, cropName, player, itemInHand); - } - } +// @Override +// public void onInteractNoteBlock(OraxenNoteBlockInteractEvent event) { +// if (event.isCancelled()) return; +// if (event.getHand() != EquipmentSlot.HAND) return; +// +// final ItemStack itemInHand = event.getItemInHand(); +// final Location potLoc = event.getBlock().getLocation(); +// final Player player = event.getPlayer(); +// +// if (super.tryMisc(event.getPlayer(), itemInHand, potLoc)) return; +// if (event.getBlockFace() != BlockFace.UP) return; +// +// Location seedLoc = potLoc.clone().add(0,1,0); +// +// String id = OraxenItems.getIdByItem(itemInHand); +// if (id != null) { +// if (id.endsWith("_seeds")) { +// String cropName = id.substring(0, id.length() - 6); +// plantSeed(seedLoc, cropName, player, itemInHand); +// } +// } +// else if (MainConfig.enableConvert) { +// String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); +// if (cropName == null) return; +// plantSeed(seedLoc, cropName, player, itemInHand); +// } +// } @Override - public void onInteractStringBlock(OraxenStringBlockInteractEvent event) { - if (event.isCancelled()) return; - + public void onPlayerInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); - final Block block = event.getBlock(); - final String id = event.getMechanic().getItemID(); - - if (!id.contains("_stage_")) return; - - Location seedLoc = block.getLocation(); - ItemStack itemInHand = event.getItemInHand(); - if (!id.equals(BasicItemConfig.deadCrop)) { - if (isRipe(id)) { - if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand != null && itemInHand.getType() != Material.AIR)) { - if (!CCAntiGrief.testBreak(player, seedLoc)) return; - Crop crop = customInterface.getCropFromID(id); - if (crop == null) return; - if (!checkHarvestRequirements(player, seedLoc, crop)) { - event.setCancelled(true); + if (event.getHand() != EquipmentSlot.HAND) return; + super.onPlayerInteract(event); + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; + Block block = event.getClickedBlock(); + if (block == null) return; + Location location = block.getLocation(); + final String blockID = customInterface.getBlockID(location); + if (blockID == null) return; + if (blockID.contains("_stage_")) { + ItemStack itemInHand = event.getItem(); + if (!blockID.equals(BasicItemConfig.deadCrop)) { + if (isRipe(blockID)) { + ItemStack mainHand = player.getInventory().getItemInMainHand(); + ItemStack offHand = player.getInventory().getItemInOffHand(); + if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && (mainHand.getType() != Material.AIR || offHand.getType() != Material.AIR))) { + if (!CCAntiGrief.testBreak(player, location)) return; + Crop crop = customInterface.getCropFromID(blockID); + if (crop == null) return; + if (!checkHarvestRequirements(player, location, crop)) { + event.setCancelled(true); + return; + } + block.setType(Material.AIR); + super.onInteractRipeCrop(location, crop, player); + if (crop.getReturnStage() != null) customInterface.placeWire(location, crop.getReturnStage()); return; } - block.setType(Material.AIR); - super.onInteractRipeCrop(seedLoc, crop, player); - if (crop.getReturnStage() != null) StringBlockMechanicFactory.setBlockModel(seedLoc.getBlock(), crop.getReturnStage()); + } + //has next stage + else if (MainConfig.enableBoneMeal && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) { + if (!CCAntiGrief.testPlace(player, location)) return; + if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1); + if (Math.random() < MainConfig.boneMealChance) { + location.getWorld().spawnParticle(MainConfig.boneMealSuccess, location.clone().add(0.5,0.5, 0.5),3,0.2,0.2,0.2); + if (SoundConfig.boneMeal.isEnable()) { + AdventureUtil.playerSound( + player, + SoundConfig.boneMeal.getSource(), + SoundConfig.boneMeal.getKey(), + 1,1 + ); + } + block.setType(Material.AIR); + customInterface.placeWire(location, customInterface.getNextStage(blockID)); + } return; } } - //has next stage - else if (MainConfig.enableBoneMeal && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) { - if (!CCAntiGrief.testPlace(player, seedLoc)) return; - if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1); - if (Math.random() < MainConfig.boneMealChance) { - seedLoc.getWorld().spawnParticle(MainConfig.boneMealSuccess, seedLoc.clone().add(0.5,0.5, 0.5),3,0.2,0.2,0.2); - if (SoundConfig.boneMeal.isEnable()) { - AdventureUtil.playerSound( - player, - SoundConfig.boneMeal.getSource(), - SoundConfig.boneMeal.getKey(), - 1,1 - ); - } - StringBlockMechanicFactory.setBlockModel(block, customInterface.getNextStage(id)); + super.tryMisc(player, itemInHand, location.clone().subtract(0,1,0)); + } + //interact pot (must have an item) + else if (blockID.equals(BasicItemConfig.wetPot) || blockID.equals(BasicItemConfig.dryPot)) { + ItemStack itemInHand = event.getItem(); + if (super.tryMisc(player, itemInHand, location)) return; + if (event.getBlockFace() != BlockFace.UP) return; + Location seedLoc = location.clone().add(0,1,0); + String id = OraxenItems.getIdByItem(itemInHand); + if (id != null) { + if (id.endsWith("_seeds")) { + String cropName = id.substring(0, id.length() - 6); + plantSeed(seedLoc, cropName, player, itemInHand); } - return; + } + else if (MainConfig.enableConvert) { + String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType()); + if (cropName == null) return; + plantSeed(seedLoc, cropName, player, itemInHand); } } - super.tryMisc(player, event.getItemInHand(), block.getLocation().clone().subtract(0,1,0)); } +// @Override +// public void onInteractStringBlock(OraxenStringBlockInteractEvent event) { +// if (event.isCancelled()) return; +// if (event.getHand() != EquipmentSlot.HAND) return; +// +// final Player player = event.getPlayer(); +// final Block block = event.getBlock(); +// final String id = event.getMechanic().getItemID(); +// +// if (!id.contains("_stage_")) return; +// +// Location seedLoc = block.getLocation(); +// ItemStack itemInHand = event.getItemInHand(); +// if (!id.equals(BasicItemConfig.deadCrop)) { +// if (isRipe(id)) { +// if (MainConfig.canRightClickHarvest && !(MainConfig.emptyHand && itemInHand != null && itemInHand.getType() != Material.AIR)) { +// if (!CCAntiGrief.testBreak(player, seedLoc)) return; +// Crop crop = customInterface.getCropFromID(id); +// if (crop == null) return; +// if (!checkHarvestRequirements(player, seedLoc, crop)) { +// event.setCancelled(true); +// return; +// } +// block.setType(Material.AIR); +// super.onInteractRipeCrop(seedLoc, crop, player); +// if (crop.getReturnStage() != null) StringBlockMechanicFactory.setBlockModel(seedLoc.getBlock(), crop.getReturnStage()); +// return; +// } +// } +// //has next stage +// else if (MainConfig.enableBoneMeal && itemInHand != null && itemInHand.getType() == Material.BONE_MEAL) { +// if (!CCAntiGrief.testPlace(player, seedLoc)) return; +// if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1); +// if (Math.random() < MainConfig.boneMealChance) { +// seedLoc.getWorld().spawnParticle(MainConfig.boneMealSuccess, seedLoc.clone().add(0.5,0.5, 0.5),3,0.2,0.2,0.2); +// if (SoundConfig.boneMeal.isEnable()) { +// AdventureUtil.playerSound( +// player, +// SoundConfig.boneMeal.getSource(), +// SoundConfig.boneMeal.getKey(), +// 1,1 +// ); +// } +// StringBlockMechanicFactory.setBlockModel(block, customInterface.getNextStage(id)); +// } +// return; +// } +// } +// super.tryMisc(player, event.getItemInHand(), block.getLocation().clone().subtract(0,1,0)); +// } + @Override public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) { if (event.isCancelled()) return; diff --git a/src/main/java/net/momirealms/customcrops/objects/requirements/RequirementBiome.java b/src/main/java/net/momirealms/customcrops/objects/requirements/RequirementBiome.java index 98a49cc..1131b22 100644 --- a/src/main/java/net/momirealms/customcrops/objects/requirements/RequirementBiome.java +++ b/src/main/java/net/momirealms/customcrops/objects/requirements/RequirementBiome.java @@ -17,6 +17,8 @@ package net.momirealms.customcrops.objects.requirements; +import net.momirealms.biomeapi.BiomeAPI; + public class RequirementBiome extends Requirement implements RequirementInterface { public RequirementBiome(String[] values, boolean mode, String msg) { @@ -25,7 +27,7 @@ public class RequirementBiome extends Requirement implements RequirementInterfac @Override public boolean isConditionMet(PlayerCondition playerCondition) { - String currentBiome = playerCondition.getLocation().getBlock().getBiome().getKey().toString(); + String currentBiome = BiomeAPI.getBiome(playerCondition.getLocation()); if (mode) { for (String value : values) { if (!(currentBiome.equalsIgnoreCase(value))) {