mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-07-02 10:33:23 +00:00
![speed](/assets/img/avatar_default.png)
* rename everything containing staff back to admin (as requested by ryan i've renamed commands like slconfig to saconfig but left "slconfig" as an alias) * format almost every file correctly * a few other improvements
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 int getTimeTicks()
|
|
{
|
|
return timeTicks;
|
|
}
|
|
|
|
public void setWorldToTime(World world)
|
|
{
|
|
long time = world.getTime();
|
|
time -= time % 24000;
|
|
world.setTime(time + 24000 + getTimeTicks());
|
|
}
|
|
|
|
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;
|
|
}
|
|
} |