diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 91ca62e..8b5c4dc 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -8,7 +8,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/src/com/projectkorra/rpg/RPGListener.java b/src/com/projectkorra/rpg/RPGListener.java index e62ac33..d985860 100644 --- a/src/com/projectkorra/rpg/RPGListener.java +++ b/src/com/projectkorra/rpg/RPGListener.java @@ -138,7 +138,7 @@ public void onSunRise(SunRiseEvent event) { ProjectKorraRPG.getEventManager().endEvent(event.getWorld(), wEvent); } else if (wEvent.getTime() == Time.DAY || wEvent.getTime() == Time.BOTH) { - if ((Math.ceil((event.getWorld().getFullTime() / 24000)) + 1) % wEvent.getFrequency() == 0) { + if (Math.ceil((event.getWorld().getFullTime() / 24000)) % wEvent.getFrequency() == 0) { WorldEventStartEvent startEvent = new WorldEventStartEvent(event.getWorld(), wEvent); Bukkit.getServer().getPluginManager().callEvent(startEvent); @@ -146,7 +146,7 @@ public void onSunRise(SunRiseEvent event) { continue; } - ProjectKorraRPG.getEventManager().startEvent(event.getWorld(), wEvent); + ProjectKorraRPG.getEventManager().startEvent(event.getWorld(), wEvent, true); } } else { if (ProjectKorraRPG.getEventManager().isHappening(event.getWorld(), wEvent)) { @@ -167,7 +167,7 @@ public void onSunRise(SunRiseEvent event) { public void onSunSet(SunSetEvent event) { for (WorldEvent wEvent : WorldEvent.getEvents()) { if (wEvent.getTime() == Time.NIGHT) { - if ((Math.ceil((event.getWorld().getFullTime() / 24000)) + 1) % wEvent.getFrequency() == 0) { + if (Math.ceil((event.getWorld().getFullTime() / 24000)) % wEvent.getFrequency() == 0) { WorldEventStartEvent startEvent = new WorldEventStartEvent(event.getWorld(), wEvent); Bukkit.getServer().getPluginManager().callEvent(startEvent); @@ -175,7 +175,7 @@ public void onSunSet(SunSetEvent event) { continue; } - ProjectKorraRPG.getEventManager().startEvent(event.getWorld(), wEvent); + ProjectKorraRPG.getEventManager().startEvent(event.getWorld(), wEvent, true); } } else if (wEvent.getTime() == Time.DAY) { if (ProjectKorraRPG.getEventManager().isHappening(event.getWorld(), wEvent)) { diff --git a/src/com/projectkorra/rpg/commands/EventCommand.java b/src/com/projectkorra/rpg/commands/EventCommand.java index 3a2fe88..280b969 100644 --- a/src/com/projectkorra/rpg/commands/EventCommand.java +++ b/src/com/projectkorra/rpg/commands/EventCommand.java @@ -161,7 +161,7 @@ public void execute(CommandSender sender, List args) { } else if (ProjectKorraRPG.getEventManager().isHappening(world, event)) { sender.sendMessage(ChatColor.RED + "That WorldEvent is already happening!"); } else { - ProjectKorraRPG.getEventManager().startEvent(world, event); + ProjectKorraRPG.getEventManager().startEvent(world, event, false); sender.sendMessage(ChatColor.GOLD + "Successfully started the " + event.getName() + " event!"); } } diff --git a/src/com/projectkorra/rpg/worldevent/util/EventManager.java b/src/com/projectkorra/rpg/worldevent/util/EventManager.java index e4ecadc..ec88d04 100644 --- a/src/com/projectkorra/rpg/worldevent/util/EventManager.java +++ b/src/com/projectkorra/rpg/worldevent/util/EventManager.java @@ -68,25 +68,28 @@ public void run() { } } - public void startEvent(World world, WorldEvent event) { + public void startEvent(World world, WorldEvent event, boolean natural) { if (marker.get(world).contains(event)) { return; } - double daysLeft = ((Math.ceil((world.getFullTime() / 24000)) + 1) % event.getFrequency()); - if (daysLeft > 0) { - world.setFullTime(world.getFullTime() + (long) daysLeft * 24000); - } - - if (event.getTime() != Time.BOTH && event.getTime() != time) { - long difference = 0; - if (event.getTime() == Time.DAY) { - difference = 24000 - world.getTime(); - } else { - difference = 12000 - world.getTime(); + if (!natural) { + double daysLeft = event.getFrequency() - (Math.ceil((world.getFullTime() / 24000)) % event.getFrequency()); + + if (daysLeft > 0) { + world.setFullTime(world.getFullTime() + (long) daysLeft * 24000); + } + + if (event.getTime() != Time.BOTH && event.getTime() != time) { + long difference = 0; + if (event.getTime() == Time.DAY) { + difference = 24000 - world.getTime(); + } else { + difference = 12000 - world.getTime(); + } + world.setFullTime(world.getFullTime() + difference); + time = event.getTime(); } - world.setFullTime(world.getFullTime() + difference); - time = event.getTime(); } marker.get(world).add(event);