This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I don't keep track of the changes because I do some work and commit at the end of the day you can see what changed looking at the code and files changed
- Loading branch information
1 parent
a8fd1c4
commit ab6df79
Showing
8 changed files
with
91 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
- readd metrics | ||
- fix realtime | ||
- cache cleaning | ||
- prevent packets | ||
- prevent packets | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/pl/minecon724/realweather/realtime/PlayerTimeSyncTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package pl.minecon724.realweather.realtime; | ||
|
||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import pl.minecon724.realweather.map.Coordinates; | ||
import pl.minecon724.realweather.map.WorldMap; | ||
import pl.minecon724.realweather.map.exceptions.GeoIPException; | ||
|
||
public class PlayerTimeSyncTask extends BukkitRunnable { | ||
private WorldMap worldMap = WorldMap.getInstance(); | ||
private Logger logger = Logger.getLogger("timezone sync"); | ||
|
||
private List<World> worlds; | ||
|
||
public PlayerTimeSyncTask(List<World> worlds) { | ||
this.worlds = worlds; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
for (Player player : Bukkit.getOnlinePlayers()) { | ||
if (!worlds.contains(player.getWorld())) { | ||
player.resetPlayerTime(); | ||
continue; | ||
} | ||
|
||
Coordinates coordinates; | ||
|
||
try { | ||
coordinates = worldMap.getCoordinates(player); | ||
} catch (GeoIPException e) { | ||
logger.warning( | ||
String.format("Unable to determine GeoIP for %s (%s)", | ||
player.getAddress().getHostString())); | ||
|
||
continue; | ||
} | ||
|
||
// longitude | ||
// / 15 as 15 degrees is 1 hour | ||
// * 60 to minutes | ||
// * 60 again to seconds | ||
// * 20 to ticks | ||
long offset = (long) (coordinates.longitude / 15 * 72000); | ||
|
||
player.setPlayerTime(offset, true); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters