mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 10:29:10 +00:00
3.6.17
This commit is contained in:
@@ -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