WeatherForecast class
Пакет: com.hypixel.hytale.server.core.asset.type.environment.config
Файл: com/hypixel/hytale/server/core/asset/type/environment/config/WeatherForecast.java
implements: IWeightedElement
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<WeatherForecast> |
CODEC |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
String |
getWeatherIdString getWeatherId() |
public |
int |
getWeatherIndexint getWeatherIndex() |
protected |
void |
processConfigvoid processConfig() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.environment.config;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.common.map.IWeightedElement;
class="kw">import com.hypixel.hytale.server.core.asset.type.weather.config.Weather;
class="kw">import javax.annotation.Nonnull;
class="kw">public class WeatherForecast class="kw">implements IWeightedElement {
class="kw">public class="kw">static class="kw">final BuilderCodec<WeatherForecast> CODEC = BuilderCodec.builder(WeatherForecast.class, WeatherForecast::new)
.append(new KeyedCodec<>("WeatherId", Codec.STRING), (var0, var1) -> var0.weatherId = var1, var0 -> var0.weatherId)
.addValidator(Validators.nonNull())
.addValidator(Weather.VALIDATOR_CACHE.getValidator())
.add()
.append(new KeyedCodec<>("Weight", Codec.DOUBLE, true), (var0, var1) -> var0.weight = var1, var0 -> var0.weight)
.add()
.afterDecode(WeatherForecast::processConfig)
.build();
class="kw">public class="kw">static class="kw">final WeatherForecast[] EMPTY_ARRAY = new WeatherForecast[0];
class="kw">protected String weatherId;
class="kw">protected class="kw">transient int weatherIndex;
class="kw">protected double weight;
class="kw">public WeatherForecast(String var1, double var2) {
this.weatherId = var1;
this.weight = var2;
}
class="kw">protected WeatherForecast() {
}
class="kw">public String getWeatherId() {
class="kw">return this.weatherId;
}
class="kw">public int getWeatherIndex() {
class="kw">return this.weatherIndex;
}
class="kw">protected void processConfig() {
this.weatherIndex = Weather.getAssetMap().getIndex(this.weatherId);
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "WeatherForecast{weatherId='" + this.weatherId + "', weatherIndex=" + this.weatherIndex + ", weight=" + this.weight + "}";
}
@Override
class="kw">public double getWeight() {
class="kw">return this.weight;
}
}