mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-29 06:05:14 +01:00
679a88af3f
* Updated Upstream and Sidestream(s) (Paper/Airplane/Purpur/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 4b78c0b80 [CI-SKIP] [Auto] Rebuild Patches 2d9ff13eb forced whitelist: use configuable kick message (fixes #5417) (#5418) 000cec2ab bug #5432 - post modern event even if legacy event is cancelled 6c83bc6e5 Remove from Map by key 857852c28 Make sure to remove correct TE during TE tick f7b4abb25 [Auto] Updated Upstream (Bukkit/CraftBukkit) Airplane Changes: 9a4bd85 Remove Multithreaded Tracker 1068498 Updated Upstream (Tuinity) Purpur Changes: 083a86e [ci-skip] Update for Toothpick changes 8b9b214 Updated Upstream (Paper & Tuinity) Empirecraft Changes: 6b5cffc2 Updated Paper * Updated Upstream and Sidestream(s) (Airplane/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Airplane Changes: 3ed988c Use AIR library for configuration parsing Purpur Changes: 9631959 Add 5 sec TPS to GUI (#260) 2a0a5e6 [ci-skip] Bump Toothpick Kotlin version 02b3444 Add back multithreaded entity tracker 43b4a2f Updated Upstream (Paper & Airplane) * update gradle from 6.8.2 to 6.8.3 * fix build (hopefully) * Updated Upstream and Sidestream(s) (Paper) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 211f8e041 Prevent light queue overfill when no players are online * well that was dumb * FINALLY it works * Updated Upstream and Sidestream(s) (Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Empirecraft Changes: 018fcff7 Updated Paper
144 lines
4.4 KiB
Diff
144 lines
4.4 KiB
Diff
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/pom.xml b/pom.xml
|
|
index 67c70c38214f39739d56121dde76a12f584f2a64..0d960c173924f2ee97b9ad676d2c48c532b5ef5d 100644
|
|
--- a/pom.xml
|
|
+++ b/pom.xml
|
|
@@ -190,6 +190,12 @@
|
|
<artifactId>commons-math3</artifactId>
|
|
<version>3.6.1</version>
|
|
</dependency>
|
|
+ <!-- Fast Random -->
|
|
+ <dependency>
|
|
+ <groupId>org.apache.commons</groupId>
|
|
+ <artifactId>commons-rng-core</artifactId>
|
|
+ <version>1.3</version>
|
|
+ </dependency>
|
|
</dependencies>
|
|
|
|
<repositories>
|
|
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();
|
|
+ }
|
|
+ }
|
|
+}
|