mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 08:29:35 +00:00
no change
This commit is contained in:
@@ -14,7 +14,6 @@ public class Placeholders extends PlaceholderExpansion{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "customcrops";
|
||||
|
||||
@@ -13,12 +13,10 @@ public class BreakFurniture implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void breakFurniture(EntitySpawnEvent event){
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
Entity entity = event.getEntity();
|
||||
if(!(entity instanceof Item)){
|
||||
return;
|
||||
}
|
||||
if(!(entity instanceof Item)) return;
|
||||
if(CustomStack.byItemStack(((Item) entity).getItemStack()) != null){
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
if(CustomStack.byItemStack(((Item) entity).getItemStack()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1"))){
|
||||
entity.remove();
|
||||
entity.getWorld().dropItem(entity.getLocation() ,CustomStack.getInstance(config.getString("config.sprinkler-1-item")).getItemStack());
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package net.momirealms.customcrops.listener;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.DataManager.MaxSprinklersPerChunk;
|
||||
@@ -33,11 +29,11 @@ public class RightClickBlock implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void rightClickBlock(PlayerInteractEvent event){
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
if(!event.hasItem()){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!event.hasItem()) return;
|
||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
|
||||
if(CustomStack.byItemStack(event.getItem()) == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = event.getItem();
|
||||
//水壶加水
|
||||
@@ -54,10 +50,12 @@ public class RightClickBlock implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
if(event.getBlockFace() != BlockFace.UP) return;
|
||||
if(CustomStack.byItemStack(event.getItem()) == null) return;
|
||||
|
||||
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
Location location = event.getClickedBlock().getLocation();
|
||||
//res兼容
|
||||
if(config.getBoolean("config.integration.residence")){
|
||||
@@ -82,7 +80,6 @@ public class RightClickBlock implements Listener {
|
||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.not-a-good-place"),player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(CustomStack.byItemStack(event.getItem()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1-item"))){
|
||||
if(MaxSprinklersPerChunk.maxSprinklersPerChunk(location)){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-sprinkler").replace("{Max}", config.getString("config.max-sprinklers")),player);
|
||||
@@ -107,18 +104,16 @@ public class RightClickBlock implements Listener {
|
||||
}
|
||||
private void addWater(ItemStack itemStack, Player player){
|
||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||
if(CustomStack.byItemStack(itemStack)!= null){
|
||||
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
||||
if(customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-1")) ||
|
||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-2")) ||
|
||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-3")))
|
||||
{
|
||||
if(customStack.getMaxDurability() == customStack.getDurability()){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.can-full"),player);
|
||||
}else {
|
||||
customStack.setDurability(customStack.getDurability() + 1);
|
||||
player.playSound(player, Sound.ITEM_BUCKET_FILL,1,1);
|
||||
}
|
||||
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
||||
if(customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-1")) ||
|
||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-2")) ||
|
||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-3")))
|
||||
{
|
||||
if(customStack.getMaxDurability() == customStack.getDurability()){
|
||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.can-full"),player);
|
||||
}else {
|
||||
customStack.setDurability(customStack.getDurability() + 1);
|
||||
player.playSound(player, Sound.ITEM_BUCKET_FILL,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class RightClickCustomBlock implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//空手收获农作物
|
||||
if (event.getItem() == null) {
|
||||
if(config.getBoolean("config.integration.residence")){
|
||||
if(ResidenceIntegrations.checkResHarvest(clickedBlockLocation,player)){
|
||||
@@ -61,11 +62,13 @@ public class RightClickCustomBlock implements Listener {
|
||||
clickedBlockLocation.getWorld().dropItem(clickedBlockLocation.clone().add(0.5,0.2,0.5),itemStack);
|
||||
});
|
||||
CustomBlock.remove(clickedBlockLocation);
|
||||
//如果配置文件有配置则返回第几阶段
|
||||
if(config.getConfigurationSection("crops." + cropNameList[0]).getKeys(false).contains("return")){
|
||||
CustomBlock.place(config.getString("crops." + cropNameList[0] + ".return"), clickedBlockLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
//res兼容
|
||||
if(config.getBoolean("config.integration.residence")){
|
||||
@@ -73,17 +76,14 @@ public class RightClickCustomBlock implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//wg兼容
|
||||
if(config.getBoolean("config.integration.worldguard")){
|
||||
if(WorldGuardIntegrations.checkWGBuild(clickedBlockLocation,player)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
ItemStack mainHandItem = player.getInventory().getItemInMainHand();
|
||||
|
||||
//右键的作物下方是否为自定义方块
|
||||
if (CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation.clone().subtract(0,1,0))) != null && clickedBlock.getType() == Material.TRIPWIRE) {
|
||||
//检测右键的方块下方是否为干燥的种植盆方块
|
||||
@@ -152,14 +152,12 @@ public class RightClickCustomBlock implements Listener {
|
||||
}
|
||||
//检测右键的方块是否为湿润的种植盆方块
|
||||
}else if(CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.watered-pot"))){
|
||||
|
||||
tryPlantSeed(clickedBlockLocation, mainHandItem, player, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
//尝试种植植物
|
||||
private void tryPlantSeed(Location clickedBlockLocation, ItemStack mainHandItem, Player player, FileConfiguration config) {
|
||||
|
||||
if(CustomStack.byItemStack(mainHandItem) == null) return;
|
||||
if (CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().endsWith("_seeds")){
|
||||
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
||||
@@ -221,9 +219,7 @@ public class RightClickCustomBlock implements Listener {
|
||||
private void waterPot(ItemStack itemStack, Player player, Location location, FileConfiguration config){
|
||||
|
||||
if(CustomStack.byItemStack(itemStack) == null) return;
|
||||
|
||||
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
||||
|
||||
if(customStack.getDurability() > 0){
|
||||
CustomStack.byItemStack(itemStack).setDurability(CustomStack.byItemStack(itemStack).getDurability() - 1);
|
||||
}else return;
|
||||
|
||||
Reference in New Issue
Block a user