mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-20 15:39:21 +00:00
3.6.17
This commit is contained in:
@@ -195,8 +195,9 @@ public interface CustomCropsWorld<W> {
|
||||
* Saves the world data to a file.
|
||||
*
|
||||
* @param async async or not
|
||||
* @param disabling is the server disabled
|
||||
*/
|
||||
void save(boolean async);
|
||||
void save(boolean async, boolean disabling);
|
||||
|
||||
/**
|
||||
* Sets whether the ticking task is ongoing.
|
||||
|
||||
@@ -186,13 +186,17 @@ public class CustomCropsWorldImpl<W> implements CustomCropsWorld<W> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(boolean async) {
|
||||
if (async) {
|
||||
public void save(boolean async, boolean disabling) {
|
||||
if (async && !disabling) {
|
||||
this.scheduler.async().execute(this::save);
|
||||
} else {
|
||||
if (disabling) {
|
||||
save();
|
||||
} else {
|
||||
BukkitCustomCropsPlugin.getInstance().getScheduler().sync().run(this::save, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
long time1 = System.currentTimeMillis();
|
||||
|
||||
@@ -67,9 +67,10 @@ public interface WorldManager extends Reloadable {
|
||||
* Unloads the CustomCrops world associated with the specified Bukkit world.
|
||||
*
|
||||
* @param world The Bukkit world to unload.
|
||||
* @param disabling
|
||||
* @return True if the world was successfully unloaded, false otherwise.
|
||||
*/
|
||||
boolean unloadWorld(World world);
|
||||
boolean unloadWorld(World world, boolean disabling);
|
||||
|
||||
/**
|
||||
* Retrieves a CustomCrops world based on the specified Bukkit world, if loaded.
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractRequirementManager<T> implements RequirementManage
|
||||
if (inner != null) {
|
||||
requirements.add(parseRequirement(inner, runActions));
|
||||
} else {
|
||||
plugin.getPluginLogger().warn("Section " + typeOrName + " is misconfigured");
|
||||
plugin.getPluginLogger().warn("Section " + section.getRouteAsString() + "." + typeOrName + " is misconfigured");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=3.6.16
|
||||
project_version=3.6.17
|
||||
config_version=41
|
||||
project_group=net.momirealms
|
||||
|
||||
@@ -40,9 +40,9 @@ guava_version=33.3.1-jre
|
||||
vault_version=1.7
|
||||
|
||||
# Proxy settings
|
||||
#systemProp.socks.proxyHost=127.0.0.1
|
||||
#systemProp.socks.proxyPort=7890
|
||||
#systemProp.http.proxyHost=127.0.0.1
|
||||
#systemProp.http.proxyPort=7890
|
||||
#systemProp.https.proxyHost=127.0.0.1
|
||||
#systemProp.https.proxyPort=7890
|
||||
systemProp.socks.proxyHost=127.0.0.1
|
||||
systemProp.socks.proxyPort=7890
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=7890
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=7890
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ConfigType {
|
||||
.vanillaPots(ListUtils.toList(section.get("vanilla-blocks")))
|
||||
.ignoreRandomTick(section.getBoolean("ignore-random-tick", false))
|
||||
.ignoreScheduledTick(section.getBoolean("ignore-scheduled-tick", false))
|
||||
.storage(section.getInt("storage", 5))
|
||||
.storage(section.getInt("storage", section.getInt("max-water-storage", 5)))
|
||||
.isRainDropAccepted(section.getBoolean("absorb-rainwater", false))
|
||||
.isNearbyWaterAccepted(section.getBoolean("absorb-nearby-water", false))
|
||||
.maxFertilizers(section.getInt("max-fertilizers", 1))
|
||||
|
||||
@@ -80,6 +80,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
||||
}
|
||||
int amount = section.getInt("amount", 0);
|
||||
List<String> items = ListUtils.toList(section.get("item"));
|
||||
boolean any = items.contains("any") || items.contains("*");
|
||||
return context -> {
|
||||
Player player = context.holder();
|
||||
if (player == null) return true;
|
||||
@@ -96,7 +97,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
||||
}
|
||||
String id = plugin.getItemManager().id(itemStack);
|
||||
if (!regex) {
|
||||
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
||||
if ((any || items.contains(id)) && itemStack.getAmount() >= amount) return true;
|
||||
} else {
|
||||
for (String itemRegex : items) {
|
||||
if (id.matches(itemRegex) && itemStack.getAmount() >= amount) {
|
||||
@@ -130,6 +131,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
||||
}
|
||||
int amount = section.getInt("amount", 0);
|
||||
List<String> items = ListUtils.toList(section.get("material"));
|
||||
boolean any = items.contains("any") || items.contains("*");
|
||||
return context -> {
|
||||
Player player = context.holder();
|
||||
if (player == null) return true;
|
||||
@@ -146,7 +148,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
||||
}
|
||||
String id = itemStack.getType().name();
|
||||
if (!regex) {
|
||||
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
||||
if ((any || items.contains(id)) && itemStack.getAmount() >= amount) return true;
|
||||
} else {
|
||||
for (String itemRegex : items) {
|
||||
if (id.matches(itemRegex) && itemStack.getAmount() >= amount) {
|
||||
|
||||
@@ -129,7 +129,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
if (isMechanicEnabled(world)) {
|
||||
loadWorld(world);
|
||||
} else {
|
||||
unloadWorld(world);
|
||||
unloadWorld(world, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
public void disable() {
|
||||
this.unload();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
unloadWorld(world);
|
||||
unloadWorld(world, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,13 +217,13 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadWorld(World world) {
|
||||
public boolean unloadWorld(World world, boolean disabling) {
|
||||
CustomCropsWorld<?> removedWorld = worlds.remove(world.getName());
|
||||
if (removedWorld == null) {
|
||||
return false;
|
||||
}
|
||||
removedWorld.setTicking(false);
|
||||
removedWorld.save(false);
|
||||
removedWorld.save(false, disabling);
|
||||
removedWorld.scheduler().shutdownScheduler();
|
||||
removedWorld.scheduler().shutdownExecutor();
|
||||
return true;
|
||||
@@ -232,7 +232,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
final World world = event.getWorld();
|
||||
getWorld(world).ifPresent(world1 -> world1.save(true));
|
||||
getWorld(world).ifPresent(world1 -> world1.save(true, false));
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGH)
|
||||
@@ -246,7 +246,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
World world = event.getWorld();
|
||||
if (!isMechanicEnabled(world)) return;
|
||||
unloadWorld(world);
|
||||
unloadWorld(world, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
Reference in New Issue
Block a user