API

The API adds many ways for developers to interact with RealisticSeasons. The RealisticSeasons API can be imported by importing the plugin jar directly into your project. Maven is still a work in progress. Don't forget to add RealisticSeasons as a (soft) depend in your plugin.yml. Here is a list of all the methods and events.

Methods

SeasonsAPI seasonsapi = SeasonsAPI.getInstance(); gets an instance of SeasonsAPI. This will be used in the next methods.

seasonsapi.setSeason(World w, Season s); seasonsapi.setSeason(p.getWorld(), Season.WINTER); Change the season in a world. Will also update the date.

Season season = seasonsapi.getSeason(World w); Get the current season of a world

seasonsapi.setDate(World w, Date date); seasonsapi.setDate(p.getWorld(), new Date(1, 1, 2022)); Change the date in a world. May also update seasons. Make sure to import the RealisticSeasons Date object and not the java one.

Date date = seasonsapi.getDate(World w); Get the current date in a world.

int temperature = seasonsapi.getTemperature(Player p); Get the temperature of a player

int airtemperature = seasonsapi.getAirTemperature(Location loc); Get air temperature on location.

seasonsapi.applyTimedTemperatureEffect(Player p, int modifier, int seconds); Apply a temporary temperature effect to a player. modifier is how much the temperature of the player should change.

TemperatureEffect effect = seasonsapi.applyPermanentTemperatureEffect(Player p, int modifier); Apply a "permanent" temperature effect to the player. The effect will not be removed unless you remove it yourself. Not persistent through restarts. effect.cancel(); The temperature effect will be removed again

int seconds = seasonsapi.getSeconds(World w); int minutes = seasonsapi.getMinutes(World w); int hours = seasonsapi.getHours(World w); Get seconds, minutes and hours of the time in a world. String dayOfWeek = seasonsapi.getDayOfWeek(World w) Get the day of the week as a name. It uses names in calendar.yml String monthName = seasonsapi.getCurrentMonthName(World w) Get month as a name. It uses names in calendar.yml

SeasonBiome biome = getReplacementSeasonBiome(String biomeName, Season s) SeasonBiome biome = getReplacementSeasonBiome(Location l, Season s) SeasonBiome biome = getReplacementSeasonBiome(Biome b, Season s) String hex = biome.getFogColor() String hex = biome.getWaterColor() String hex = biome.getWaterFogColor() String hex = biome.getSkyColor() String hex = biome.getFoliageColor() String hex = biome.getGrassColor() Get some information about the season colors in a biome or location. Format is in hex.

Events

The plugin also has its own events:

@EventHandler
 public void onSeasonChange(SeasonChangeEvent e) {
     Season newSeason = e.getNewSeason();
     Season oldSeason = e.getOldSeason();
     World w = e.getWorld();
     //Event is cancellable
     e.setCancelled(true);
 }
@EventHandler
 public void dayChange(DayChangeEvent e) {
     Date from = e.getFrom();
     Date to = e.getTo();
     World w = e.getWorld();
 }
@EventHandler
 public void particleStart(SeasonParticleStartEvent e) {
     Player p = e.getPlayer();
     Location loc = e.getLocation();
     SeasonParticle particle = e.getParticleType();
     //Event is cancellable
     e.setCancelled(true);
 }


SeasonParticle enum:
enum SeasonParticle {
    FIREFLY,
    SHOOTING_STAR,
    FALLING_LEAF,
    SMALL_FALLING_LEAF,
    COLD_BREATH
}

@EventHandler
 public void onSeasonEventStart(SeasonEventStart e) {
     World w = e.getWorld();
     SeasonCustomEvent customEvent = e.getCustomEvent();
     List<String> commands = customEvent.getCommands(true);
     boolean displayInEventList = customEvent.doDisplay();
     String displayName = customEvent.getName();
     
     //Event is cancellable
     e.setCancelled(true);
 }
@EventHandler
 public void onSeasonEventEnd(SeasonEventEnd e) {
     World w = e.getWorld();
     SeasonCustomEvent customEvent = e.getCustomEvent();
     List<String> commands = customEvent.getCommands(false);
     boolean displayInEventList = customEvent.doDisplay();
     String displayName = customEvent.getName();
 }
 
 
 @EventHandler
 public void onChunkRefresh(SeasonRefreshChunkEvent e) {
     Chunk c = e.getChunk();
     Player p = e.getPlayer();
     
     //Event is cancellable
     e.setCancelled(true); 
 }

Last updated