9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 08:29:35 +00:00
This commit is contained in:
Xiao-MoMi
2022-07-23 20:00:40 +08:00
parent 1955677b06
commit f9761f2fe6
12 changed files with 51 additions and 10 deletions

View File

@@ -44,7 +44,7 @@ public class ConfigReader {
public static HashMap<String, WateringCan> CANS = new HashMap<>();
public static HashMap<String, Sprinkler> 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("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>Lands <color:#FFEBCD>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("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>GriefPrevention <color:#FFEBCD>Hooked!");
}
}
}
}

View File

@@ -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("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>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("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><red>Detected that you might have not set \"disable-REAL_WIRE\" false in ItemsAdder's config!");
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><red>You need a restart to apply that config :)");
}else {
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>Plugin Enabled!");
}
}
@Override

View File

@@ -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;
}
}

View File

@@ -33,7 +33,6 @@ public class CropTimer {
public void stopTimer(int ID) {
Bukkit.getScheduler().cancelTask(ID);
Bukkit.getServer().getScheduler().cancelTask(ID);
}
public int getTaskID() {

View File

@@ -33,7 +33,6 @@ public class CropTimerAsync {
public void stopTimer(int ID) {
Bukkit.getScheduler().cancelTask(ID);
Bukkit.getServer().getScheduler().cancelTask(ID);
}
public int getTaskID() {