Removed RealTimeDay -> Replace with seperate Plugin
This commit is contained in:
@@ -1,62 +0,0 @@
|
|||||||
package de.anura.core;
|
|
||||||
|
|
||||||
import de.anura.core.API.Core;
|
|
||||||
import de.anura.core.API.Errors;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
public class RealTime {
|
|
||||||
|
|
||||||
public static void setup() {
|
|
||||||
try {
|
|
||||||
if (Core.getMainClass().getConfig().getBoolean("realtime-day")) {
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
world.setGameRuleValue("doDaylightCycle", "false");
|
|
||||||
world.setTime(0);
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), () -> {
|
|
||||||
Integer[] time = getSystemTime();
|
|
||||||
int TTime = convertTime(time[0], time[1]);
|
|
||||||
setWorldTime(TTime);
|
|
||||||
}, 0, (20 * 60 * 10));
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Errors.reportException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Integer[] getSystemTime() {
|
|
||||||
Date date = new Date();
|
|
||||||
Calendar calendar = GregorianCalendar.getInstance();
|
|
||||||
calendar.setTime(date);
|
|
||||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
|
||||||
int minute = calendar.get(Calendar.MINUTE);
|
|
||||||
Integer[] time = new Integer[]{hour, minute};
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setWorldTime(Integer ticks) {
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
world.setGameRuleValue("doDaylightCycle", "false");
|
|
||||||
world.setTime(ticks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int convertTime(Integer hour, Integer minute) {
|
|
||||||
int TMinute = (int) (83 * (round(minute, 5)) / 5);
|
|
||||||
int THour;
|
|
||||||
if (hour >= 6) {
|
|
||||||
THour = (hour - 6) * 1000;
|
|
||||||
} else {
|
|
||||||
THour = ((hour + 24) - 6) * 1000;
|
|
||||||
}
|
|
||||||
return THour + TMinute;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double round(double num, int multipleOf) {
|
|
||||||
return Math.floor((num + (double) multipleOf / 2) / multipleOf) * multipleOf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,6 @@ public class Setup {
|
|||||||
c.addDefault("disable-mushroom-spread", false);
|
c.addDefault("disable-mushroom-spread", false);
|
||||||
c.addDefault("on-join-to-spawn", false);
|
c.addDefault("on-join-to-spawn", false);
|
||||||
c.addDefault("golf", false);
|
c.addDefault("golf", false);
|
||||||
c.addDefault("realtime-day", false);
|
|
||||||
c.addDefault("no-snow-melt", false);
|
c.addDefault("no-snow-melt", false);
|
||||||
c.addDefault("no-bed-explode", false);
|
c.addDefault("no-bed-explode", false);
|
||||||
c.addDefault("spawn.world", "none");
|
c.addDefault("spawn.world", "none");
|
||||||
@@ -88,7 +87,6 @@ public class Setup {
|
|||||||
AnuraCore.pots = new FlowerPots();
|
AnuraCore.pots = new FlowerPots();
|
||||||
AnuraCore.signs = new Signs();
|
AnuraCore.signs = new Signs();
|
||||||
AnuraCore.level = new Level();
|
AnuraCore.level = new Level();
|
||||||
RealTime.setup();
|
|
||||||
ResultSet rs = Core.getMySql().querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
ResultSet rs = Core.getMySql().querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
World w = Bukkit.getWorld(rs.getString("world"));
|
World w = Bukkit.getWorld(rs.getString("world"));
|
||||||
|
|||||||
Reference in New Issue
Block a user