Package tk.airshipcraft.commonlib.calendar


package tk.airshipcraft.commonlib.calendar

This package, a part of AirshipCraft's CommonLib core library, provides a comprehensive calendar and event system for Minecraft servers. Designed to offer functionalities like seasonal changes, event scheduling, and dynamic in-game news, this system emphasizes ease of use, interoperability, and extensibility. It is particularly useful for enhancing server features such as agriculture, economy, and AI-driven NPCs.

Core Classes:

  • CustomDate - Represents a custom in-game date format with configurable days per month and months per year. Supports operations like adding days, comparing dates, and converting between real-world and in-game time.
  • WorldClock - Manages in-game time progression, synchronizing it with real-world time, and interacts with CalendarManager and EventManager for event triggers based on in-game dates.

Interfaces:

Abstract Classes:

  • AbstractGameEvent - Provides a template for creating various types of in-game events, including execution of commands and broadcasting messages.

Implementation Classes:

  • CalendarManager - Manages conversion between real-world and in-game time, maintaining the current date and allowing for time progression.
  • SeasonManager - Calculates current seasons based on in-game dates from CalendarManager.
  • EventManager - Manages event lifecycle, including scheduling and triggering events on specific dates.

Core Classes Usage Examples:


 // CustomDate Example
 CustomDate customDate = new CustomDate(1, 1, 1);
 customDate.addDays(30);
 LocalDate equivalentDate = customDate.toLocalDate();

 // WorldClock Example
 WorldClock worldClock = new WorldClock(plugin, calendarManager, eventManager);
 worldClock.start();

 // CalendarManager Example
 ICalendarManager calendar = new CalendarManager();
 LocalDate today = calendar.getCurrentDate();
 calendar.advanceTime(1);

 // SeasonManager Example
 ISeasonManager seasonManager = new SeasonManager(calendar);
 Season currentSeason = seasonManager.getCurrentSeason();

 // EventManager Example
 IEventManager eventManager = new EventManager();
 eventManager.scheduleEvent(today.plusDays(10), new AbstractGameEvent(...) {
     @Override
     public void trigger() {
         // Event logic here.
     }
 });
 eventManager.triggerEvents(today);
 

Example Use Cases:

  • SeasonManager - Uses for dynamic crop growth and harvest schedules in an Agriculture Plugin.
  • EventManager - Integrates for market events and sales linked to calendar events in an Economy Plugin.
  • CalendarManager - Uses for varying NPC behaviors and quests based on time of year in an NPC Interaction Plugin.

This package promotes a decoupled, layered approach to time-related functionalities for maintainable and scalable server architecture.

Since:
2023-12-27
Version:
1.0.0
Author:
notzune