public class Util extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Util.IdentityHashStrategy |
static class |
Util.OperatingSystem |
Modifier and Type | Field and Description |
---|---|
private static ExecutorService |
BOOTSTRAP_EXECUTOR |
private static ExecutorService |
IO_WORKER_EXECUTOR |
private static Logger |
LOGGER |
private static ExecutorService |
MAIN_WORKER_EXECUTOR |
static LongSupplier |
nanoTimeSupplier |
private static AtomicInteger |
NEXT_WORKER_ID |
static UUID |
NIL_UUID |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
private static void |
attemptShutdown(ExecutorService service) |
private static boolean |
attemptTasks(BooleanSupplier[] booleanSupplier) |
private static boolean |
attemptTasks(int retries,
String taskName,
BooleanSupplier[] tasks) |
static void |
backupAndReplace(File current,
File newFile,
File backup) |
static void |
backupAndReplace(Path current,
Path newPath,
Path backup)
Copies
current to backup and then replaces current with newPath |
static <V> CompletableFuture<List<V>> |
combine(List<? extends CompletableFuture<? extends V>> futures) |
static <T> CompletableFuture<T> |
completeExceptionally(Throwable throwable) |
private static ExecutorService |
createIoWorker() |
static String |
createTranslationKey(String type,
Identifier id) |
private static ExecutorService |
createWorker(String name) |
static Runnable |
debugRunnable(Runnable runnable,
Supplier<String> messageSupplier) |
private static BooleanSupplier |
deleteTask(Path path) |
private static BooleanSupplier |
deletionVerifyTask(Path path) |
private static BooleanSupplier |
existenceCheckTask(Path path) |
static Executor |
getBootstrapExecutor() |
static com.mojang.datafixers.types.Type<?> |
getChoiceType(com.mojang.datafixers.DSL.TypeReference typeReference,
String id) |
private static com.mojang.datafixers.types.Type<?> |
getChoiceTypeInternal(com.mojang.datafixers.DSL.TypeReference typeReference,
String id) |
static long |
getEpochTimeMs() |
static String |
getInnermostMessage(Throwable t) |
static Executor |
getIoWorkerExecutor() |
static Stream<String> |
getJVMFlags() |
static <T> T |
getLast(List<T> list) |
static Executor |
getMainWorkerExecutor() |
static long |
getMeasuringTimeMs() |
static long |
getMeasuringTimeNano() |
static Util.OperatingSystem |
getOperatingSystem() |
static int |
getRandom(int[] array,
Random random) |
static <T> T |
getRandom(T[] array,
Random random) |
static <T extends Comparable<T>> |
getValueAsString(Property<T> property,
Object object) |
static <K> it.unimi.dsi.fastutil.Hash.Strategy<K> |
identityHashStrategy() |
static <T> Optional<T> |
ifPresentOrElse(Optional<T> optional,
Consumer<T> consumer,
Runnable runnable) |
static <T> T |
make(Supplier<T> factory) |
static <T> T |
make(T object,
Consumer<T> initializer) |
private static void |
method_18347(Thread thread,
Throwable throwable) |
static Consumer<String> |
method_29188(String string,
Consumer<String> consumer) |
static int |
moveCursor(String string,
int cursor,
int delta)
Moves the
cursor in the string by a delta amount. |
static <T> T |
next(Iterable<T> iterable,
T t) |
static <T> T |
previous(Iterable<T> iterable,
T t) |
static void |
relativeCopy(Path src,
Path dest,
Path toCopy)
Copies a file contained in the folder
src to the folder dest . |
private static BooleanSupplier |
renameTask(Path src,
Path dest) |
static String |
replaceInvalidChars(String string,
CharPredicate predicate) |
static void |
shutdownExecutors() |
static void |
startTimerHack() |
static <T> Stream<T> |
stream(Optional<? extends T> optional) |
static <T extends Throwable> |
throwOrPause(T t) |
static void |
throwUnchecked(Throwable throwable) |
static com.mojang.serialization.DataResult<int[]> |
toIntArray(IntStream intStream,
int length) |
static <K,V> Collector<Map.Entry<? extends K,? extends V>,?,Map<K,V>> |
toMap() |
private static final AtomicInteger NEXT_WORKER_ID
private static final ExecutorService BOOTSTRAP_EXECUTOR
private static final ExecutorService MAIN_WORKER_EXECUTOR
private static final ExecutorService IO_WORKER_EXECUTOR
public static LongSupplier nanoTimeSupplier
public static final UUID NIL_UUID
private static final Logger LOGGER
public static <T extends Comparable<T>> String getValueAsString(Property<T> property, Object object)
public static String createTranslationKey(String type, @Nullable Identifier id)
public static long getMeasuringTimeMs()
public static long getMeasuringTimeNano()
public static long getEpochTimeMs()
private static ExecutorService createWorker(String name)
public static Executor getBootstrapExecutor()
public static Executor getMainWorkerExecutor()
public static Executor getIoWorkerExecutor()
public static void shutdownExecutors()
private static void attemptShutdown(ExecutorService service)
private static ExecutorService createIoWorker()
@Environment(value=CLIENT) public static <T> CompletableFuture<T> completeExceptionally(Throwable throwable)
@Environment(value=CLIENT) public static void throwUnchecked(Throwable throwable)
@Nullable public static com.mojang.datafixers.types.Type<?> getChoiceType(com.mojang.datafixers.DSL.TypeReference typeReference, String id)
@Nullable private static com.mojang.datafixers.types.Type<?> getChoiceTypeInternal(com.mojang.datafixers.DSL.TypeReference typeReference, String id)
public static Util.OperatingSystem getOperatingSystem()
public static <T> T getLast(List<T> list)
public static <T> T make(Supplier<T> factory)
public static <T> T make(T object, Consumer<T> initializer)
public static <K> it.unimi.dsi.fastutil.Hash.Strategy<K> identityHashStrategy()
public static <V> CompletableFuture<List<V>> combine(List<? extends CompletableFuture<? extends V>> futures)
public static <T> Optional<T> ifPresentOrElse(Optional<T> optional, Consumer<T> consumer, Runnable runnable)
public static Runnable debugRunnable(Runnable runnable, Supplier<String> messageSupplier)
public static <T extends Throwable> T throwOrPause(T t)
public static <T> T getRandom(T[] array, Random random)
public static int getRandom(int[] array, Random random)
private static BooleanSupplier renameTask(Path src, Path dest)
private static BooleanSupplier deleteTask(Path path)
private static BooleanSupplier deletionVerifyTask(Path path)
private static BooleanSupplier existenceCheckTask(Path path)
private static boolean attemptTasks(BooleanSupplier[] booleanSupplier)
private static boolean attemptTasks(int retries, String taskName, BooleanSupplier[] tasks)
public static void backupAndReplace(Path current, Path newPath, Path backup)
current
to backup
and then replaces current
with newPath
@Environment(value=CLIENT) public static int moveCursor(String string, int cursor, int delta)
cursor
in the string
by a delta
amount.
Skips surrogate characters.public static com.mojang.serialization.DataResult<int[]> toIntArray(IntStream intStream, int length)
public static void startTimerHack()
@Environment(value=CLIENT) public static void relativeCopy(Path src, Path dest, Path toCopy) throws IOException
src
to the folder dest
.
This will replicate any path structure that may exist between src
and toCopy
.IOException
@Environment(value=CLIENT) public static String replaceInvalidChars(String string, CharPredicate predicate)