mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 09:59:20 +00:00
2.0.2
This commit is contained in:
@@ -34,9 +34,9 @@ public class WorldUtils {
|
||||
/**
|
||||
* unload a world's crop data
|
||||
* @param world world
|
||||
* @param disable whether the server is stopping
|
||||
* @param sync whether unload is sync or async
|
||||
*/
|
||||
public static void unloadCropWorld(World world, boolean disable) {
|
||||
CustomCrops.plugin.getCropManager().onWorldUnload(world, disable);
|
||||
public static void unloadCropWorld(World world, boolean sync) {
|
||||
CustomCrops.plugin.getCropManager().onWorldUnload(world, sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,9 @@ import java.util.List;
|
||||
public class MainConfig {
|
||||
|
||||
public static World[] worlds;
|
||||
public static String[] worldNames;
|
||||
public static List<World> worldList;
|
||||
public static List<String> worldNameList;
|
||||
public static boolean whiteOrBlack;
|
||||
public static String customPlugin;
|
||||
public static boolean OraxenHook;
|
||||
@@ -127,11 +129,11 @@ public class MainConfig {
|
||||
lang = config.getString("lang","english");
|
||||
|
||||
whiteOrBlack = config.getString("worlds.mode","whitelist").equals("whitelist");
|
||||
List<String> worldsName = config.getStringList("worlds.list");
|
||||
worlds = new World[worldsName.size()];
|
||||
for (int i = 0; i < worldsName.size(); i++) {
|
||||
if (Bukkit.getWorld(worldsName.get(i)) != null) {
|
||||
worlds[i] = Bukkit.getWorld(worldsName.get(i));
|
||||
worldNameList = config.getStringList("worlds.list");
|
||||
worlds = new World[worldNameList.size()];
|
||||
for (int i = 0; i < worldNameList.size(); i++) {
|
||||
if (Bukkit.getWorld(worldNameList.get(i)) != null) {
|
||||
worlds[i] = Bukkit.getWorld(worldNameList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +144,7 @@ public class MainConfig {
|
||||
}
|
||||
|
||||
worlds = worldList.toArray(new World[0]);
|
||||
worldNames = worldNameList.toArray(new String[0]);
|
||||
worldFolder = StringUtils.replace(config.getString("worlds.worlds-folder",""), "\\", File.separator);
|
||||
|
||||
cropMode = config.getString("mechanics.crops-mode", "tripwire").equals("tripwire");
|
||||
@@ -361,6 +364,20 @@ public class MainConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getWorldNameList() {
|
||||
if (whiteOrBlack) {
|
||||
return worldNameList;
|
||||
}
|
||||
else {
|
||||
List<String> allWorldNames = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
allWorldNames.add(world.getName());
|
||||
}
|
||||
allWorldNames.removeAll(worldNameList);
|
||||
return allWorldNames;
|
||||
}
|
||||
}
|
||||
|
||||
private static void hookMessage(String plugin){
|
||||
AdventureUtil.consoleMessage("[CustomCrops] <white>" + plugin + " Hooked!");
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class CropManager extends Function {
|
||||
public void onWorldLoad(World world) {
|
||||
CustomWorld cw = customWorlds.get(world);
|
||||
if (cw != null) return;
|
||||
if (MainConfig.getWorldsList().contains(world)) {
|
||||
if (MainConfig.getWorldNameList().contains(world.getName())) {
|
||||
CustomWorld customWorld = new CustomWorld(world, this);
|
||||
customWorlds.put(world, customWorld);
|
||||
if (MainConfig.autoGrow && MainConfig.enableCompensation) {
|
||||
|
||||
@@ -48,7 +48,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class CustomWorld {
|
||||
|
||||
private final World world;
|
||||
|
||||
private final ConcurrentHashMap<SimpleLocation, Sprinkler> sprinklerCache;
|
||||
private final ConcurrentHashMap<SimpleLocation, Fertilizer> fertilizerCache;
|
||||
private final ConcurrentHashMap<String, HashSet<SimpleLocation>> scarecrowCache;
|
||||
@@ -63,7 +62,6 @@ public class CustomWorld {
|
||||
|
||||
public CustomWorld(World world, CropManager cropManager) {
|
||||
this.world = world;
|
||||
|
||||
this.fertilizerCache = new ConcurrentHashMap<>(2048);
|
||||
this.sprinklerCache = new ConcurrentHashMap<>(1024);
|
||||
this.scarecrowCache = new ConcurrentHashMap<>(256);
|
||||
@@ -83,8 +81,8 @@ public class CustomWorld {
|
||||
});
|
||||
}
|
||||
|
||||
public void unload(boolean disable) {
|
||||
if (disable) {
|
||||
public void unload(boolean sync) {
|
||||
if (sync) {
|
||||
unloadData();
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user