mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-06 18:59:38 +01:00
why was this even commited lol
This commit is contained in:
parent
c029945e1d
commit
31f850c5dd
@ -1,33 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: YatopiaMC <yatopiamc@gmail.com>
|
||||
Date: Sun, 17 Jan 2021 15:37:52 -0600
|
||||
Subject: [PATCH] Yatopia Config & Redirect Config
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index e88b47a838dc472ad64271a518ee1789f7be19fa..a69bf7aae1e9d6b658b079431d23ca0f28c871d1 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1606,6 +1606,22 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Origami start - add config to timings report
|
||||
+ @NotNull
|
||||
+ public org.bukkit.configuration.file.YamlConfiguration getOrigamiConfig()
|
||||
+ {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+ // Origami end
|
||||
+
|
||||
+ // Yatopia start - add config to timings report
|
||||
+ @NotNull
|
||||
+ public org.bukkit.configuration.file.YamlConfiguration getYatopiaConfig()
|
||||
+ {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+ // Yatopia end
|
||||
+
|
||||
/**
|
||||
* Sends the component to the player
|
||||
*
|
@ -1,75 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: tr7zw <tr7zw@live.de>
|
||||
Date: Sat, 1 Aug 2020 15:52:50 -0500
|
||||
Subject: [PATCH] Add GameProfileLookupEvent
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 6d04816e22f44a33c001d2b7e080402fba6af86c..dffd42fa0862a04fbb63dbc2c378d41eac2aafb5 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -27,6 +27,7 @@ dependencies {
|
||||
api("org.ow2.asm:asm:9.0")
|
||||
api("org.ow2.asm:asm-commons:9.0")
|
||||
api("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
|
||||
+ api("com.mojang:authlib:2.3.31") // Yatopia
|
||||
|
||||
compileOnly("org.apache.maven:maven-resolver-provider:3.8.1")
|
||||
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0")
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/events/GameProfileLookupEvent.java b/src/main/java/org/yatopiamc/yatopia/server/events/GameProfileLookupEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f96afc8f1b04f4bf46a2acbca95ebcfebfa01182
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/events/GameProfileLookupEvent.java
|
||||
@@ -0,0 +1,51 @@
|
||||
+package org.yatopiamc.yatopia.server.events;
|
||||
+
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import java.util.UUID;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class GameProfileLookupEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private GameProfile gameProfile = null;
|
||||
+ private final UUID uuid;
|
||||
+ private final String name;
|
||||
+
|
||||
+ public GameProfileLookupEvent(boolean async, @NotNull UUID uuid, @NotNull String name) {
|
||||
+ super(async);
|
||||
+ this.uuid = uuid;
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public GameProfile getGameProfile() {
|
||||
+ return gameProfile;
|
||||
+ }
|
||||
+
|
||||
+ public void setGameProfile(@Nullable GameProfile gameProfile) {
|
||||
+ this.gameProfile = gameProfile;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public UUID getUuid() {
|
||||
+ return uuid;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public String getName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
@ -1,242 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Toffikk <slodkitofik@gmail.com>
|
||||
Date: Wed, 16 Jun 2021 15:04:11 +0100
|
||||
Subject: [PATCH] Rebrand
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index f111042223f0d7974785c37245bb60b75388163e..494297e5bed54f7cf41711032391fce991d5efa8 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -19,8 +19,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":Paper-API"))
|
||||
- implementation(project(":Paper-MojangAPI"))
|
||||
+ implementation(project(":Yatopia-API")) // Yatopia
|
||||
+ implementation("com.destroystokyo.paper:paper-mojangapi:1.16.5-R0.1-SNAPSHOT") // Yatopia
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.12.1")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.2.0")
|
||||
@@ -65,7 +65,7 @@ tasks.jar {
|
||||
attributes(mapOf(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Paper-\"$gitHash\"",
|
||||
+ "Implementation-Version" to "git-Yatopia-\"$gitHash\"", // Yatopia
|
||||
"Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
@@ -119,7 +119,7 @@ tasks.test {
|
||||
fun TaskContainer.registerRunTask(
|
||||
name: String, block: JavaExec.() -> Unit
|
||||
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
||||
- group = "paper"
|
||||
+ group = "paperweight" // Yatopia
|
||||
standardInput = System.`in`
|
||||
workingDir = rootProject.layout.projectDirectory.dir(
|
||||
providers.gradleProperty("runWorkDir").forUseAtConfigurationTime().orElse("run")
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
index e0b1f0671d16ddddcb6725acd25a1d1d69e42701..d943a45200b89f541347d0bc7a3e8494022066db 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
||||
@Override
|
||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
||||
builder
|
||||
- .appName("Paper")
|
||||
+ .appName("Yatopia") // Yatopia
|
||||
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
||||
.completer(new ConsoleCommandCompleter(this.server))
|
||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 1f29c92776aea8dbba52d4cb197addce5b3e4d5e..893a992156efb7b01b13efe9637704ac99c19baa 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1634,7 +1634,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Paper"; //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return "Yatopia"; // Yatopia // Paper // Spigot // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 8a98bd1018afd934696fedbed24e271ab6b75f51..5c85cdb4ef4ffeebdadf01a4ad4a23801bd3fdca 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -230,7 +230,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "Paper"; // Paper
|
||||
+ private final String serverName = "Yatopia"; // Paper // Yatopia
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index a2a62bfb747994c43b8b0b607af90d3be2836873..faa5cbb07a735312954e0b78c7902a31d0a2d48d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -395,7 +395,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
|
||||
@Override
|
||||
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||
- return new com.destroystokyo.paper.PaperVersionFetcher();
|
||||
+ return new org.yatopiamc.yatopia.server.util.VersionFetcher.YatopiaVersionFetcher(); // Yatopia
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index 774556a62eb240da42e84db4502e2ed43495be17..359e64243b0b7adcc44138d192ea8fad7b10a542 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties");
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.yatopiamc.yatopia/yatopia-api/pom.properties"); // Yatopia
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/VersionFetcher/YatopiaVersionFetcher.java b/src/main/java/org/yatopiamc/yatopia/server/util/VersionFetcher/YatopiaVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a0dc55e0fd646e31edda78ff9e68c0beb2b276e3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/VersionFetcher/YatopiaVersionFetcher.java
|
||||
@@ -0,0 +1,132 @@
|
||||
+package org.yatopiamc.yatopia.server.util.VersionFetcher;
|
||||
+
|
||||
+import com.destroystokyo.paper.VersionHistoryManager;
|
||||
+import com.google.common.base.Charsets;
|
||||
+import com.google.common.io.Resources;
|
||||
+import com.google.gson.Gson;
|
||||
+import com.google.gson.JsonObject;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStream;
|
||||
+import java.io.InputStreamReader;
|
||||
+import java.net.HttpURLConnection;
|
||||
+import java.net.URL;
|
||||
+import java.net.URLEncoder;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Objects;
|
||||
+import java.util.jar.Manifest;
|
||||
+import javax.annotation.Nonnull;
|
||||
+
|
||||
+import com.destroystokyo.paper.util.VersionFetcher;
|
||||
+import javax.annotation.Nullable;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+
|
||||
+public class YatopiaVersionFetcher implements VersionFetcher {
|
||||
+
|
||||
+ @Override
|
||||
+ public long getCacheTime() {
|
||||
+ return 3600000;
|
||||
+ }
|
||||
+
|
||||
+ @Nonnull
|
||||
+ @Override
|
||||
+ public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
+ if (serverVersion.equals("null")) return Component.text("Custom build");
|
||||
+ String[] parts = serverVersion.substring("git-Yatopia-".length()).split("[-\\s]");
|
||||
+ String branch = String.join("-", Arrays.copyOfRange(parts, 0, parts.length - 3));
|
||||
+ String version = parts[parts.length - 3];
|
||||
+ final Component updateMessage = getUpdateStatusMessage("YatopiaMC/Yatopia", branch, version);
|
||||
+ final Component history = getHistory();
|
||||
+
|
||||
+ return history != null ? TextComponent.ofChildren(history, Component.newline(), updateMessage) : updateMessage;
|
||||
+ }
|
||||
+
|
||||
+ private Component getUpdateStatusMessage(String repo, String branch, String versionInfo) {
|
||||
+ int distance;
|
||||
+ try {
|
||||
+ int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
+ distance = fetchDistanceFromJenkins(branch, jenkinsBuild);
|
||||
+ } catch (NumberFormatException ignored) {
|
||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo.replace("\"", ""));
|
||||
+ }
|
||||
+
|
||||
+ switch (distance) {
|
||||
+ case -1:
|
||||
+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
+ case 0:
|
||||
+ return Component.text("You are running the latest version", NamedTextColor.GREEN);
|
||||
+ case -2:
|
||||
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
|
||||
+ default:
|
||||
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // modified from PurpurVersionFetcher
|
||||
+ private static int fetchDistanceFromJenkins(String branch, int jenkinsBuild) {
|
||||
+ try {
|
||||
+ try (BufferedReader reader = Resources.asCharSource(new URL("https://ci.codemc.io/job/YatopiaMC/job/Yatopia/job/" + URLEncoder.encode(branch, Charsets.UTF_8.name()) + "/lastStableBuild/buildNumber"), Charsets.UTF_8).openBufferedStream()) {
|
||||
+ return Integer.decode(reader.readLine()) - jenkinsBuild;
|
||||
+ } catch (NumberFormatException ex) {
|
||||
+ ex.printStackTrace();
|
||||
+ return -2;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Contributed by Techcable <Techcable@outlook.com> in GH-65
|
||||
+ // from PaperVersionFetcher
|
||||
+ private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) {
|
||||
+ try {
|
||||
+ HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
+ connection.connect();
|
||||
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit
|
||||
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
|
||||
+ JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
|
||||
+ String status = obj.get("status").getAsString();
|
||||
+ switch (status) {
|
||||
+ case "identical":
|
||||
+ return 0;
|
||||
+ case "behind":
|
||||
+ return obj.get("behind_by").getAsInt();
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (JsonSyntaxException | NumberFormatException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // from PaperVersionFetcher
|
||||
+ @Nullable
|
||||
+ private Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ final String oldVersion = data.getOldVersion();
|
||||
+ if (oldVersion == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
+}
|
@ -1,138 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: YatopiaMC <yatopiamc@gmail.com>
|
||||
Date: Fri, 23 Oct 2020 09:20:01 -0700
|
||||
Subject: [PATCH] Utilities
|
||||
|
||||
This patch includes all utilities required by the Yatopia project and its patches.
|
||||
|
||||
Co-authored-by: Mykyta Komarnytskyy <nkomarn@hotmail.com>
|
||||
Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 494297e5bed54f7cf41711032391fce991d5efa8..80a2ba2fe63ad6fd6e83f46cd29b4cabe64023b0 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -37,6 +37,7 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
|
||||
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.14.1") // Paper
|
||||
implementation("org.ow2.asm:asm:9.1")
|
||||
+ implementation("org.apache.commons:commons-rng-core:1.3")
|
||||
implementation("com.googlecode.json-simple:json-simple:1.1.1") {
|
||||
// This includes junit transitively for whatever reason
|
||||
isTransitive = false
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/Constants.java b/src/main/java/org/yatopiamc/yatopia/server/util/Constants.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ac5235155eb1b5515165fc9648b7c9d7a0713b44
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/Constants.java
|
||||
@@ -0,0 +1,7 @@
|
||||
+package org.yatopiamc.yatopia.server.util;
|
||||
+
|
||||
+public class Constants {
|
||||
+
|
||||
+ public static final int[] EMPTY_ARRAY = new int[0];
|
||||
+ public static final int[] ZERO_ARRAY = new int[]{0};
|
||||
+}
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java b/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e41c1e3fa656d8f595733897ab05089c3b0976a7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java
|
||||
@@ -0,0 +1,64 @@
|
||||
+package org.yatopiamc.yatopia.server.util;
|
||||
+
|
||||
+import org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus;
|
||||
+
|
||||
+import java.util.Random;
|
||||
+import java.util.SplittableRandom;
|
||||
+
|
||||
+public class FastRandom extends Random {
|
||||
+
|
||||
+ private XoRoShiRo128PlusPlus random;
|
||||
+
|
||||
+ public FastRandom() {
|
||||
+ super();
|
||||
+ SplittableRandom randomseed = new SplittableRandom();
|
||||
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ public FastRandom(long seed) {
|
||||
+ super(seed);
|
||||
+ SplittableRandom randomseed = new SplittableRandom(seed);
|
||||
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean nextBoolean() {
|
||||
+ return random.nextBoolean();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt() {
|
||||
+ return random.nextInt();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public float nextFloat() {
|
||||
+ return (float) random.nextDouble();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double nextDouble() {
|
||||
+ return random.nextDouble();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public synchronized void setSeed(long seed) {
|
||||
+ SplittableRandom randomseed = new SplittableRandom(seed);
|
||||
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void nextBytes(byte[] bytes) {
|
||||
+ random.nextBytes(bytes);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt(int bound) {
|
||||
+ return random.nextInt(bound);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long nextLong() {
|
||||
+ return random.nextLong();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..acdf3d60738791b767a3bafa2c9511342a8c18df
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package org.yatopiamc.yatopia.server.util;
|
||||
+
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class TimeUtils {
|
||||
+
|
||||
+ public static String getFriendlyName(TimeUnit unit) {
|
||||
+ switch (unit) {
|
||||
+ case NANOSECONDS:
|
||||
+ return "ns";
|
||||
+ case MILLISECONDS:
|
||||
+ return "ms";
|
||||
+ case MICROSECONDS:
|
||||
+ return "micros";
|
||||
+ case SECONDS:
|
||||
+ return "s";
|
||||
+ case MINUTES:
|
||||
+ return "m";
|
||||
+ case DAYS:
|
||||
+ return "d";
|
||||
+ case HOURS:
|
||||
+ return "h";
|
||||
+ default:
|
||||
+ throw new AssertionError();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
Loading…
Reference in New Issue
Block a user