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!!
56 lines
1.2 KiB
Java
56 lines
1.2 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 WorldTime
|
|
{
|
|
|
|
INHERIT(),
|
|
SUNRISE("sunrise,morning", 0),
|
|
NOON("noon,midday,day", 6000),
|
|
SUNSET("sunset,evening", 12000),
|
|
MIDNIGHT("midnight,night", 18000);
|
|
//
|
|
private final int timeTicks;
|
|
private final List<String> aliases;
|
|
|
|
WorldTime()
|
|
{
|
|
this.timeTicks = 0;
|
|
this.aliases = null;
|
|
}
|
|
|
|
WorldTime(String aliases, int timeTicks)
|
|
{
|
|
this.timeTicks = timeTicks;
|
|
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
|
|
}
|
|
|
|
public static WorldTime getByAlias(String needle)
|
|
{
|
|
needle = needle.toLowerCase();
|
|
for (WorldTime time : values())
|
|
{
|
|
if (time.aliases != null && time.aliases.contains(needle))
|
|
{
|
|
return time;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getTimeTicks()
|
|
{
|
|
return timeTicks;
|
|
}
|
|
|
|
public void setWorldToTime(World world)
|
|
{
|
|
long time = world.getTime();
|
|
time -= time % 24000;
|
|
world.setTime(time + 24000 + getTimeTicks());
|
|
}
|
|
} |