mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 18:39:17 +00:00
API improvements
This commit is contained in:
@@ -44,7 +44,6 @@ import net.momirealms.customcrops.bukkit.requirement.PlayerRequirementManager;
|
||||
import net.momirealms.customcrops.bukkit.scheduler.BukkitSchedulerAdapter;
|
||||
import net.momirealms.customcrops.bukkit.sender.BukkitSenderFactory;
|
||||
import net.momirealms.customcrops.bukkit.world.BukkitWorldManager;
|
||||
import net.momirealms.customcrops.common.config.ConfigLoader;
|
||||
import net.momirealms.customcrops.common.dependency.Dependency;
|
||||
import net.momirealms.customcrops.common.dependency.DependencyManagerImpl;
|
||||
import net.momirealms.customcrops.common.helper.VersionHelper;
|
||||
@@ -122,11 +121,6 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
|
||||
return getBoostrap().getDataFolder().toPath().toAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigLoader getConfigManager() {
|
||||
return configManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerVersion() {
|
||||
return Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
@@ -177,7 +171,6 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
|
||||
boolean downloadFromPolymart = polymart.equals("1");
|
||||
boolean downloadFromBBB = buildByBit.equals("true");
|
||||
|
||||
((SimpleRegistryAccess) registryAccess).freeze();
|
||||
this.reload();
|
||||
if (ConfigManager.metrics()) new Metrics((JavaPlugin) getBoostrap(), 16593);
|
||||
if (ConfigManager.checkUpdate()) {
|
||||
@@ -197,18 +190,21 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// delayed init task
|
||||
if (VersionHelper.isFolia()) {
|
||||
Bukkit.getGlobalRegionScheduler().run(getBoostrap(), (scheduledTask) -> {
|
||||
((SimpleRegistryAccess) registryAccess).freeze();
|
||||
logger.info("Registry access has been frozen");
|
||||
((BukkitItemManager) itemManager).setAntiGriefLib(AntiGriefLib.builder((JavaPlugin) getBoostrap()).silentLogs(true).ignoreOP(true).build());
|
||||
EventUtils.fireAndForget(new CustomCropsReloadEvent(this));
|
||||
});
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(getBoostrap(), () -> {
|
||||
((SimpleRegistryAccess) registryAccess).freeze();
|
||||
logger.info("Registry access has been frozen");
|
||||
((BukkitItemManager) itemManager).setAntiGriefLib(AntiGriefLib.builder((JavaPlugin) getBoostrap()).silentLogs(false).ignoreOP(true).build());
|
||||
EventUtils.fireAndForget(new CustomCropsReloadEvent(this));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customcrops.bukkit.command.feature;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.core.Registries;
|
||||
import net.momirealms.customcrops.api.core.InternalRegistries;
|
||||
import net.momirealms.customcrops.api.core.block.CustomCropsBlock;
|
||||
import net.momirealms.customcrops.api.core.world.*;
|
||||
import net.momirealms.customcrops.bukkit.command.BukkitCommandFeature;
|
||||
@@ -59,10 +59,10 @@ public class ForceTickCommand extends BukkitCommandFeature<CommandSender> {
|
||||
.required("type", NamespacedKeyParser.namespacedKeyComponent().suggestionProvider(new SuggestionProvider<>() {
|
||||
@Override
|
||||
public @NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<Object> context, @NonNull CommandInput input) {
|
||||
int all = Registries.BLOCK.size();
|
||||
int all = InternalRegistries.BLOCK.size();
|
||||
ArrayList<CustomCropsBlock> blocks = new ArrayList<>();
|
||||
for (int i = 0; i < all; i++) {
|
||||
blocks.add(Registries.BLOCK.byId(i));
|
||||
blocks.add(InternalRegistries.BLOCK.byId(i));
|
||||
}
|
||||
return CompletableFuture.completedFuture(
|
||||
blocks.stream().map(block -> Suggestion.suggestion(block.type().asString())).toList()
|
||||
@@ -76,7 +76,7 @@ public class ForceTickCommand extends BukkitCommandFeature<CommandSender> {
|
||||
NamespacedKey type = context.get("type");
|
||||
Mode mode = context.get("mode");
|
||||
Key key = Key.key(type.asString());
|
||||
CustomCropsBlock customCropsBlock = Registries.BLOCK.get(key);
|
||||
CustomCropsBlock customCropsBlock = InternalRegistries.BLOCK.get(key);
|
||||
if (customCropsBlock == null) {
|
||||
handleFeedback(context.sender(), MessageConstants.COMMAND_FORCE_TICK_FAILURE_TYPE, Component.text(key.asString()));
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.momirealms.customcrops.api.action.ActionManager;
|
||||
import net.momirealms.customcrops.api.core.ConfigManager;
|
||||
import net.momirealms.customcrops.api.core.CustomForm;
|
||||
import net.momirealms.customcrops.api.core.ExistenceForm;
|
||||
import net.momirealms.customcrops.api.core.Registries;
|
||||
import net.momirealms.customcrops.api.core.InternalRegistries;
|
||||
import net.momirealms.customcrops.api.core.mechanic.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.core.mechanic.crop.CropStageConfig;
|
||||
import net.momirealms.customcrops.api.core.mechanic.fertilizer.FertilizerConfig;
|
||||
@@ -94,7 +94,7 @@ public class ConfigType {
|
||||
"fertilizers",
|
||||
(manager, id, section) -> {
|
||||
String typeName = Preconditions.checkNotNull(section.getString("type"), "Fertilizer type can't be null").toLowerCase(Locale.ENGLISH);
|
||||
FertilizerType type = Registries.FERTILIZER_TYPE.get(typeName);
|
||||
FertilizerType type = InternalRegistries.FERTILIZER_TYPE.get(typeName);
|
||||
if (type == null) {
|
||||
BukkitCustomCropsPlugin.getInstance().getPluginLogger().warn("Fertilizer type " + typeName + " not found");
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.flowpowered.nbt.stream.NBTInputStream;
|
||||
import com.flowpowered.nbt.stream.NBTOutputStream;
|
||||
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.core.ConfigManager;
|
||||
import net.momirealms.customcrops.api.core.Registries;
|
||||
import net.momirealms.customcrops.api.core.InternalRegistries;
|
||||
import net.momirealms.customcrops.api.core.block.CustomCropsBlock;
|
||||
import net.momirealms.customcrops.api.core.world.*;
|
||||
import net.momirealms.customcrops.api.core.world.adaptor.AbstractWorldAdaptor;
|
||||
@@ -415,7 +415,7 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor<World> {
|
||||
CompoundMap block = readCompound(blockData).getValue();
|
||||
Key key = keyFunction.apply((String) block.get("type").getValue());
|
||||
CompoundMap data = (CompoundMap) block.get("data").getValue();
|
||||
CustomCropsBlock customBlock = Registries.BLOCK.get(key);
|
||||
CustomCropsBlock customBlock = InternalRegistries.BLOCK.get(key);
|
||||
if (customBlock == null) {
|
||||
BukkitCustomCropsPlugin.getInstance().getInstance().getPluginLogger().warn("[" + world.worldName() + "] Unrecognized custom block " + key + " has been removed from chunk " + ChunkPos.of(x, z));
|
||||
continue;
|
||||
|
||||
@@ -228,12 +228,12 @@ tomato:
|
||||
point: 1
|
||||
conditions:
|
||||
season_condition:
|
||||
type: suitable_season
|
||||
type: suitable-season
|
||||
value:
|
||||
- Spring
|
||||
- Autumn
|
||||
water_condition:
|
||||
type: water_more_than
|
||||
type: water-more-than
|
||||
value: 0
|
||||
# Conditions that may cause the crop to die
|
||||
death-conditions:
|
||||
@@ -243,7 +243,7 @@ tomato:
|
||||
conditions:
|
||||
'&&':
|
||||
condition_1:
|
||||
type: water_less_than
|
||||
type: water-less-than
|
||||
value: 1
|
||||
condition_2:
|
||||
type: random
|
||||
@@ -253,14 +253,14 @@ tomato:
|
||||
model: {0}crop_stage_death
|
||||
conditions:
|
||||
condition_1:
|
||||
type: unsuitable_season
|
||||
type: unsuitable-season
|
||||
value:
|
||||
- Winter
|
||||
crow_attack:
|
||||
# Crop removal due to crow attack
|
||||
conditions:
|
||||
condition_1:
|
||||
type: crow_attack
|
||||
type: crow-attack
|
||||
value:
|
||||
chance: 0.005
|
||||
fly-model: {0}crow_fly
|
||||
|
||||
Reference in New Issue
Block a user