mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-06-28 08:50:35 +00:00
![Paldiu](/assets/img/avatar_default.png)
Lombok implementation removal. I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!! Thank you!!
44 lines
1 KiB
Java
44 lines
1 KiB
Java
package me.totalfreedom.totalfreedommod.world;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.bukkit.World;
|
|
|
|
public enum WorldWeather
|
|
{
|
|
|
|
OFF("off"),
|
|
RAIN("rain"),
|
|
STORM("storm,thunderstorm");
|
|
//
|
|
private final List<String> aliases;
|
|
|
|
WorldWeather(String aliases)
|
|
{
|
|
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
|
|
}
|
|
|
|
public static WorldWeather getByAlias(String needle)
|
|
{
|
|
needle = needle.toLowerCase();
|
|
for (WorldWeather mode : values())
|
|
{
|
|
if (mode.aliases.contains(needle))
|
|
{
|
|
return mode;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void setWorldToWeather(World world)
|
|
{
|
|
world.setStorm(this == RAIN || this == STORM);
|
|
world.setWeatherDuration(this == RAIN || this == STORM ? 20 * 60 * 5 : 0);
|
|
|
|
world.setThundering(this == STORM);
|
|
world.setThunderDuration(this == STORM ? 20 * 60 * 5 : 0);
|
|
}
|
|
}
|