mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 19:39:20 +00:00
3.0.2
This commit is contained in:
@@ -90,7 +90,7 @@ public class ConfigManager extends Function {
|
||||
}
|
||||
|
||||
private void loadWorlds(ConfigurationSection section) {
|
||||
worldFolderPath = section.getString("folder", "");
|
||||
worldFolderPath = section.getString("absolute-world-folder-path", "");
|
||||
whiteListWorlds = section.getString("mode", "whitelist").equalsIgnoreCase("whitelist");
|
||||
worldList = new HashSet<>(section.getStringList("list"));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.momirealms.customcrops.api.object.sprinkler.Sprinkler;
|
||||
import net.momirealms.customcrops.api.object.world.CCChunk;
|
||||
import net.momirealms.customcrops.api.object.world.ChunkCoordinate;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.util.ConfigUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class MigrateWorld extends Function {
|
||||
@Override
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void init() {
|
||||
File chunks_folder = new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "chunks");
|
||||
File chunks_folder = ConfigUtils.getChunkFolder(worldName);
|
||||
if (!chunks_folder.exists()) chunks_folder.mkdirs();
|
||||
File[] data_files = chunks_folder.listFiles();
|
||||
if (data_files == null) return;
|
||||
@@ -69,7 +70,7 @@ public class MigrateWorld extends Function {
|
||||
@Override
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void disable() {
|
||||
File chunks_folder = new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "chunks");
|
||||
File chunks_folder = ConfigUtils.getChunkFolder(worldName);
|
||||
if (!chunks_folder.exists()) chunks_folder.mkdirs();
|
||||
for (Map.Entry<ChunkCoordinate, CCChunk> entry : chunkMap.entrySet()) {
|
||||
ChunkCoordinate chunkCoordinate = entry.getKey();
|
||||
|
||||
@@ -99,7 +99,7 @@ public class CCWorld extends Function {
|
||||
@Override
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void init() {
|
||||
File chunks_folder = new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "chunks");
|
||||
File chunks_folder = ConfigUtils.getChunkFolder(worldName);
|
||||
if (!chunks_folder.exists()) chunks_folder.mkdirs();
|
||||
File[] data_files = chunks_folder.listFiles();
|
||||
if (data_files == null) return;
|
||||
@@ -131,14 +131,14 @@ public class CCWorld extends Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void disable() {
|
||||
closePool();
|
||||
saveCache();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void saveCache() {
|
||||
File chunks_folder = new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "chunks");
|
||||
File chunks_folder = ConfigUtils.getChunkFolder(worldName);
|
||||
if (!chunks_folder.exists()) chunks_folder.mkdirs();
|
||||
for (Map.Entry<ChunkCoordinate, CCChunk> entry : chunkMap.entrySet()) {
|
||||
ChunkCoordinate chunkCoordinate = entry.getKey();
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.action.*;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.condition.Random;
|
||||
import net.momirealms.customcrops.api.object.condition.*;
|
||||
import net.momirealms.customcrops.api.object.crop.VariationCrop;
|
||||
@@ -454,4 +455,14 @@ public class ConfigUtils {
|
||||
int a = Integer.parseInt(split[3]);
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public static File getChunkFolder(String world) {
|
||||
File chunks_folder;
|
||||
if (ConfigManager.worldFolderPath.equals("")) {
|
||||
chunks_folder = new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), world + File.separator + "customcrops" + File.separator + "chunks");
|
||||
} else {
|
||||
chunks_folder = new File(ConfigManager.worldFolderPath, world + File.separator + "customcrops" + File.separator + "chunks");
|
||||
}
|
||||
return chunks_folder;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,13 @@ public class HelpCommand extends AbstractSubCommand {
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>help");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>about");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>reload <#87CEFA>Reload the plugin");
|
||||
AdventureUtils.sendMessage(sender, " <gray>└─<white>setseason <#FFFACD><world> <season> <#87CEFA>Set a world's season");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>migrate <#87CEFA>Migrate data from 2.0->3.0");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>convert <#87CEFA>Convert config from 2.0->3.0");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>setseason <#FFFACD><world> <season> <#87CEFA>Set a world's season");
|
||||
AdventureUtils.sendMessage(sender, " <gray>├─<white>setdate <#FFFACD><world> <date> <#87CEFA>Set a world's date");
|
||||
AdventureUtils.sendMessage(sender, " <gray>└─<white>force");
|
||||
AdventureUtils.sendMessage(sender, " <gray> ├─<white>sprinklerwork <#FFFACD><world> <#87CEFA>Forced sprinklers to work");
|
||||
AdventureUtils.sendMessage(sender, " <gray> └─<white>consume <#FFFACD><world> <#87CEFA>Forced pots to reduce water amount and the remaining use of fertilizers");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,13 @@ public class MigrateCommand extends AbstractSubCommand {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
File outer_folder = new File(CustomCrops.getInstance().getDataFolder().getAbsoluteFile().getParentFile().getParentFile() + ConfigManager.worldFolderPath);
|
||||
|
||||
File outer_folder;
|
||||
if (ConfigManager.worldFolderPath.equals("")) {
|
||||
outer_folder = CustomCrops.getInstance().getDataFolder().getAbsoluteFile().getParentFile().getParentFile();
|
||||
} else {
|
||||
outer_folder = new File(ConfigManager.worldFolderPath);
|
||||
}
|
||||
if (!outer_folder.isDirectory()) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] World folder is not detected");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user