From 602366a545ae0d41bd14253e62f0be4c90afe019 Mon Sep 17 00:00:00 2001 From: tenkuma Date: Thu, 10 Apr 2025 12:54:24 -0300 Subject: [PATCH] First commit. --- .classpath | 12 +++++ .project | 17 +++++++ .settings/org.eclipse.core.resources.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 12 +++++ README.md | 12 +++++ bin/gd/rf/adrianvictor/realtime/Main$1.class | Bin 0 -> 2455 bytes bin/gd/rf/adrianvictor/realtime/Main.class | Bin 0 -> 1769 bytes config.yml | 4 ++ plugin.yml | 6 +++ src/gd/rf/adrianvictor/realtime/Main.java | 51 +++++++++++++++++++ 10 files changed, 116 insertions(+) create mode 100755 .classpath create mode 100755 .project create mode 100755 .settings/org.eclipse.core.resources.prefs create mode 100755 .settings/org.eclipse.jdt.core.prefs create mode 100644 README.md create mode 100644 bin/gd/rf/adrianvictor/realtime/Main$1.class create mode 100644 bin/gd/rf/adrianvictor/realtime/Main.class create mode 100755 config.yml create mode 100755 plugin.yml create mode 100755 src/gd/rf/adrianvictor/realtime/Main.java diff --git a/.classpath b/.classpath new file mode 100755 index 0000000..a20094d --- /dev/null +++ b/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100755 index 0000000..9296415 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + TimeKeeper + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100755 index 0000000..4824b80 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100755 index 0000000..f1d5502 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +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.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa534c2 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +This is a plugin for Minecraft beta that syncs the real world time with your in-game time. + +## How it works +It will calculate and change the game time every second (that's 20 ticks and that can be changed in the config), it will use your computer's timezone as default if the config `timezone` value does not exist. + +## Performance +I am not sure if this plugin has any significant performance hit, it runs code every few ticks (you can in/decrease the frequency in the config) and that is not the best approach for doing this, but it's the only that works in beta. Using it with `ticksBetweenUpdate: 1` does not seem to change the performance in any way. The specifications for the computer used for the tests: + +`Host: 83AF IdeaPad 1 14IAU7` +`CPU: 12th Gen Intel i5-1235U (12) @ 1.300GHz` +`GPU: Intel Alder Lake-UP3 GT2 [Iris Xe Graphics]` +`Memory: 10097MiB / 15709MiB` diff --git a/bin/gd/rf/adrianvictor/realtime/Main$1.class b/bin/gd/rf/adrianvictor/realtime/Main$1.class new file mode 100644 index 0000000000000000000000000000000000000000..875d5518bbe001a28cb2dac7a2966080ea2b7f1b GIT binary patch literal 2455 zcmX^0Z`VEs1_l#`Y3vM4j0{TYDf&fe`iUt;nTdI2naL&jMfydli8&>ixvBcTiJ5sS zhU^S1j0^%4iHO_hk=uUi;IDoL70bun?Zz;fms8jl;0;aFV(L!Hz~C! z1mYJVpZw&+oUp{AOb{O`$O7^pBZCS-_ox_JGcqt2mF96XNHfT?GsrM9@S%E;he3`( zo{@ngvm~`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epeatingTask(this, new Runnable() { + @Override + public void run() { + for (String worldName : worlds) { + World world = Bukkit.getServer().getWorld(worldName); + if (world == null) { + log.severe("World " + worldName + " specified in the config was not found, removing it."); + worlds.remove(worldName); + return; + } + ZonedDateTime time = ZonedDateTime.now(ZoneId.of(config.getString("timezone", ZoneId.systemDefault().toString()))); + int hour = time.getHour(); + int minute = time.getMinute(); + long minecraftTime = (hour * 1000 + minute * 100 / 6 - 6000) % 24000; + if (minecraftTime < 0) { + minecraftTime = minecraftTime * 2; + } + world.setTime(minecraftTime); + } + } + }, 0L, ticksBetweenUpdate); + } +}