diff --git a/gradle.properties b/gradle.properties index 2d37cfe..2e97395 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.1.0-1.19.2 \ No newline at end of file +mod_version=1.1.1-1.19.2 \ No newline at end of file diff --git a/src/main/java/com/skinnydevi/playtimelimiter/server/PlayerJoinListener.java b/src/main/java/com/skinnydevi/playtimelimiter/server/PlayerJoinListener.java index 46ccf43..c6236a0 100644 --- a/src/main/java/com/skinnydevi/playtimelimiter/server/PlayerJoinListener.java +++ b/src/main/java/com/skinnydevi/playtimelimiter/server/PlayerJoinListener.java @@ -3,6 +3,7 @@ import com.skinnydevi.playtimelimiter.PlaytimeLimiter; import com.skinnydevi.playtimelimiter.config.ConfigManager; import com.skinnydevi.playtimelimiter.playtime.PlaytimeDataManager; + import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -13,11 +14,11 @@ import java.text.DecimalFormat; import java.time.Duration; +import java.time.LocalTime; import java.util.concurrent.TimeUnit; public class PlayerJoinListener { - @SubscribeEvent public void onMPPlayerJoin(PlayerEvent.PlayerLoggedInEvent e) { if (!(e.getEntity() instanceof ServerPlayer)) @@ -39,6 +40,7 @@ public void onMPPlayerLeave(PlayerEvent.PlayerLoggedOutEvent e) { } private int tick; + private LocalTime oldTrackerTime = LocalTime.now(); @SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent e) { @@ -47,6 +49,11 @@ public void onServerTick(TickEvent.ServerTickEvent e) { tick++; if (tick % 20 == 0) { + LocalTime newTrackerTime = LocalTime.now(); + float diff = Duration.between(oldTrackerTime, newTrackerTime).toMillis() / 1000f; + oldTrackerTime = newTrackerTime; + int workingSecond = Math.round(diff); + PlaytimeDataManager.getTrackedPlayers().forEach(playerMP -> { if (playerMP.hasDisconnected()) { PlaytimeDataManager.savePlayer(playerMP); @@ -61,14 +68,14 @@ public void onServerTick(TickEvent.ServerTickEvent e) { */ if (ConfigManager.TRACK_TOTAL_PLAYTIME.get()) { PlaytimeDataManager.setTotalPlayedTime( - playerMP, PlaytimeDataManager.getTotalPlayedTime(playerMP) + 1 + playerMP, PlaytimeDataManager.getTotalPlayedTime(playerMP) + workingSecond ); } /* Playtime Logic */ - int newTime = PlaytimeDataManager.getRemainingTime(playerMP) - 1; + int newTime = PlaytimeDataManager.getRemainingTime(playerMP) - workingSecond; PlaytimeDataManager.setRemainingTime(playerMP, newTime); if (!compound.contains("timeout")) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 0ee55d9..7f76be8 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -11,7 +11,7 @@ loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft versio # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="MIT" # A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional +issueTrackerURL="https://github.com/SkinnyDevi/playtimelimiter/issues" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod @@ -25,7 +25,7 @@ displayName="§c§lPlaytime Limiter" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ #updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional +displayURL="https://www.curseforge.com/minecraft/mc-mods/skdvs-playtime-limiter-port-upgrade" #optional # A file name (in the root of the mod JAR) containing a logo for display logoFile="playtimelimiter-icon.png" #optional # A text field displayed in the mod UI