diff --git a/libs/KingdomsX(premium).txt b/libs/KingdomsX(premium).txt new file mode 100644 index 0000000..e69de29 diff --git a/libs/Lands(premium).txt b/libs/Lands(premium).txt new file mode 100644 index 0000000..e69de29 diff --git a/libs/PlotSquared(premium).txt b/libs/PlotSquared(premium).txt new file mode 100644 index 0000000..e69de29 diff --git a/libs/Residence(premium).txt b/libs/Residence(premium).txt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/net/momirealms/customcrops/ConfigReader.java b/src/main/java/net/momirealms/customcrops/ConfigReader.java index f3b071d..0b03379 100644 --- a/src/main/java/net/momirealms/customcrops/ConfigReader.java +++ b/src/main/java/net/momirealms/customcrops/ConfigReader.java @@ -44,7 +44,7 @@ public class ConfigReader { public static HashMap CANS = new HashMap<>(); public static HashMap SPRINKLERS = new HashMap<>(); - private static YamlConfiguration getConfig(String configName) { + public static YamlConfiguration getConfig(String configName) { File file = new File(CustomCrops.instance.getDataFolder(), configName); if (!file.exists()) { CustomCrops.instance.saveResource(configName, false); @@ -227,6 +227,14 @@ public class ConfigReader { AdventureManager.consoleMessage("[CustomCrops] Lands Hooked!"); } } + if(config.getBoolean("config.integration.GriefPrevention",false)){ + if(Bukkit.getPluginManager().getPlugin("GriefPrevention") == null){ + CustomCrops.instance.getLogger().warning("Failed to initialize GriefPrevention!"); + }else { + integration.add(new GriefPrevention()); + AdventureManager.consoleMessage("[CustomCrops] GriefPrevention Hooked!"); + } + } } } diff --git a/src/main/java/net/momirealms/customcrops/CustomCrops.java b/src/main/java/net/momirealms/customcrops/CustomCrops.java index d30dcac..27286ff 100644 --- a/src/main/java/net/momirealms/customcrops/CustomCrops.java +++ b/src/main/java/net/momirealms/customcrops/CustomCrops.java @@ -33,8 +33,11 @@ import net.momirealms.customcrops.utils.BackUp; import net.momirealms.customcrops.utils.HoloUtil; import net.momirealms.customcrops.utils.Placeholders; import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +import java.io.IOException; import java.util.Objects; public final class CustomCrops extends JavaPlugin { @@ -111,8 +114,19 @@ public final class CustomCrops extends JavaPlugin { this.potManager = new PotManager(this); this.potManager.loadData(); - //启动完成 - AdventureManager.consoleMessage("[CustomCrops] Plugin Enabled!"); + FileConfiguration fileConfiguration = Bukkit.getPluginManager().getPlugin("ItemsAdder").getConfig(); + if (fileConfiguration.getBoolean("blocks.disable-REAL_WIRE")){ + fileConfiguration.set("blocks.disable-REAL_WIRE", false); + try { + fileConfiguration.save(new File(Bukkit.getPluginManager().getPlugin("ItemsAdder").getDataFolder(), "config.yml")); + } catch (IOException e) { + e.printStackTrace(); + } + AdventureManager.consoleMessage("[CustomCrops] Detected that you might have not set \"disable-REAL_WIRE\" false in ItemsAdder's config!"); + AdventureManager.consoleMessage("[CustomCrops] You need a restart to apply that config :)"); + }else { + AdventureManager.consoleMessage("[CustomCrops] Plugin Enabled!"); + } } @Override diff --git a/src/main/java/net/momirealms/customcrops/integrations/GriefPrevention.java b/src/main/java/net/momirealms/customcrops/integrations/GriefPrevention.java new file mode 100644 index 0000000..b226abc --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/integrations/GriefPrevention.java @@ -0,0 +1,17 @@ +package net.momirealms.customcrops.integrations; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class GriefPrevention implements Integration{ + + @Override + public boolean canBreak(Location location, Player player) { + return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBreak(player, location.getBlock(), location) == null; + } + + @Override + public boolean canPlace(Location location, Player player) { + return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBuild(player, location) == null; + } +} diff --git a/src/main/java/net/momirealms/customcrops/timer/CropTimer.java b/src/main/java/net/momirealms/customcrops/timer/CropTimer.java index b49ccce..d0e147f 100644 --- a/src/main/java/net/momirealms/customcrops/timer/CropTimer.java +++ b/src/main/java/net/momirealms/customcrops/timer/CropTimer.java @@ -33,7 +33,6 @@ public class CropTimer { public void stopTimer(int ID) { Bukkit.getScheduler().cancelTask(ID); - Bukkit.getServer().getScheduler().cancelTask(ID); } public int getTaskID() { diff --git a/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java b/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java index 2573035..838c6f2 100644 --- a/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java +++ b/src/main/java/net/momirealms/customcrops/timer/CropTimerAsync.java @@ -33,7 +33,6 @@ public class CropTimerAsync { public void stopTimer(int ID) { Bukkit.getScheduler().cancelTask(ID); - Bukkit.getServer().getScheduler().cancelTask(ID); } public int getTaskID() { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 37d486f..8e17761 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -11,6 +11,7 @@ config: PlotSquared: false Towny: false Lands: false + GriefPrevention: false #The time to start growing(ticks) #1000ticks is 7am in game. (0-23999) @@ -27,8 +28,6 @@ config: quality: #If disabled, you need to configurate the loot in ItemsAdder config - #If enabled, make sure that your Grief Prevention Plugin is supported. - #Otherwise there might exists duplication. enable: true #Default ratio default-ratio: 17/2/1 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 921b3c1..5630182 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -15,6 +15,7 @@ softdepend: - PlotSquared - Towny - Lands + - GriefPrevention commands: customcrops: usage: /customcrops \ No newline at end of file diff --git a/src/main/resources/zh-cn/config.yml b/src/main/resources/zh-cn/config.yml index a661cc0..f2c68fd 100644 --- a/src/main/resources/zh-cn/config.yml +++ b/src/main/resources/zh-cn/config.yml @@ -1,4 +1,6 @@ config: + lang: chinese + #插件兼容 integration: Residence: false @@ -8,6 +10,7 @@ config: PlotSquared: false Towny: false Lands: false + GriefPrevention: false #生长时间点(tick) #1000代表上午7点,农作物陆续开始生长 @@ -27,8 +30,6 @@ config: quality: #若不启用则植物成熟阶段会掉落IA配置里的loot #如果关闭产物品质需要在IA物品配置内自行添加最后一阶段掉落物 - #如果你使用的领地插件不被兼容,请不要启用产物品质功能, - #请立即更换领地插件或寻找作者写领地兼容 enable: true #默认品质权重比 default-ratio: 17/2/1 @@ -75,4 +76,7 @@ config: #因为有大量世界所以无法通过添加白名单世界的方式生长 #在此选项开启的状态下,白名单世界只能填写一个 #作为所有世界农作物生长的时间、季节判断依据 - all-world-grow: false \ No newline at end of file + all-world-grow: false + + #玩家是否能空手右键收获 + right-click-harvest: true \ No newline at end of file