diff --git a/build.gradle b/build.gradle index 0894f24..5721338 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { group = 'net.momirealms' -version = '1.5.9' +version = '1.5.10' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customcrops/ConfigReader.java b/src/main/java/net/momirealms/customcrops/ConfigReader.java index f046d5a..7e20999 100644 --- a/src/main/java/net/momirealms/customcrops/ConfigReader.java +++ b/src/main/java/net/momirealms/customcrops/ConfigReader.java @@ -71,6 +71,7 @@ public class ConfigReader { public static String referenceWorld; public static boolean asyncCheck; public static boolean enableLimit; + public static boolean hasParticle; public static int cropLimit; public static int sprinklerLimit; public static int yMin; @@ -109,6 +110,7 @@ public class ConfigReader { logTime = config.getBoolean("config.log-time-consume",false); onlyLoadedGrow = !config.getBoolean("config.only-grow-in-loaded-chunks",true); allWorld = config.getBoolean("config.all-world-grow",false); + hasParticle = config.getBoolean("config.water-particles", true); //数量与高度限制 enableLimit = config.getBoolean("config.limit.enable",true); @@ -523,26 +525,32 @@ public class ConfigReader { public static Key useFertilizerKey; public static net.kyori.adventure.sound.Sound.Source useFertilizerSource; + public static Key harvestKey; + public static net.kyori.adventure.sound.Sound.Source harvestSource; + public static void loadSound(){ YamlConfiguration config = getConfig("sounds.yml"); - waterPotKey = Key.key(config.getString("water-pot.sound")); - waterPotSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("water-pot.type").toUpperCase()); + waterPotKey = Key.key(config.getString("water-pot.sound", "minecraft:block.water.ambient")); + waterPotSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("water-pot.type","player").toUpperCase()); - addWaterToCanKey = Key.key(config.getString("add-water-to-can.sound")); - addWaterToCanSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-can.type").toUpperCase()); + addWaterToCanKey = Key.key(config.getString("add-water-to-can.sound", "minecraft:item.bucket.fill")); + addWaterToCanSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-can.type","player").toUpperCase()); - addWaterToSprinklerKey = Key.key(config.getString("add-water-to-sprinkler.sound")); - addWaterToSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-sprinkler.type").toUpperCase()); + addWaterToSprinklerKey = Key.key(config.getString("add-water-to-sprinkler.sound", "minecraft:item.bucket.fill")); + addWaterToSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-sprinkler.type","player").toUpperCase()); - placeSprinklerKey = Key.key(config.getString("place-sprinkler.sound")); - placeSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("place-sprinkler.type").toUpperCase()); + placeSprinklerKey = Key.key(config.getString("place-sprinkler.sound", "minecraft:block.bone_block.place")); + placeSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("place-sprinkler.type","player").toUpperCase()); - plantSeedKey = Key.key(config.getString("plant-seed.sound")); - plantSeedSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("plant-seed.type").toUpperCase()); + plantSeedKey = Key.key(config.getString("plant-seed.sound", "minecraft:item.hoe.till")); + plantSeedSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("plant-seed.type","player").toUpperCase()); - useFertilizerKey = Key.key(config.getString("use-fertilizer.sound")); - useFertilizerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("use-fertilizer.type").toUpperCase()); + useFertilizerKey = Key.key(config.getString("use-fertilizer.sound", "minecraft:item.hoe.till")); + useFertilizerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("use-fertilizer.type","player").toUpperCase()); + + harvestKey = Key.key(config.getString("harvest.sound", "minecraft:block.crop.break")); + harvestSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("harvest.type", "player").toUpperCase()); } } } diff --git a/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java b/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java index fc01b99..15072cd 100644 --- a/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java +++ b/src/main/java/net/momirealms/customcrops/listener/InteractEntity.java @@ -31,6 +31,7 @@ import net.momirealms.customcrops.utils.Sprinkler; import net.momirealms.customcrops.utils.WateringCan; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -77,7 +78,6 @@ public class InteractEntity implements Listener { Sprinkler sprinkler = SprinklerManager.Cache.get(loc); if (itemStack.getType() == Material.WATER_BUCKET){ itemStack.setType(Material.BUCKET); - AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey); if (sprinkler != null){ currentWater = sprinkler.getWater(); currentWater += ConfigReader.Config.sprinklerRefill; @@ -94,6 +94,7 @@ public class InteractEntity implements Listener { } plugin.getSprinklerManager().data.set(path, currentWater); } + AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey); } else { if (ConfigReader.Config.canAddWater && itemStack.getType() != Material.AIR){ diff --git a/src/main/java/net/momirealms/customcrops/listener/RightClick.java b/src/main/java/net/momirealms/customcrops/listener/RightClick.java index dc55e53..7ba1ed9 100644 --- a/src/main/java/net/momirealms/customcrops/listener/RightClick.java +++ b/src/main/java/net/momirealms/customcrops/listener/RightClick.java @@ -39,10 +39,7 @@ import net.momirealms.customcrops.requirements.PlantingCondition; import net.momirealms.customcrops.requirements.Requirement; import net.momirealms.customcrops.utils.*; import org.apache.commons.lang.StringUtils; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -159,6 +156,7 @@ public class RightClick implements Listener { } nbtItem.setInteger("WaterAmount", water); player.getWorld().playSound(player.getLocation(), Sound.ITEM_BUCKET_FILL,1,1); + if (ConfigReader.Message.hasWaterInfo){ String string = ConfigReader.Message.waterLeft + ConfigReader.Message.waterFull.repeat(water) + ConfigReader.Message.waterEmpty.repeat(wateringCan.getMax() - water) + ConfigReader.Message.waterRight; @@ -171,6 +169,9 @@ public class RightClick implements Listener { lores.clear(); ConfigReader.Basic.waterLore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(lore.replace("{water_info}", string))))); } + if (ConfigReader.Config.hasParticle){ + player.getWorld().spawnParticle(Particle.WATER_SPLASH, block.getLocation().add(0.5,1, 0.5),15,0.1,0.1,0.1); + } itemStack.setItemMeta(nbtItem.getItem().getItemMeta()); } return; @@ -201,7 +202,7 @@ public class RightClick implements Listener { ConfigReader.Basic.waterLore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(lore.replace("{water_info}", string))))); } itemStack.setItemMeta(nbtItem.getItem().getItemMeta()); - }else if (namespacedID.contains("_stage_")){ + } else if (namespacedID.contains("_stage_")){ nbtItem.setInteger("WaterAmount", water - 1); AdventureManager.playerSound(player, ConfigReader.Sounds.waterPotSource, ConfigReader.Sounds.waterPotKey); waterPot(wateringCan.getWidth(), wateringCan.getLength(), block.getLocation().subtract(0,1,0), player.getLocation().getYaw()); @@ -363,6 +364,7 @@ public class RightClick implements Listener { } CustomBlock.remove(location); CropInstance crop = ConfigReader.CROPS.get(cropNameList[0]); + AdventureManager.playerSound(player, ConfigReader.Sounds.harvestSource, ConfigReader.Sounds.harvestKey); if(crop.getReturnStage() != null){ CustomBlock.place(crop.getReturnStage(), location); } @@ -390,7 +392,10 @@ public class RightClick implements Listener { } } - private void waterPot(int width, int length, Location clickedLocation, float yaw){ + private void waterPot(int width, int length, Location location, float yaw){ + if (ConfigReader.Config.hasParticle){ + location.getWorld().spawnParticle(Particle.WATER_SPLASH, location.clone().add(0.5,1.2,0.5),15,0.1,0.1, 0.1); + } int extend = width / 2; // -90~90 z+ // -180~-90 & 90-180 z- @@ -400,7 +405,7 @@ public class RightClick implements Listener { // -45 ~ 45 if (yaw > -45) { for (int i = -extend; i <= extend; i++) { - Location tempLoc = clickedLocation.clone().add(i, 0, -1); + Location tempLoc = location.clone().add(i, 0, -1); for (int j = 0; j < length; j++){ tempLoc.add(0,0,1); CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); @@ -416,7 +421,7 @@ public class RightClick implements Listener { // -135 ~ -45 else { for (int i = -extend; i <= extend; i++) { - Location tempLoc = clickedLocation.clone().add(-1, 0, i); + Location tempLoc = location.clone().add(-1, 0, i); for (int j = 0; j < length; j++){ tempLoc.add(1,0,0); CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); @@ -434,7 +439,7 @@ public class RightClick implements Listener { // 45 ~ 135 if (yaw > 45 && yaw < 135) { for (int i = -extend; i <= extend; i++) { - Location tempLoc = clickedLocation.clone().add(1, 0, i); + Location tempLoc = location.clone().add(1, 0, i); for (int j = 0; j < length; j++){ tempLoc.subtract(1,0,0); CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); @@ -450,7 +455,7 @@ public class RightClick implements Listener { // -180 ~ -135 135~180 else { for (int i = -extend; i <= extend; i++) { - Location tempLoc = clickedLocation.clone().add(i, 0, 1); + Location tempLoc = location.clone().add(i, 0, 1); for (int j = 0; j < length; j++){ tempLoc.subtract(0,0,1); CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock()); diff --git a/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java b/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java index af7340b..c834dd2 100644 --- a/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java +++ b/src/main/java/net/momirealms/customcrops/utils/SimpleLocation.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customcrops.utils; import org.bukkit.Location; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6922b62..a661cc0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -43,6 +43,8 @@ config: water-can-refill: 1 #是否可以用水壶为洒水器加水 water-can-add-water-to-sprinkler: true + #使用水的时候是否产生粒子效果 + water-particles: true #生长生效的世界 whitelist-worlds: diff --git a/src/main/resources/sounds.yml b/src/main/resources/sounds.yml index 12474df..28548b4 100644 --- a/src/main/resources/sounds.yml +++ b/src/main/resources/sounds.yml @@ -21,4 +21,8 @@ plant-seed: #使用肥料的音效 use-fertilizer: sound: minecraft:item.hoe.till + type: player +#空手收获的音效 +harvest: + sound: minecraft:block.crop.break type: player \ No newline at end of file