# 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();`\
\&#xNAN;*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);`\
\&#xNAN;*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));`\
\&#xNAN;*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);`\
\&#xNAN;*Get the current date in a world.*

`int temperature = seasonsapi.getTemperature(Player p);`\
\&#xNAN;*Get the temperature of a player*

`int airtemperature = seasonsapi.getAirTemperature(Location loc);`\
\&#xNAN;*Get air temperature on location.*

`seasonsapi.applyTimedTemperatureEffect(Player p, int modifier, int seconds);`\
\&#xNAN;*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);`\
\&#xNAN;*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();`\
\&#xNAN;*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);`\
\&#xNAN;*Get seconds, minutes and hours of the time in a world.*\
\
`String dayOfWeek = seasonsapi.getDayOfWeek(World w)`\
\&#xNAN;*Get the day of the week as a name. It uses names in calendar.yml*\
\
`String monthName = seasonsapi.getCurrentMonthName(World w)`\
\&#xNAN;*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()`\
\&#xNAN;*Get some information about the season colors in a biome or location. Format is in hex.*&#x20;

### 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); 
 }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.realisticseasons.com/developers/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
