9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2026-01-04 15:41:46 +00:00
This commit is contained in:
Xiao-MoMi
2023-04-20 19:31:27 +08:00
parent 4f92c268e6
commit 0c5017297e
10 changed files with 39 additions and 15 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group = 'net.momirealms'
version = '3.0.1'
version = '3.0.2'
repositories {
mavenCentral()

View File

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

View File

@@ -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();

View File

@@ -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();

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
# Don't change
config-version: '25'
config-version: '26'
# BStats
metrics: true
# Language: english / spanish / chinese / turkish
@@ -9,9 +9,8 @@ debug: false
worlds:
# This is designed for servers that using a separate folder for worlds
# The default folder is your server's root folder
# 如果你的服务器使用独立文件夹存储世界,请在此填入根目录下的文件地址
folder: ''
# 如果你的服务器使用独立文件夹存储世界,请在此填入绝对地址
absolute-world-folder-path: ''
# Mode: whitelist/blacklist
# Requires a restart when changing mode or editing world list for the safety of data
# 模式:白名单/黑名单
@@ -33,7 +32,7 @@ schedule-system:
# Save cache to file interval (seconds)
# set "-1" to disable
# 保存缓存的时间间隔 (秒)
cache-save-interval: 7200
cache-save-interval: 7500
# Thread pool settings
# 线程池设置
thread-pool-settings:

View File

@@ -1,3 +1,4 @@
# Watering can key name
watering_can_1:
# 物品 id
item: customcrops:watering_can_1

View File

@@ -21,4 +21,4 @@ messages:
world-not-exist: '<white>World {world} does not exist.'
season-not-exist: '<white>Season {season} does not exist.'
force-sprinkler-work: "<white>Forced {world}'s sprinklers to work"
force-consume: "<white>Forced {world}'s pot to reduce water amount and the remaining use of fertilizers"
force-consume: "<white>Forced {world}'s pots to reduce water amount and the remaining use of fertilizers"