mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 10:29:10 +00:00
3.4.0.8
This commit is contained in:
@@ -68,9 +68,7 @@ public class CustomCropsPluginImpl extends CustomCropsPlugin {
|
||||
Dependency.ADVENTURE_TEXT_MINIMESSAGE,
|
||||
Dependency.ADVENTURE_LEGACY_SERIALIZER,
|
||||
Dependency.BSTATS_BASE,
|
||||
Dependency.BSTATS_BUKKIT,
|
||||
Dependency.BIOME_API,
|
||||
Dependency.ANTI_GRIEF
|
||||
Dependency.BSTATS_BUKKIT
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.momirealms.customcrops.compatibility.papi.ParseUtils;
|
||||
import net.momirealms.customcrops.mechanic.misc.CrowAttackAnimation;
|
||||
import net.momirealms.customcrops.utils.ClassUtils;
|
||||
import net.momirealms.customcrops.utils.ConfigUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.Farmland;
|
||||
@@ -94,6 +95,7 @@ public class ConditionManagerImpl implements ConditionManager {
|
||||
this.registerFertilizerCondition();
|
||||
this.registerCrowAttackCondition();
|
||||
this.registerPotCondition();
|
||||
this.registerLightCondition();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -621,6 +623,37 @@ public class ConditionManagerImpl implements ConditionManager {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLightCondition() {
|
||||
registerCondition("skylight_more_than", (args) -> {
|
||||
int value = (int) args;
|
||||
return block -> {
|
||||
int light = block.getLocation().getBukkitLocation().getBlock().getLightFromSky();
|
||||
return value > light;
|
||||
};
|
||||
});
|
||||
registerCondition("skylight_less_than", (args) -> {
|
||||
int value = (int) args;
|
||||
return block -> {
|
||||
int light = block.getLocation().getBukkitLocation().getBlock().getLightFromSky();
|
||||
return value < light;
|
||||
};
|
||||
});
|
||||
registerCondition("light_more_than", (args) -> {
|
||||
int value = (int) args;
|
||||
return block -> {
|
||||
int light = block.getLocation().getBukkitLocation().getBlock().getLightLevel();
|
||||
return value > light;
|
||||
};
|
||||
});
|
||||
registerCondition("light_less_than", (args) -> {
|
||||
int value = (int) args;
|
||||
return block -> {
|
||||
int light = block.getLocation().getBukkitLocation().getBlock().getLightLevel();
|
||||
return value < light;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerWaterCondition() {
|
||||
registerCondition("water_more_than", (args) -> {
|
||||
int value = (int) args;
|
||||
|
||||
@@ -1151,7 +1151,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
);
|
||||
}
|
||||
|
||||
this.registerItemFunction(sprinkler.get3DItemID(), FunctionTrigger.PLACE,
|
||||
this.registerItemFunction(new String[]{sprinkler.get3DItemID(), sprinkler.get3DItemWithWater()}, FunctionTrigger.PLACE,
|
||||
/*
|
||||
* This will only trigger if the sprinkler has only 3D items
|
||||
*/
|
||||
@@ -1184,7 +1184,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}, CFunction.FunctionPriority.NORMAL)
|
||||
);
|
||||
|
||||
this.registerItemFunction(sprinkler.get3DItemID(), FunctionTrigger.BE_INTERACTED,
|
||||
this.registerItemFunction(new String[]{sprinkler.get3DItemID(), sprinkler.get3DItemWithWater()}, FunctionTrigger.BE_INTERACTED,
|
||||
/*
|
||||
* Interact the sprinkler
|
||||
*/
|
||||
@@ -1261,7 +1261,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}, CFunction.FunctionPriority.NORMAL)
|
||||
);
|
||||
|
||||
this.registerItemFunction(sprinkler.get3DItemID(), FunctionTrigger.BE_INTERACTED,
|
||||
this.registerItemFunction(new String[]{sprinkler.get3DItemID(), sprinkler.get3DItemWithWater()}, FunctionTrigger.BE_INTERACTED,
|
||||
new CFunction(conditionWrapper -> {
|
||||
if (!(conditionWrapper instanceof InteractFurnitureWrapper interactFurnitureWrapper)) {
|
||||
return FunctionResult.PASS;
|
||||
@@ -1287,7 +1287,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}, CFunction.FunctionPriority.LOWEST)
|
||||
);
|
||||
|
||||
this.registerItemFunction(sprinkler.get3DItemID(), FunctionTrigger.BREAK,
|
||||
this.registerItemFunction(new String[]{sprinkler.get3DItemID(), sprinkler.get3DItemWithWater()}, FunctionTrigger.BREAK,
|
||||
/*
|
||||
* Handle breaking sprinklers
|
||||
*/
|
||||
@@ -2064,7 +2064,16 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerItemFunction(String[] items, FunctionTrigger trigger, CFunction... function) {
|
||||
for (String item : items) {
|
||||
if (item != null) {
|
||||
registerItemFunction(item, trigger, function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerItemFunction(String item, FunctionTrigger trigger, CFunction... function) {
|
||||
if (item == null) return;
|
||||
if (itemID2FunctionMap.containsKey(item)) {
|
||||
var previous = itemID2FunctionMap.get(item);
|
||||
TreeSet<CFunction> previousFunctions = previous.get(trigger);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PotConfig extends AbstractEventItem implements Pot {
|
||||
private final Requirement[] useRequirements;
|
||||
private final boolean acceptRainDrop;
|
||||
private final boolean acceptNearbyWater;
|
||||
private boolean isVanillaBlock;
|
||||
private final boolean isVanillaBlock;
|
||||
|
||||
public PotConfig(
|
||||
String key,
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Migration {
|
||||
// do migration
|
||||
if (config.contains("mechanics.season.sync-season")) {
|
||||
config.set("mechanics.sync-season.enable", config.getBoolean("mechanics.season.sync-season.enable"));
|
||||
config.set("mechanics.sync-season.reference", config.getBoolean("mechanics.season.sync-season.reference"));
|
||||
config.set("mechanics.sync-season.reference", config.getString("mechanics.season.sync-season.reference"));
|
||||
}
|
||||
if (config.contains("mechanics.season.greenhouse")) {
|
||||
config.set("mechanics.greenhouse.enable", config.getBoolean("mechanics.season.greenhouse.enable"));
|
||||
|
||||
@@ -124,6 +124,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.registerSneakRequirement();
|
||||
this.registerTemperatureRequirement();
|
||||
this.registerFertilizerRequirement();
|
||||
this.registerLightRequirement();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -242,6 +243,33 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLightRequirement() {
|
||||
registerRequirement("light", (args, actions, advanced) -> {
|
||||
List<Pair<Integer, Integer>> tempPairs = ConfigUtils.stringListArgs(args).stream().map(it -> ConfigUtils.splitStringIntegerArgs(it, "~")).toList();
|
||||
return state -> {
|
||||
Location location = state.getLocation();
|
||||
int temp = location.getBlock().getLightLevel();
|
||||
for (Pair<Integer, Integer> pair : tempPairs)
|
||||
if (temp >= pair.left() && temp <= pair.right())
|
||||
return true;
|
||||
if (advanced) triggerActions(actions, state);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("natural_light", (args, actions, advanced) -> {
|
||||
List<Pair<Integer, Integer>> tempPairs = ConfigUtils.stringListArgs(args).stream().map(it -> ConfigUtils.splitStringIntegerArgs(it, "~")).toList();
|
||||
return state -> {
|
||||
Location location = state.getLocation();
|
||||
int temp = location.getBlock().getLightFromSky();
|
||||
for (Pair<Integer, Integer> pair : tempPairs)
|
||||
if (temp >= pair.left() && temp <= pair.right())
|
||||
return true;
|
||||
if (advanced) triggerActions(actions, state);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerOrRequirement() {
|
||||
registerRequirement("||", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
|
||||
Reference in New Issue
Block a user