First commit.
This commit is contained in:
commit
602366a545
10 changed files with 116 additions and 0 deletions
12
.classpath
Executable file
12
.classpath
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/tenkumaLib"/>
|
||||||
|
<classpathentry kind="lib" path="/home/adrian/archive/minecraft-jar/craftbukkit-1060.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
17
.project
Executable file
17
.project
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>TimeKeeper</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
.settings/org.eclipse.core.resources.prefs
Executable file
2
.settings/org.eclipse.core.resources.prefs
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
12
.settings/org.eclipse.jdt.core.prefs
Executable file
12
.settings/org.eclipse.jdt.core.prefs
Executable file
|
|
@ -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
|
||||||
12
README.md
Normal file
12
README.md
Normal file
|
|
@ -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`
|
||||||
BIN
bin/gd/rf/adrianvictor/realtime/Main$1.class
Normal file
BIN
bin/gd/rf/adrianvictor/realtime/Main$1.class
Normal file
Binary file not shown.
BIN
bin/gd/rf/adrianvictor/realtime/Main.class
Normal file
BIN
bin/gd/rf/adrianvictor/realtime/Main.class
Normal file
Binary file not shown.
4
config.yml
Executable file
4
config.yml
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
ticksBetweenUpdate: 20
|
||||||
|
timezone: "America/Sao_Paulo" # comment this line to use system's default timezone
|
||||||
|
worlds:
|
||||||
|
- "world"
|
||||||
6
plugin.yml
Executable file
6
plugin.yml
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
author: tenkuma
|
||||||
|
database: false
|
||||||
|
main: gd.rf.adrianvictor.realtime.Main
|
||||||
|
name: TimeKeeper
|
||||||
|
url: https://adrianvictor.rf.gd
|
||||||
|
version: '1.0'
|
||||||
51
src/gd/rf/adrianvictor/realtime/Main.java
Executable file
51
src/gd/rf/adrianvictor/realtime/Main.java
Executable file
|
|
@ -0,0 +1,51 @@
|
||||||
|
package gd.rf.adrianvictor.realtime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import gd.rf.adrianvictor.lib.Log;
|
||||||
|
import gd.rf.adrianvictor.lib.ConfigurationEx;
|
||||||
|
|
||||||
|
public class Main extends JavaPlugin {
|
||||||
|
Log log;
|
||||||
|
ConfigurationEx config;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
log.info("Disabling!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
log = new Log(this);
|
||||||
|
log.info("Starting!");
|
||||||
|
config = new ConfigurationEx(this, "config.yml", log);
|
||||||
|
config.loadConfig();
|
||||||
|
int ticksBetweenUpdate = config.getInt("ticksBetweenUpdate", 20);
|
||||||
|
List<String> worlds = config.getStringList("worlds", null);
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue