mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 20:31:30 +01:00
Fix time conversion code
This commit is contained in:
parent
b9f10a2e0c
commit
2d8ea825a2
@ -509,7 +509,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
despawnNPCs(false);
|
||||
ProfileFetcher.reset();
|
||||
Skin.clearCache();
|
||||
|
||||
getServer().getPluginManager().callEvent(new CitizensPreReloadEvent());
|
||||
|
||||
saves.reloadFromSource();
|
||||
@ -622,6 +621,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
Messaging.logTr(Messages.NUM_LOADED_NOTIFICATION, Iterables.size(npcRegistry), "?");
|
||||
startMetrics();
|
||||
System.out.println(Setting.SAVE_TASK_DELAY.asTicks());
|
||||
System.out.println(Setting.SAVE_TASK_DELAY.asTicks() / 20);
|
||||
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asTicks());
|
||||
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
|
||||
new PlayerUpdateTask().runTaskTimer(Citizens.this, 0, 1);
|
||||
|
@ -230,7 +230,7 @@ public class Settings {
|
||||
if (duration == null) {
|
||||
duration = SpigotUtil.parseDuration(asString());
|
||||
}
|
||||
return (int) TimeUnit.SECONDS.convert(duration.getNano(), TimeUnit.NANOSECONDS);
|
||||
return Util.convert(TimeUnit.SECONDS, duration);
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
|
@ -574,7 +574,7 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
|
||||
public NPCCommandBuilder cooldown(Duration cd) {
|
||||
return cooldown((int) TimeUnit.SECONDS.convert(cd.getNano(), TimeUnit.NANOSECONDS));
|
||||
return cooldown(Util.convert(TimeUnit.SECONDS, cd));
|
||||
}
|
||||
|
||||
public NPCCommandBuilder cooldown(int cooldown) {
|
||||
@ -588,7 +588,7 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
|
||||
public NPCCommandBuilder globalCooldown(Duration cd) {
|
||||
return globalCooldown((int) TimeUnit.SECONDS.convert(cd.getNano(), TimeUnit.NANOSECONDS));
|
||||
return globalCooldown(Util.convert(TimeUnit.SECONDS, cd));
|
||||
}
|
||||
|
||||
public NPCCommandBuilder globalCooldown(int cooldown) {
|
||||
|
@ -91,6 +91,11 @@ public class Util {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public static int convert(TimeUnit unit, Duration delay) {
|
||||
return (int) (unit.convert(delay.getSeconds(), TimeUnit.SECONDS)
|
||||
+ unit.convert(delay.getNano(), TimeUnit.NANOSECONDS));
|
||||
}
|
||||
|
||||
public static ItemStack createItem(Material mat, String name) {
|
||||
return createItem(mat, name, null);
|
||||
}
|
||||
@ -411,7 +416,8 @@ public class Util {
|
||||
}
|
||||
|
||||
public static int toTicks(Duration delay) {
|
||||
return (int) TimeUnit.MILLISECONDS.convert(delay.getNano(), TimeUnit.NANOSECONDS) / 50;
|
||||
return (int) (TimeUnit.MILLISECONDS.convert(delay.getSeconds(), TimeUnit.SECONDS)
|
||||
+ TimeUnit.MILLISECONDS.convert(delay.getNano(), TimeUnit.NANOSECONDS)) / 50;
|
||||
}
|
||||
|
||||
private static final Location AT_LOCATION = new Location(null, 0, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user