diff --git a/build.gradle b/build.gradle index 9e8aa3f..f22b7b4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { group = 'net.momirealms' -version = '1.6.1.2' +version = '1.6.3.2' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customcrops/ConfigReader.java b/src/main/java/net/momirealms/customcrops/ConfigReader.java index 66fd5b4..8fde6cf 100644 --- a/src/main/java/net/momirealms/customcrops/ConfigReader.java +++ b/src/main/java/net/momirealms/customcrops/ConfigReader.java @@ -182,39 +182,43 @@ public class ConfigReader { integration = new ArrayList<>(); if (config.getBoolean("config.integration.Residence",false)){ if (Bukkit.getPluginManager().getPlugin("Residence") == null) Log.warn("Failed to initialize Residence!"); - else {integration.add(new Residence());hookMessage("Residence");} + else {integration.add(new ResidenceIntegration());hookMessage("Residence");} } if (config.getBoolean("config.integration.Kingdoms",false)){ if (Bukkit.getPluginManager().getPlugin("Kingdoms") == null) Log.warn("Failed to initialize Kingdoms!"); - else {integration.add(new KingdomsX());hookMessage("Kingdoms");} + else {integration.add(new KingdomsXIntegration());hookMessage("Kingdoms");} } if (config.getBoolean("config.integration.WorldGuard",false)){ if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) Log.warn("Failed to initialize WorldGuard!"); - else {integration.add(new WorldGuard());hookMessage("WorldGuard");} + else {integration.add(new WorldGuardIntegration());hookMessage("WorldGuard");} } if (config.getBoolean("config.integration.GriefDefender",false)){ if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null) Log.warn("Failed to initialize GriefDefender!"); - else {integration.add(new GriefDefender());hookMessage("GriefDefender");} + else {integration.add(new GriefDefenderIntegration());hookMessage("GriefDefender");} } if (config.getBoolean("config.integration.PlotSquared",false)){ if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null) Log.warn("Failed to initialize PlotSquared!"); - else {integration.add(new PlotSquared());hookMessage("PlotSquared");} + else {integration.add(new PlotSquaredIntegration());hookMessage("PlotSquared");} } if (config.getBoolean("config.integration.Towny",false)){ if (Bukkit.getPluginManager().getPlugin("Towny") == null) Log.warn("Failed to initialize Towny!"); - else {integration.add(new Towny());hookMessage("Towny");} + else {integration.add(new TownyIntegration());hookMessage("Towny");} } if (config.getBoolean("config.integration.Lands",false)){ if (Bukkit.getPluginManager().getPlugin("Lands") == null) Log.warn("Failed to initialize Lands!"); - else {integration.add(new Lands());hookMessage("Lands");} + else {integration.add(new LandsIntegration());hookMessage("Lands");} } if (config.getBoolean("config.integration.GriefPrevention",false)){ if (Bukkit.getPluginManager().getPlugin("GriefPrevention") == null) Log.warn("Failed to initialize GriefPrevention!"); - else {integration.add(new GriefPrevention());hookMessage("GriefPrevention");} + else {integration.add(new GriefPreventionIntegration());hookMessage("GriefPrevention");} } if (config.getBoolean("config.integration.CrashClaim",false)){ if (Bukkit.getPluginManager().getPlugin("CrashClaim") == null) Log.warn("Failed to initialize CrashClaim!"); - else {integration.add(new CrashClaim());hookMessage("CrashClaim");} + else {integration.add(new CrashClaimIntegration());hookMessage("CrashClaim");} + } + if (config.getBoolean("config.integration.BentoBox",false)){ + if (Bukkit.getPluginManager().getPlugin("BentoBox") == null) Log.warn("Failed to initialize BentoBox!"); + else {integration.add(new BentoBoxIntegration());hookMessage("BentoBox");} } realisticSeason = false; @@ -226,23 +230,23 @@ public class ConfigReader { skillXP = null; if (config.getBoolean("config.integration.mcMMO",false)){ if (Bukkit.getPluginManager().getPlugin("mcMMO") == null) Log.warn("Failed to initialize mcMMO!"); - else {skillXP = new mcMMO();hookMessage("mcMMO");} + else {skillXP = new mcMMOIntegration();hookMessage("mcMMO");} } if (config.getBoolean("config.integration.AureliumSkills",false)){ if (Bukkit.getPluginManager().getPlugin("AureliumSkills") == null) Log.warn("Failed to initialize AureliumSkills!"); - else {skillXP = new Aurelium();hookMessage("AureliumSkills");} + else {skillXP = new AureliumIntegration();hookMessage("AureliumSkills");} } if(config.getBoolean("config.integration.MMOCore",false)){ if(Bukkit.getPluginManager().getPlugin("MMOCore") == null) Log.warn("Failed to initialize MMOCore!"); - else {skillXP = new MMOCore();hookMessage("MMOCore");} + else {skillXP = new MMOCoreIntegration();hookMessage("MMOCore");} } if(config.getBoolean("config.integration.EcoSkills",false)){ if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null) Log.warn("Failed to initialize EcoSkills!"); - else {skillXP = new EcoSkill();hookMessage("EcoSkills");} + else {skillXP = new EcoSkillsIntegration();hookMessage("EcoSkills");} } if(config.getBoolean("config.integration.JobsReborn",false)){ if(Bukkit.getPluginManager().getPlugin("Jobs") == null) Log.warn("Failed to initialize Jobs!"); - else {skillXP = new JobsReborn();hookMessage("JobsReborn");} + else {skillXP = new JobsRebornIntegration();hookMessage("JobsReborn");} } } } diff --git a/src/main/java/net/momirealms/customcrops/CustomCrops.java b/src/main/java/net/momirealms/customcrops/CustomCrops.java index cf9bb1e..bbbd1b0 100644 --- a/src/main/java/net/momirealms/customcrops/CustomCrops.java +++ b/src/main/java/net/momirealms/customcrops/CustomCrops.java @@ -76,10 +76,9 @@ public final class CustomCrops extends JavaPlugin { AdventureManager.consoleMessage("[CustomCrops] Running on " + Bukkit.getVersion()); ConfigReader.reloadConfig(); - if (!Objects.equals(ConfigReader.Config.version, "5")){ + if (!Objects.equals(ConfigReader.Config.version, "6")){ ConfigUtil.update(); } - if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){ placeholders = new Placeholders(); placeholders.register(); diff --git a/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java b/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java index ed50d09..dc0e7f1 100644 --- a/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java +++ b/src/main/java/net/momirealms/customcrops/datamanager/PotManager.java @@ -56,17 +56,22 @@ public class PotManager { String key = map.getString("fertilizer"); Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(key); if (fertilizer == null) return; - if (fertilizer instanceof SpeedGrow){ + if (fertilizer instanceof SpeedGrow speedGrowConfig){ SpeedGrow speedGrow = new SpeedGrow(key, map.getInt("times")); + speedGrow.setChance(speedGrowConfig.getChance()); Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), speedGrow); - }else if (fertilizer instanceof QualityCrop){ + }else if (fertilizer instanceof QualityCrop qualityCropConfig){ QualityCrop qualityCrop = new QualityCrop(key, map.getInt("times")); + qualityCrop.setChance(qualityCropConfig.getChance()); Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), qualityCrop); - }else if (fertilizer instanceof RetainingSoil){ + }else if (fertilizer instanceof RetainingSoil retainingSoilConfig){ RetainingSoil retainingSoil = new RetainingSoil(key, map.getInt("times")); + retainingSoil.setChance(retainingSoilConfig.getChance()); Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), retainingSoil); - }else if(fertilizer instanceof YieldIncreasing){ + }else if(fertilizer instanceof YieldIncreasing yieldIncreasingConfig){ YieldIncreasing yieldIncreasing = new YieldIncreasing(key, map.getInt("times")); + yieldIncreasing.setChance(yieldIncreasingConfig.getChance()); + yieldIncreasing.setBonus(yieldIncreasingConfig.getBonus()); Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), yieldIncreasing); }else { AdventureManager.consoleMessage("[CustomCrops] 未知肥料类型错误!"); diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/BentoBoxIntegration.java b/src/main/java/net/momirealms/customcrops/integrations/protection/BentoBoxIntegration.java new file mode 100644 index 0000000..f529032 --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/BentoBoxIntegration.java @@ -0,0 +1,44 @@ +/* + * 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.integrations.protection; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.lists.Flags; + +import java.util.Optional; + +public class BentoBoxIntegration implements Integration{ + + @Override + public boolean canBreak(Location location, Player player) { + User user = User.getInstance(player); + Optional islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location); + return islandOptional.map(island -> island.isAllowed(user, Flags.BREAK_BLOCKS)).orElse(true); + } + + @Override + public boolean canPlace(Location location, Player player) { + User user = User.getInstance(player); + Optional islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location); + return islandOptional.map(island -> island.isAllowed(user, Flags.PLACE_BLOCKS)).orElse(true); + } +} diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaim.java b/src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaimIntegration.java similarity index 96% rename from src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaim.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaimIntegration.java index 91a38a1..fc9f092 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaim.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/CrashClaimIntegration.java @@ -22,7 +22,7 @@ import net.crashcraft.crashclaim.permissions.PermissionRoute; import org.bukkit.Location; import org.bukkit.entity.Player; -public class CrashClaim implements Integration{ +public class CrashClaimIntegration implements Integration{ @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefender.java b/src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefenderIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefender.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefenderIntegration.java index 7f62b83..83b4d0a 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefender.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/GriefDefenderIntegration.java @@ -20,7 +20,7 @@ package net.momirealms.customcrops.integrations.protection; import org.bukkit.Location; import org.bukkit.entity.Player; -public class GriefDefender implements Integration { +public class GriefDefenderIntegration implements Integration { @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/GriefPrevention.java b/src/main/java/net/momirealms/customcrops/integrations/protection/GriefPreventionIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/protection/GriefPrevention.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/GriefPreventionIntegration.java index 41fc1dd..9f58c97 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/GriefPrevention.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/GriefPreventionIntegration.java @@ -20,7 +20,7 @@ package net.momirealms.customcrops.integrations.protection; import org.bukkit.Location; import org.bukkit.entity.Player; -public class GriefPrevention implements Integration{ +public class GriefPreventionIntegration implements Integration{ @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsX.java b/src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsXIntegration.java similarity index 96% rename from src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsX.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsXIntegration.java index 8d4b3e9..c7ee8ea 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsX.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/KingdomsXIntegration.java @@ -23,7 +23,7 @@ import org.kingdoms.constants.group.Kingdom; import org.kingdoms.constants.land.Land; import org.kingdoms.constants.player.KingdomPlayer; -public class KingdomsX implements Integration { +public class KingdomsXIntegration implements Integration { @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/Lands.java b/src/main/java/net/momirealms/customcrops/integrations/protection/LandsIntegration.java similarity index 81% rename from src/main/java/net/momirealms/customcrops/integrations/protection/Lands.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/LandsIntegration.java index a954f29..32e6006 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/Lands.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/LandsIntegration.java @@ -18,24 +18,23 @@ package net.momirealms.customcrops.integrations.protection; import me.angeschossen.lands.api.flags.Flags; -import me.angeschossen.lands.api.integration.LandsIntegration; import me.angeschossen.lands.api.land.Area; import net.momirealms.customcrops.CustomCrops; import org.bukkit.Location; import org.bukkit.entity.Player; -public class Lands implements Integration{ +public class LandsIntegration implements Integration{ @Override public boolean canBreak(Location location, Player player) { - Area area = new LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); + Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); if (area != null) return area.hasFlag(player, Flags.BLOCK_BREAK, false); else return true; } @Override public boolean canPlace(Location location, Player player) { - Area area = new LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); + Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location); if (area != null) return area.hasFlag(player, Flags.BLOCK_PLACE, false); else return true; } diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquared.java b/src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquaredIntegration.java similarity index 96% rename from src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquared.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquaredIntegration.java index b242718..5a6d077 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquared.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/PlotSquaredIntegration.java @@ -20,7 +20,7 @@ package net.momirealms.customcrops.integrations.protection; import com.plotsquared.core.location.Location; import org.bukkit.entity.Player; -public class PlotSquared implements Integration { +public class PlotSquaredIntegration implements Integration { @Override public boolean canBreak(org.bukkit.Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/Residence.java b/src/main/java/net/momirealms/customcrops/integrations/protection/ResidenceIntegration.java similarity index 96% rename from src/main/java/net/momirealms/customcrops/integrations/protection/Residence.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/ResidenceIntegration.java index a9c43d3..67c396c 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/Residence.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/ResidenceIntegration.java @@ -23,7 +23,7 @@ import com.bekvon.bukkit.residence.protection.ResidencePermissions; import org.bukkit.Location; import org.bukkit.entity.Player; -public class Residence implements Integration { +public class ResidenceIntegration implements Integration { @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/Towny.java b/src/main/java/net/momirealms/customcrops/integrations/protection/TownyIntegration.java similarity index 96% rename from src/main/java/net/momirealms/customcrops/integrations/protection/Towny.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/TownyIntegration.java index 6f71b3a..8c512de 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/Towny.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/TownyIntegration.java @@ -22,7 +22,7 @@ import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; import org.bukkit.Location; import org.bukkit.entity.Player; -public class Towny implements Integration{ +public class TownyIntegration implements Integration{ @Override public boolean canBreak(Location location, Player player) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuard.java b/src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuardIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuard.java rename to src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuardIntegration.java index 76383c7..cc96624 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuard.java +++ b/src/main/java/net/momirealms/customcrops/integrations/protection/WorldGuardIntegration.java @@ -30,10 +30,11 @@ import com.sk89q.worldguard.protection.regions.RegionQuery; import org.bukkit.Location; import org.bukkit.entity.Player; -public class WorldGuard implements Integration { +public class WorldGuardIntegration implements Integration { @Override public boolean canPlace(Location location, Player player) { + if (player.isOp()) return true; LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); World world = BukkitAdapter.adapt(location.getWorld()); WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform(); @@ -46,6 +47,7 @@ public class WorldGuard implements Integration { @Override public boolean canBreak(Location location, Player player) { + if (player.isOp()) return true; LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); World world = BukkitAdapter.adapt(location.getWorld()); WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform(); diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/Aurelium.java b/src/main/java/net/momirealms/customcrops/integrations/skill/AureliumIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/skill/Aurelium.java rename to src/main/java/net/momirealms/customcrops/integrations/skill/AureliumIntegration.java index 9d83ceb..061bf49 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/skill/Aurelium.java +++ b/src/main/java/net/momirealms/customcrops/integrations/skill/AureliumIntegration.java @@ -22,7 +22,7 @@ import com.archyx.aureliumskills.leveler.Leveler; import com.archyx.aureliumskills.skills.Skill; import org.bukkit.entity.Player; -public class Aurelium implements SkillXP { +public class AureliumIntegration implements SkillXP { private static final Leveler leveler = AureliumAPI.getPlugin().getLeveler(); private static final Skill skill = AureliumAPI.getPlugin().getSkillRegistry().getSkill("farming"); diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkill.java b/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkill.java deleted file mode 100644 index 6da0724..0000000 --- a/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkill.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.momirealms.customcrops.integrations.skill; - -import com.willfp.ecoskills.api.EcoSkillsAPI; -import com.willfp.ecoskills.skills.Skills; -import org.bukkit.entity.Player; - -public class EcoSkill implements SkillXP{ - - @Override - public void addXp(Player player, double amount) { - EcoSkillsAPI.getInstance().giveSkillExperience(player, Skills.FARMING, amount); - } -} diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkillsIntegration.java b/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkillsIntegration.java new file mode 100644 index 0000000..3f9c1e6 --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/integrations/skill/EcoSkillsIntegration.java @@ -0,0 +1,30 @@ +/* + * 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.integrations.skill; + +import com.willfp.ecoskills.api.EcoSkillsAPI; +import com.willfp.ecoskills.skills.Skills; +import org.bukkit.entity.Player; + +public class EcoSkillsIntegration implements SkillXP{ + + @Override + public void addXp(Player player, double amount) { + EcoSkillsAPI.getInstance().giveSkillExperience(player, Skills.FARMING, amount); + } +} diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/JobsReborn.java b/src/main/java/net/momirealms/customcrops/integrations/skill/JobsRebornIntegration.java similarity index 51% rename from src/main/java/net/momirealms/customcrops/integrations/skill/JobsReborn.java rename to src/main/java/net/momirealms/customcrops/integrations/skill/JobsRebornIntegration.java index 87eb072..8f12059 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/skill/JobsReborn.java +++ b/src/main/java/net/momirealms/customcrops/integrations/skill/JobsRebornIntegration.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.integrations.skill; import com.gamingmesh.jobs.Jobs; @@ -8,7 +25,7 @@ import org.bukkit.entity.Player; import java.util.List; -public class JobsReborn implements SkillXP{ +public class JobsRebornIntegration implements SkillXP{ @Override public void addXp(Player player, double amount) { diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/MMOCore.java b/src/main/java/net/momirealms/customcrops/integrations/skill/MMOCoreIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/skill/MMOCore.java rename to src/main/java/net/momirealms/customcrops/integrations/skill/MMOCoreIntegration.java index dcd6bd2..29294d2 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/skill/MMOCore.java +++ b/src/main/java/net/momirealms/customcrops/integrations/skill/MMOCoreIntegration.java @@ -21,7 +21,7 @@ import net.Indyuce.mmocore.experience.EXPSource; import net.Indyuce.mmocore.experience.Profession; import org.bukkit.entity.Player; -public class MMOCore implements SkillXP{ +public class MMOCoreIntegration implements SkillXP{ @Override public void addXp(Player player, double amount) { Profession profession = net.Indyuce.mmocore.MMOCore.plugin.professionManager.get("farming"); diff --git a/src/main/java/net/momirealms/customcrops/integrations/skill/mcMMO.java b/src/main/java/net/momirealms/customcrops/integrations/skill/mcMMOIntegration.java similarity index 95% rename from src/main/java/net/momirealms/customcrops/integrations/skill/mcMMO.java rename to src/main/java/net/momirealms/customcrops/integrations/skill/mcMMOIntegration.java index 53f23ed..ffbfa59 100644 --- a/src/main/java/net/momirealms/customcrops/integrations/skill/mcMMO.java +++ b/src/main/java/net/momirealms/customcrops/integrations/skill/mcMMOIntegration.java @@ -20,7 +20,7 @@ package net.momirealms.customcrops.integrations.skill; import com.gmail.nossr50.api.ExperienceAPI; import org.bukkit.entity.Player; -public class mcMMO implements SkillXP { +public class mcMMOIntegration implements SkillXP { @Override public void addXp(Player player, double amount) { diff --git a/src/main/java/net/momirealms/customcrops/listener/JoinAndQuit.java b/src/main/java/net/momirealms/customcrops/listener/JoinAndQuit.java index ce4dd71..b886f7b 100644 --- a/src/main/java/net/momirealms/customcrops/listener/JoinAndQuit.java +++ b/src/main/java/net/momirealms/customcrops/listener/JoinAndQuit.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.listener; import net.momirealms.customcrops.ConfigReader; diff --git a/src/main/java/net/momirealms/customcrops/listener/PapiReload.java b/src/main/java/net/momirealms/customcrops/listener/PapiReload.java index 83de715..be7d6ac 100644 --- a/src/main/java/net/momirealms/customcrops/listener/PapiReload.java +++ b/src/main/java/net/momirealms/customcrops/listener/PapiReload.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.listener; import net.momirealms.customcrops.CustomCrops; diff --git a/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakBlockI.java b/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakBlockI.java index b2f4504..c530814 100644 --- a/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakBlockI.java +++ b/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakBlockI.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.listener.itemframe; import dev.lone.itemsadder.api.CustomFurniture; diff --git a/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakFurnitureI.java b/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakFurnitureI.java index d22134b..806e132 100644 --- a/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakFurnitureI.java +++ b/src/main/java/net/momirealms/customcrops/listener/itemframe/BreakFurnitureI.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.listener.itemframe; import dev.lone.itemsadder.api.CustomFurniture; diff --git a/src/main/java/net/momirealms/customcrops/listener/itemframe/InteractFurnitureI.java b/src/main/java/net/momirealms/customcrops/listener/itemframe/InteractFurnitureI.java index 0f6f144..33c05f4 100644 --- a/src/main/java/net/momirealms/customcrops/listener/itemframe/InteractFurnitureI.java +++ b/src/main/java/net/momirealms/customcrops/listener/itemframe/InteractFurnitureI.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.listener.itemframe; import de.tr7zw.changeme.nbtapi.NBTCompound; @@ -5,6 +22,8 @@ import de.tr7zw.changeme.nbtapi.NBTItem; import dev.lone.itemsadder.api.CustomFurniture; import dev.lone.itemsadder.api.CustomStack; import dev.lone.itemsadder.api.Events.FurnitureInteractEvent; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customcrops.ConfigReader; @@ -23,11 +42,13 @@ import net.momirealms.customcrops.objects.fertilizer.YieldIncreasing; import net.momirealms.customcrops.utils.*; import org.apache.commons.lang.StringUtils; import org.bukkit.*; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; import java.util.List; import java.util.Objects; @@ -83,6 +104,18 @@ public class InteractFurnitureI implements Listener { if (water > 0){ nbtItem.setInteger("WaterAmount", --water); AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } if (sprinkler != null){ currentWater = sprinkler.getWater(); currentWater++; @@ -157,6 +190,18 @@ public class InteractFurnitureI implements Listener { int water = nbtItem.getInteger("WaterAmount"); if (water > 0){ nbtItem.setInteger("WaterAmount", --water); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } AdventureManager.playerSound(player, ConfigReader.Sounds.waterPotSource, ConfigReader.Sounds.waterPotKey); PotUtil.waterPot(wateringCan.getWidth(), wateringCan.getLength(), location.subtract(0.5,1,0.5), player.getLocation().getYaw()); } @@ -242,6 +287,8 @@ public class InteractFurnitureI implements Listener { } } + + /** * 右键收获判定 * @param crop 农作物实体 diff --git a/src/main/java/net/momirealms/customcrops/listener/itemframe/RightClickI.java b/src/main/java/net/momirealms/customcrops/listener/itemframe/RightClickI.java index 6f59a6a..308c3af 100644 --- a/src/main/java/net/momirealms/customcrops/listener/itemframe/RightClickI.java +++ b/src/main/java/net/momirealms/customcrops/listener/itemframe/RightClickI.java @@ -1,8 +1,26 @@ +/* + * 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.listener.itemframe; import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTItem; import dev.lone.itemsadder.api.CustomBlock; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customcrops.ConfigReader; @@ -26,12 +44,14 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; import java.util.List; @@ -156,6 +176,18 @@ public class RightClickI implements Listener { nbtItem.setInteger("WaterAmount", --water); AdventureManager.playerSound(player, ConfigReader.Sounds.waterPotSource, ConfigReader.Sounds.waterPotKey); PotUtil.waterPot(wateringCan.getWidth(), wateringCan.getLength(), block.getLocation(), player.getLocation().getYaw()); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } } if (ConfigReader.Message.hasWaterInfo) AdventureManager.playerActionbar(player, diff --git a/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakBlockT.java b/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakBlockT.java index ead795a..8945f1d 100644 --- a/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakBlockT.java +++ b/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakBlockT.java @@ -24,6 +24,7 @@ import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.datamanager.CropManager; import net.momirealms.customcrops.datamanager.PotManager; +import net.momirealms.customcrops.listener.JoinAndQuit; import net.momirealms.customcrops.objects.fertilizer.Fertilizer; import net.momirealms.customcrops.objects.fertilizer.QualityCrop; import net.momirealms.customcrops.integrations.protection.Integration; @@ -51,9 +52,12 @@ public class BreakBlockT implements Listener { @EventHandler public void onBreak(CustomBlockBreakEvent event){ + long time = System.currentTimeMillis(); + Player player = event.getPlayer(); + if (time - (JoinAndQuit.coolDown.getOrDefault(player, time - 150)) < 150) return; + JoinAndQuit.coolDown.put(player, time); String namespacedId = event.getNamespacedID(); if(namespacedId.contains("_stage_")){ - Player player = event.getPlayer(); Location location = event.getBlock().getLocation(); for (Integration integration : ConfigReader.Config.integration) if(!integration.canBreak(location, player)) return; diff --git a/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakFurnitureT.java b/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakFurnitureT.java index 57887ca..562b1ea 100644 --- a/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakFurnitureT.java +++ b/src/main/java/net/momirealms/customcrops/listener/tripwire/BreakFurnitureT.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.listener.tripwire; import dev.lone.itemsadder.api.Events.FurnitureBreakEvent; diff --git a/src/main/java/net/momirealms/customcrops/listener/tripwire/InteractFurnitureT.java b/src/main/java/net/momirealms/customcrops/listener/tripwire/InteractFurnitureT.java index 3e55301..8e17523 100644 --- a/src/main/java/net/momirealms/customcrops/listener/tripwire/InteractFurnitureT.java +++ b/src/main/java/net/momirealms/customcrops/listener/tripwire/InteractFurnitureT.java @@ -20,6 +20,8 @@ package net.momirealms.customcrops.listener.tripwire; import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTItem; import dev.lone.itemsadder.api.Events.FurnitureInteractEvent; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customcrops.ConfigReader; @@ -89,6 +91,18 @@ public class InteractFurnitureT implements Listener { int water = nbtItem.getInteger("WaterAmount"); if (water > 0){ nbtItem.setInteger("WaterAmount", --water); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey); if (sprinkler != null){ currentWater = sprinkler.getWater(); diff --git a/src/main/java/net/momirealms/customcrops/listener/tripwire/RightClickT.java b/src/main/java/net/momirealms/customcrops/listener/tripwire/RightClickT.java index 2022be6..16cf3bd 100644 --- a/src/main/java/net/momirealms/customcrops/listener/tripwire/RightClickT.java +++ b/src/main/java/net/momirealms/customcrops/listener/tripwire/RightClickT.java @@ -21,6 +21,7 @@ import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTItem; import dev.lone.itemsadder.api.CustomBlock; import dev.lone.itemsadder.api.CustomStack; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customcrops.ConfigReader; @@ -28,6 +29,7 @@ import net.momirealms.customcrops.datamanager.CropManager; import net.momirealms.customcrops.datamanager.PotManager; import net.momirealms.customcrops.datamanager.SeasonManager; import net.momirealms.customcrops.datamanager.SprinklerManager; +import net.momirealms.customcrops.listener.itemframe.InteractFurnitureI; import net.momirealms.customcrops.objects.fertilizer.Fertilizer; import net.momirealms.customcrops.objects.fertilizer.QualityCrop; import net.momirealms.customcrops.integrations.protection.Integration; @@ -46,12 +48,14 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -177,6 +181,18 @@ public class RightClickT implements Listener { nbtItem.setInteger("WaterAmount", --water); AdventureManager.playerSound(player, ConfigReader.Sounds.waterPotSource, ConfigReader.Sounds.waterPotKey); PotUtil.waterPot(wateringCan.getWidth(), wateringCan.getLength(), block.getLocation(), player.getLocation().getYaw()); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } } if (ConfigReader.Message.hasWaterInfo) AdventureManager.playerActionbar(player, @@ -205,6 +221,18 @@ public class RightClickT implements Listener { nbtItem.setInteger("WaterAmount", --water); AdventureManager.playerSound(player, ConfigReader.Sounds.waterPotSource, ConfigReader.Sounds.waterPotKey); PotUtil.waterPot(wateringCan.getWidth(), wateringCan.getLength(), block.getLocation().subtract(0, 1, 0), player.getLocation().getYaw()); + if (nbtCompound.hasKey("custom_durability")){ + int dur = nbtCompound.getInteger("custom_durability"); + int max_dur = nbtCompound.getInteger("max_custom_durability"); + if (dur > 0){ + nbtCompound.setInteger("custom_durability", dur - 1); + nbtCompound.setDouble("fake_durability", (int) itemStack.getType().getMaxDurability() * (double) (dur/max_dur)); + nbtItem.setInteger("Damage", (int) (itemStack.getType().getMaxDurability() * (1 - (double) dur/max_dur))); + } else { + AdventureManager.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:item.shield.break")); + itemStack.setAmount(itemStack.getAmount() - 1); + } + } } if (ConfigReader.Message.hasWaterInfo) AdventureManager.playerActionbar(player, diff --git a/src/main/java/net/momirealms/customcrops/objects/WateringCan.java b/src/main/java/net/momirealms/customcrops/objects/WateringCan.java index b9ccacc..a014416 100644 --- a/src/main/java/net/momirealms/customcrops/objects/WateringCan.java +++ b/src/main/java/net/momirealms/customcrops/objects/WateringCan.java @@ -19,8 +19,16 @@ package net.momirealms.customcrops.objects; public record WateringCan(int max, int width, int length) { - public int getMax() { return max; } - public int getLength() { return length; } - public int getWidth() { return width; } + public int getMax() { + return max; + } + + public int getLength() { + return length; + } + + public int getWidth() { + return width; + } } diff --git a/src/main/java/net/momirealms/customcrops/objects/fertilizer/Fertilizer.java b/src/main/java/net/momirealms/customcrops/objects/fertilizer/Fertilizer.java index 4dcb374..b54758f 100644 --- a/src/main/java/net/momirealms/customcrops/objects/fertilizer/Fertilizer.java +++ b/src/main/java/net/momirealms/customcrops/objects/fertilizer/Fertilizer.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.objects.fertilizer; import org.bukkit.Particle; diff --git a/src/main/java/net/momirealms/customcrops/objects/fertilizer/YieldIncreasing.java b/src/main/java/net/momirealms/customcrops/objects/fertilizer/YieldIncreasing.java index 694fa85..8a8275e 100644 --- a/src/main/java/net/momirealms/customcrops/objects/fertilizer/YieldIncreasing.java +++ b/src/main/java/net/momirealms/customcrops/objects/fertilizer/YieldIncreasing.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.objects.fertilizer; public class YieldIncreasing extends Fertilizer { diff --git a/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java b/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java index 9b7c91d..25fbf7a 100644 --- a/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java +++ b/src/main/java/net/momirealms/customcrops/utils/HoloUtil.java @@ -78,6 +78,7 @@ public class HoloUtil { packet2.getModifier().write(0,id); packet2.getWatchableCollectionModifier().write(0, wrappedDataWatcher.getWatchableObjects()); cache.put(location, id); + try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet1); ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet2); diff --git a/src/main/java/net/momirealms/customcrops/utils/PotUtil.java b/src/main/java/net/momirealms/customcrops/utils/PotUtil.java index 3f1141d..30b8081 100644 --- a/src/main/java/net/momirealms/customcrops/utils/PotUtil.java +++ b/src/main/java/net/momirealms/customcrops/utils/PotUtil.java @@ -94,15 +94,20 @@ public class PotUtil { public static void addFertilizer(Fertilizer fertilizerConfig, Location location) { if (fertilizerConfig instanceof QualityCrop config){ QualityCrop qualityCrop = new QualityCrop(config.getKey(), config.getTimes()); + qualityCrop.setChance(config.getChance()); PotManager.Cache.put(LocUtil.fromLocation(location), qualityCrop); }else if (fertilizerConfig instanceof SpeedGrow config){ SpeedGrow speedGrow = new SpeedGrow(config.getKey(), config.getTimes()); + speedGrow.setChance(config.getChance()); PotManager.Cache.put(LocUtil.fromLocation(location), speedGrow); }else if (fertilizerConfig instanceof RetainingSoil config){ RetainingSoil retainingSoil = new RetainingSoil(config.getKey(), config.getTimes()); + retainingSoil.setChance(config.getChance()); PotManager.Cache.put(LocUtil.fromLocation(location), retainingSoil); }else if (fertilizerConfig instanceof YieldIncreasing config){ YieldIncreasing yieldIncreasing = new YieldIncreasing(config.getKey(), config.getTimes()); + yieldIncreasing.setBonus(config.getBonus()); + yieldIncreasing.setChance(config.getChance()); PotManager.Cache.put(LocUtil.fromLocation(location), yieldIncreasing); } if (fertilizerConfig.getParticle() != null) location.getWorld().spawnParticle(fertilizerConfig.getParticle(), location.add(0.5,1.3,0.5), 5,0.2,0.2,0.2); diff --git a/src/main/resources/basic.yml b/src/main/resources/basic.yml index d500c6a..90b3a6d 100644 --- a/src/main/resources/basic.yml +++ b/src/main/resources/basic.yml @@ -7,7 +7,9 @@ basic: soil-detector: customcrops:soil_detector - +# If you want watering-can has custom durability +# Just set material to damageable items like wooden_sword +# custom durability in itemsadder is compatible in CustomCrops water-can: watering_can_1: item: customcrops:watering_can_1 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 16f552c..8b607d5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ #Don't change -config-version: '5' +config-version: '6' #Want to sell the crops? #Try this plugin: https://www.spigotmc.org/resources/shipping-bin.104591/ @@ -62,6 +62,7 @@ config: Lands: false GriefPrevention: false CrashClaim: false + BentoBox: false #integration to add players' farming skill xp AureliumSkills: false mcMMO: false @@ -78,10 +79,10 @@ config: # Mode 2: # ● Online players' crops will grow # Mode 3: - # ● Recommended Mode 1 + Mode 2 + # ● If you enable season, mode 3 is recommended (Mode 1 + Mode 2) # Mode 4: - # ● Please disable season in this mode! - # ● All the crops will grow + # ● If you disable season, mode 4 is recommended + # ● All the crops will grow, this is good for offline crops # ● If season not disabled, your server would be lagging when there's a lot of data # ● Crop data would be removed as soon as they are ripe when season disabled, so it would not cause lag! grow-mode: 3 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b7b2b60..73bf81b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: CustomCrops version: '${version}' main: net.momirealms.customcrops.CustomCrops -api-version: 1.17 +api-version: 1.16 authors: [ XiaoMoMi ] depend: - ItemsAdder diff --git a/src/main/resources/zh-cn/basic.yml b/src/main/resources/zh-cn/basic.yml index 848559d..ea78076 100644 --- a/src/main/resources/zh-cn/basic.yml +++ b/src/main/resources/zh-cn/basic.yml @@ -11,6 +11,9 @@ basic: #土质探测器,用于查看使用的肥料种类和残余量 soil-detector: customcrops:soil_detector +#如果你想要水壶有自定义耐久度 +#请在ia里将它设置为耐久度的物品(例如木剑) +#IA的自定义耐久度对本插件生效 water-can: watering_can_1: item: customcrops:watering_can_1 @@ -19,6 +22,8 @@ water-can: #水壶工作的范围 width: 1 length: 1 + #水壶的最大耐久度,不填写则无限耐久 + durability: 100 watering_can_2: item: customcrops:watering_can_2 max: 4 @@ -40,12 +45,11 @@ lore: watering-can: enable: true #Lore样式 + #可用变量 {water}当前水量 {max_water}最大蓄水量 lore: - '{water_info}' - '右键水方块为水壶加水' - #水量 {water_info} - #可用变量 {water}当前水量 {max_water}最大蓄水量 left: '뀂' full: '뀁뀃' empty: '뀁뀄' diff --git a/src/main/resources/zh-cn/config.yml b/src/main/resources/zh-cn/config.yml index 483d1d1..89d4cc3 100644 --- a/src/main/resources/zh-cn/config.yml +++ b/src/main/resources/zh-cn/config.yml @@ -1,5 +1,5 @@ #请不要修改此值 -config-version: '5' +config-version: '6' config: @@ -54,6 +54,7 @@ config: Lands: false GriefPrevention: false CrashClaim: false + BentoBox: false #增加技能经验 AureliumSkills: false mcMMO: false