You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[!abstract] Product Overview
A generic, composable condition evaluation library for Hytale modders. Provides a fluent API for building complex conditional logic without boilerplate code.
Product Identity
Attribute
Value
Mod ID
sf-condition-framework
Maven Artifact
com.lordofthetales.framework:condition-framework
CurseForge Slug
hytale-condition-framework
License
MIT (free, open source)
Monetization
Free (reputation builder)
Target Audience
Mod developers
Dependencies
SF-01 Accessor API, SF-02 Core Library
Value Proposition
Problem Statement
Every Hytale mod that needs conditional logic (shops, quests, spawners, gates, events) ends up writing custom if-then code. This leads to:
Duplicated logic across mods
Inconsistent condition evaluation
No serialization for config files
Hard to debug nested conditions
Solution
A standardized condition library that:
Provides 20+ built-in condition types
Supports AND/OR/NOT composition
Serializes to/from YAML/JSON
Offers debug mode with evaluation traces
Is fully type-safe with generics
Feature Specification
CF-001: Core Condition Interface
/** * Base condition interface with composition support. * @param <C> The context type for evaluation */publicinterfaceCondition<CextendsConditionContext> {
/** * Evaluate this condition against a context. * @param context The evaluation context * @return true if condition is met */booleanevaluate(Ccontext);
/** * Get human-readable description. */StringgetDescription();
/** * Get unique condition type identifier for serialization. */StringgetType();
// ===== Composition Methods =====defaultCondition<C> and(Condition<C> other) {
returnnewAndCondition<>(this, other);
}
defaultCondition<C> or(Condition<C> other) {
returnnewOrCondition<>(this, other);
}
defaultCondition<C> not() {
returnnewNotCondition<>(this);
}
// ===== Static Factories =====static <CextendsConditionContext> Condition<C> always() {
returnctx -> true;
}
static <CextendsConditionContext> Condition<C> never() {
returnctx -> false;
}
static <CextendsConditionContext> Condition<C> all(List<Condition<C>> conditions) {
returnnewAllCondition<>(conditions);
}
static <CextendsConditionContext> Condition<C> any(List<Condition<C>> conditions) {
returnnewAnyCondition<>(conditions);
}
}
CF-002: Built-in Condition Types
Category
Condition
Description
Parameters
Player
HasLevel
Player meets minimum level
minLevel: int
Player
HasPermission
Player has permission node
permission: string
Player
HasPlaytime
Player has X hours played
minHours: int
Player
IsInGroup
Player in permission group
group: string
Inventory
HasItem
Has item in inventory
itemId: string, count: int
Inventory
HasItemTag
Has item with tag
tag: string, count: int
Inventory
HasEmptySlots
Has N empty slots
slots: int
Inventory
HasCurrency
Has enough currency
currency: string, amount: int
Location
InZone
Player in named zone
zoneId: string
Location
InBiome
Player in biome type
biome: string
Location
NearLocation
Within radius of point
x,y,z: int, radius: int
Location
InWorld
Player in world/dimension
world: string
Time
TimeOfDay
Game time in range
start: int, end: int
Time
DayOfWeek
Real-world day
days: list
Time
DateRange
Real-world date range
start: date, end: date
State
HasFlag
Player has boolean flag
flag: string
State
HasVariable
Variable comparison
var: string, op: enum, value: any
State
Cooldown
Cooldown has elapsed
key: string, duration: duration
Random
Chance
Random chance
probability: float
Custom
Script
Custom script evaluation
script: string
CF-003: Condition Context
/** * Base context interface - extend for your mod's needs. */publicinterfaceConditionContext {
/** * Get the player UUID being evaluated. */UUIDgetPlayerId();
/** * Get the current timestamp. */InstantgetTimestamp();
/** * Get arbitrary data by key. */
<T> Optional<T> getData(Stringkey, Class<T> type);
}
/** * Default player-focused context implementation. */publicclassPlayerConditionContextimplementsConditionContext {
privatefinalUUIDplayerId;
privatefinalPlayerplayer;
privatefinalMap<String, Object> additionalData;
// Player-specific accessorspublicintgetLevel() { ... }
publicVec3getPosition() { ... }
publicStringgetCurrentZone() { ... }
publicStringgetCurrentBiome() { ... }
publicInventorygetInventory() { ... }
publicSet<String> getPermissions() { ... }
publicMap<String, Object> getFlags() { ... }
// Builder for extensibilitypublicstaticBuilderbuilder(Playerplayer) {
returnnewBuilder(player);
}
publicstaticclassBuilder {
publicBuilderwithData(Stringkey, Objectvalue) { ... }
publicPlayerConditionContextbuild() { ... }
}
}
// Load from configConditionSerializerserializer = newConditionSerializer();
serializer.registerDefaults();
Condition<?> condition = serializer.deserialize(config.getSection("entry_requirement"));
// Use in your modif (condition.evaluate(context)) {
allowEntry();
}