mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 10:29:10 +00:00
implement watering can
This commit is contained in:
@@ -213,6 +213,7 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
@Override
|
||||
public void registerWateringCanConfig(WateringCanConfig config) {
|
||||
Registries.WATERING_CAN.register(config.id(), config);
|
||||
Registries.ITEM_TO_WATERING_CAN.register(config.itemID(), config);
|
||||
Registries.ITEMS.register(config.itemID(), BuiltInItemMechanics.WATERING_CAN.mechanic());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ConfigType {
|
||||
.length(section.getInt("effective-range.length", 1))
|
||||
.potWhitelist(new HashSet<>(section.getStringList("pot-whitelist")))
|
||||
.sprinklerWhitelist(new HashSet<>(section.getStringList("sprinkler-whitelist")))
|
||||
.dynamicLore(section.getBoolean("dynamic-lore"))
|
||||
.dynamicLore(section.getBoolean("dynamic-lore.enable"))
|
||||
.lore(section.getStringList("dynamic-lore.lore").stream().map(TextValue::<Player>auto).toList())
|
||||
.fillMethods(manager.getFillMethods(section.getSection("fill-method")))
|
||||
.requirements(BukkitCustomCropsPlugin.getInstance().getRequirementManager(Player.class).parseRequirements(section.getSection("requirements"), true))
|
||||
@@ -115,6 +115,7 @@ public class ConfigType {
|
||||
|
||||
PotConfig config = PotConfig.builder()
|
||||
.id(id)
|
||||
.storage(section.getInt("storage", 5))
|
||||
.isRainDropAccepted(section.getBoolean("absorb-rainwater", false))
|
||||
.isNearbyWaterAccepted(section.getBoolean("absorb-nearby-water", false))
|
||||
.maxFertilizers(section.getInt("max-fertilizers", 1))
|
||||
@@ -187,6 +188,7 @@ public class ConfigType {
|
||||
int point = Integer.parseInt(entry.getKey());
|
||||
CropStageConfig.Builder builder = CropStageConfig.builder()
|
||||
.point(point)
|
||||
.existenceForm(inner.contains("type") ? CustomForm.valueOf(inner.getString("type").toUpperCase(Locale.ENGLISH)).existenceForm() : form)
|
||||
.displayInfoOffset(inner.getDouble("hologram-offset-correction"))
|
||||
.stageID(inner.getString("model"))
|
||||
.breakRequirements(prm.parseRequirements(inner.getSection("requirements.break"), true))
|
||||
|
||||
@@ -80,6 +80,11 @@ public class BukkitItemManager extends AbstractItemManager {
|
||||
this.factory = BukkitItemFactory.create(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
this.resetItemDetectionOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomEventListener(@NotNull AbstractCustomEventListener listener) {
|
||||
Objects.requireNonNull(listener, "listener cannot be null");
|
||||
@@ -392,7 +397,7 @@ public class BukkitItemManager extends AbstractItemManager {
|
||||
CustomCropsWorld<?> world = optionalWorld.get();
|
||||
WrappedInteractEvent wrapped = new WrappedInteractEvent(ExistenceForm.BLOCK, player, world, block.getLocation(), blockID, itemInHand, itemID, hand, blockFace, event);
|
||||
|
||||
handleInteractEvent(blockID, itemID, wrapped);
|
||||
handleInteractEvent(blockID, wrapped);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,11 +411,11 @@ public class BukkitItemManager extends AbstractItemManager {
|
||||
CustomCropsWorld<?> world = optionalWorld.get();
|
||||
WrappedInteractEvent wrapped = new WrappedInteractEvent(ExistenceForm.FURNITURE, player, world, location, furnitureID, itemInHand, itemID, hand, null, event);
|
||||
|
||||
handleInteractEvent(furnitureID, itemID, wrapped);
|
||||
handleInteractEvent(furnitureID, wrapped);
|
||||
}
|
||||
|
||||
private void handleInteractEvent(String blockID, String itemID, WrappedInteractEvent wrapped) {
|
||||
CustomCropsItem customCropsItem = Registries.ITEMS.get(itemID);
|
||||
private void handleInteractEvent(String blockID, WrappedInteractEvent wrapped) {
|
||||
CustomCropsItem customCropsItem = Registries.ITEMS.get(wrapped.itemID());
|
||||
if (customCropsItem != null) {
|
||||
InteractionResult result = customCropsItem.interactAt(wrapped);
|
||||
if (result != InteractionResult.PASS)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
Reference in New Issue
Block a user