mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-24 09:29:19 +00:00
2.1.2
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '2.1.0-r3'
|
||||
version = '2.1.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -73,7 +73,7 @@ dependencies {
|
||||
implementation('net.kyori:adventure-api:4.12.0')
|
||||
implementation('net.kyori:adventure-platform-bukkit:4.1.2')
|
||||
implementation('net.kyori:adventure-text-minimessage:4.12.0')
|
||||
implementation("de.tr7zw:item-nbt-api:2.10.0")
|
||||
implementation("de.tr7zw:item-nbt-api:2.11.1")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.momirealms.customcrops.config.ConfigUtil;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.helper.LibraryLoader;
|
||||
import net.momirealms.customcrops.integrations.papi.PlaceholderManager;
|
||||
import net.momirealms.customcrops.integrations.protection.WorldGuardHook;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -67,6 +68,9 @@ public final class CustomCrops extends JavaPlugin {
|
||||
plugin = this;
|
||||
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
|
||||
LibraryLoader.load("commons-io","commons-io","2.11.0","https://repo.maven.apache.org/maven2/");
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
WorldGuardHook.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,6 +124,8 @@ public class MainConfig {
|
||||
public static HashMap<Material, String> vanilla2Crops;
|
||||
public static boolean enableEvents;
|
||||
public static int saveInterval;
|
||||
public static boolean dryMakesCropDead;
|
||||
public static double dryDeadChance;
|
||||
|
||||
public static void load() {
|
||||
ConfigUtil.update("config.yml");
|
||||
@@ -166,6 +168,9 @@ public class MainConfig {
|
||||
dryGrowChance = config.getDouble("mechanics.dry-pot-grow-chance", 0.5);
|
||||
dropLootsInAllWorlds = config.getBoolean("mechanics.drop-loots-in-all-worlds", false);
|
||||
|
||||
dryMakesCropDead = config.getBoolean("mechanics.dry-pot-makes-crop-dead.enable", false);
|
||||
dryDeadChance = config.getDouble("mechanics.dry-pot-makes-crop-dead.chance", 0.6);
|
||||
|
||||
waterBucketToSprinkler = config.getInt("mechanics.fill.water-bucket-to-sprinkler", 3);
|
||||
waterToWaterCan = config.getInt("mechanics.fill.waterblock-to-watering-can", 1);
|
||||
wateringCanToSprinkler = config.getInt("mechanics.fill.watering-can-to-sprinkler", 1);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||
|
||||
import io.th0rgal.oraxen.OraxenPlugin;
|
||||
import io.th0rgal.oraxen.api.OraxenItems;
|
||||
import io.th0rgal.oraxen.api.events.*;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
|
||||
@@ -34,17 +33,14 @@ import net.momirealms.customcrops.integrations.AntiGrief;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.objects.Sprinkler;
|
||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public class OraxenWireHandler extends OraxenHandler{
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
@@ -34,6 +35,21 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class WorldGuardHook implements AntiGrief {
|
||||
|
||||
public static StateFlag HARVEST_FLAG;
|
||||
public static StateFlag PLACE_FLAG;
|
||||
|
||||
public static void initialize() {
|
||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
if (HARVEST_FLAG == null) {
|
||||
HARVEST_FLAG = new StateFlag("customcrops-harvest", false);
|
||||
registry.register(HARVEST_FLAG);
|
||||
}
|
||||
if (PLACE_FLAG == null) {
|
||||
PLACE_FLAG = new StateFlag("customcrops-place", false);
|
||||
registry.register(PLACE_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
@@ -41,7 +57,7 @@ public class WorldGuardHook implements AntiGrief {
|
||||
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
|
||||
if (hasRegion(world, BukkitAdapter.asBlockVector(location))){
|
||||
RegionQuery query = platform.getRegionContainer().createQuery();
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BUILD);
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, PLACE_FLAG);
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
@@ -53,7 +69,7 @@ public class WorldGuardHook implements AntiGrief {
|
||||
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
|
||||
if (hasRegion(world, BukkitAdapter.asBlockVector(location))){
|
||||
RegionQuery query = platform.getRegionContainer().createQuery();
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BLOCK_BREAK);
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, HARVEST_FLAG);
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
@@ -485,6 +485,13 @@ public class CropManager extends Function {
|
||||
if (potID == null) return true;
|
||||
|
||||
boolean certainGrow = potID.equals(BasicItemConfig.wetPot);
|
||||
if (MainConfig.dryMakesCropDead && !certainGrow && Math.random() < MainConfig.dryDeadChance) {
|
||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||
customInterface.removeBlock(location);
|
||||
customInterface.placeWire(location, BasicItemConfig.deadCrop);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
String temp = CropConfig.namespace + growingCrop.getType() + "_stage_";
|
||||
|
||||
@@ -543,6 +550,10 @@ public class CropManager extends Function {
|
||||
if (potID == null) return true;
|
||||
|
||||
boolean certainGrow = potID.equals(BasicItemConfig.wetPot);
|
||||
if (MainConfig.dryMakesCropDead && !certainGrow && Math.random() < MainConfig.dryDeadChance) {
|
||||
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
String temp = CropConfig.namespace + growingCrop.getType() + "_stage_";
|
||||
if (fertilizer instanceof SpeedGrow speedGrow && Math.random() < speedGrow.getChance() && current_stage+2 <= crop.getMax_stage()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Don't change
|
||||
# 请不要修改
|
||||
config-version: '18'
|
||||
config-version: '19'
|
||||
|
||||
# lang: english / spanish / chinese
|
||||
lang: english
|
||||
@@ -96,6 +96,11 @@ mechanics:
|
||||
# 建议设置高于0的数值,这样每个农作物都能得到生长,最后从数据中移除
|
||||
# 长远来看,这样不会造成数据堆积,对服务器性能友好
|
||||
dry-pot-grow-chance: 0.5
|
||||
# Should the crop go to dead stage if the pot is dry
|
||||
# 农作物是否会在干燥的种植盆上枯萎
|
||||
dry-pot-makes-crop-dead:
|
||||
enable: false
|
||||
chance: 0.6
|
||||
# Can player harvest crops with right click?
|
||||
# if set "false" crops can't be harvested repeatedly
|
||||
# 玩家是否能右键收获农作物,禁用此项则重复收获机制也无法使用
|
||||
|
||||
Reference in New Issue
Block a user