com/hypixel/hytale/server/core/util/AssetUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.server.core.asset.AssetModule;
import java.nio.file.Path;
public class AssetUtil {
public AssetUtil () {
}
@Deprecated(
forRemoval = true
)
public static Path getHytaleAssetsPath () {
return AssetModule.get().getBaseAssetPack().getRoot();
}
}
com/hypixel/hytale/server/core/util/BsonUtil.java
package com.hypixel.hytale.server.core.util;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.common.util.ExceptionUtil;
import com.hypixel.hytale.common.util.PathUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
import io.netty.buffer.ByteBuf;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonBinaryReader;
import org.bson.BsonBinaryWriter;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.BsonValue;
import org.bson.codecs.BsonDocumentCodec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.bson.io.BasicOutputBuffer;
import org.bson.json.JsonMode;
import org.bson.json.JsonWriter;
import org.bson.json.JsonWriterSettings;
public class BsonUtil {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
public static final JsonWriterSettings SETTINGS;
private static final BsonDocumentCodec codec;
private static final DecoderContext decoderContext;
private static final EncoderContext encoderContext;
public static final BsonDocumentCodec BSON_DOCUMENT_CODEC;
public BsonUtil () {
}
public static byte [] writeToBytes(@Nullable BsonDocument document) {
if (document == null ) {
return ArrayUtil.EMPTY_BYTE_ARRAY;
} else {
BasicOutputBuffer buffer = new BasicOutputBuffer ();
byte [] var2;
try {
codec.encode(new BsonBinaryWriter (buffer), (BsonDocument)document, encoderContext);
var2 = buffer.toByteArray();
} catch (Throwable var5) {
try {
buffer.close();
} catch (Throwable var4) {
var5.addSuppressed(var4);
}
throw var5;
}
buffer.close();
return var2;
}
}
public static BsonDocument readFromBytes (@Nullable byte [] buf) {
return buf != null && buf.length != 0 ? codec.decode(new BsonBinaryReader (ByteBuffer.wrap(buf)), decoderContext) : null ;
}
public static BsonDocument readFromBuffer (@Nullable ByteBuffer buf) {
return buf != null && buf.hasRemaining() ? codec.decode(new BsonBinaryReader (buf), decoderContext) : null ;
}
public static BsonDocument readFromBinaryStream (@Nonnull ByteBuf buf) {
return readFromBytes(ByteBufUtil.readByteArray(buf));
}
public static void writeToBinaryStream (@Nonnull ByteBuf buf, BsonDocument doc) {
ByteBufUtil.writeByteArray(buf, writeToBytes(doc));
}
@Nonnull
public static CompletableFuture<Void> writeDocumentBytes (@Nonnull Path file, BsonDocument document) {
try {
if (Files.isRegularFile(file, new LinkOption [0 ])) {
Path resolve = file.resolveSibling(String.valueOf(file.getFileName()) + ".bak" );
Files.move(file, resolve, StandardCopyOption.REPLACE_EXISTING);
}
BasicOutputBuffer bob = new BasicOutputBuffer ();
byte [] bytes;
try {
codec.encode(new BsonBinaryWriter (bob), (BsonDocument)document, encoderContext);
bytes = bob.toByteArray();
} catch (Throwable var7) {
try {
bob.close();
} catch (Throwable var6) {
var7.addSuppressed(var6);
}
throw var7;
}
bob.close();
return CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> Files.write(file, bytes, new OpenOption [0 ])));
} catch (IOException e) {
return CompletableFuture.failedFuture(e);
}
}
@Nonnull
public static CompletableFuture<Void> writeDocument (@Nonnull Path file, BsonDocument document) {
return writeDocument(file, document, true );
}
@Nonnull
public static CompletableFuture<Void> writeDocument (@Nonnull Path file, BsonDocument document, boolean backup) {
try {
Path parent = PathUtil.getParent(file);
if (!Files.exists(parent, new LinkOption [0 ])) {
Files.createDirectories(parent);
}
if (backup && Files.isRegularFile(file, new LinkOption [0 ])) {
Path resolve = file.resolveSibling(String.valueOf(file.getFileName()) + ".bak" );
Files.move(file, resolve, StandardCopyOption.REPLACE_EXISTING);
}
String json = toJson(document);
return CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> Files.writeString(file, json)));
} catch (IOException e) {
return CompletableFuture.failedFuture(e);
}
}
@Nonnull
public static CompletableFuture<BsonDocument> readDocument (@Nonnull Path file) {
return readDocument(file, true );
}
@Nonnull
public static CompletableFuture<BsonDocument> readDocument (@Nonnull Path file, boolean backup) {
BasicFileAttributes attributes;
try {
attributes = Files.readAttributes(file, BasicFileAttributes.class);
} catch (IOException var4) {
if (backup) {
return readDocumentBak(file);
}
return CompletableFuture.completedFuture((Object)null );
}
if (attributes.size() == 0L ) {
LOGGER.at(Level.WARNING).log("Error loading file %s, file was found to be entirely empty" , file);
return backup ? readDocumentBak(file) : CompletableFuture.completedFuture((Object)null );
} else {
CompletableFuture<BsonDocument> future = CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> Files.readString(file)))).thenApply(BsonDocument::parse);
return backup ? future.exceptionallyCompose((t) -> readDocumentBak(file)) : future;
}
}
@Nullable
public static BsonDocument readDocumentNow (@Nonnull Path file) {
BasicFileAttributes attributes;
try {
attributes = Files.readAttributes(file, BasicFileAttributes.class);
} catch (IOException e) {
((HytaleLogger.Api)HytaleLogger.getLogger().atWarning()).log(ExceptionUtil.toStringWithStack(e));
return null ;
}
if (attributes.size() == 0L ) {
return null ;
} else {
String contentsString;
try {
contentsString = Files.readString(file);
} catch (IOException var4) {
return null ;
}
return BsonDocument.parse(contentsString);
}
}
@Nonnull
public static CompletableFuture<BsonDocument> readDocumentBak (@Nonnull Path fileOrig) {
Path file = fileOrig.resolveSibling(String.valueOf(fileOrig.getFileName()) + ".bak" );
BasicFileAttributes attributes;
try {
attributes = Files.readAttributes(file, BasicFileAttributes.class);
} catch (IOException var4) {
return CompletableFuture.completedFuture((Object)null );
}
if (attributes.size() == 0L ) {
LOGGER.at(Level.WARNING).log("Error loading backup file %s, file was found to be entirely empty" , file);
return CompletableFuture.completedFuture((Object)null );
} else {
LOGGER.at(Level.WARNING).log("Loading %s backup file for %s!" , file, fileOrig);
return CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> Files.readString(file)))).thenApply(BsonDocument::parse);
}
}
public static BsonValue translateJsonToBson (@Nonnull JsonElement element) {
return (BsonValue)(element.isJsonObject() ? BsonDocument.parse(element.toString()) : new BsonString (element.getAsString()));
}
public static JsonElement translateBsonToJson (BsonDocument value) {
try {
StringWriter writer = new StringWriter ();
JsonElement var2;
try {
codec.encode(new JsonWriter (writer, SETTINGS), (BsonDocument)value, encoderContext);
var2 = JsonParser.parseString(writer.toString());
} catch (Throwable var5) {
try {
writer.close();
} catch (Throwable var4) {
var5.addSuppressed(var4);
}
throw var5;
}
writer.close();
return var2;
} catch (IOException e) {
throw new RuntimeException (e);
}
}
public static String toJson (BsonDocument document) {
StringWriter writer = new StringWriter ();
BSON_DOCUMENT_CODEC.encode(new JsonWriter (writer, SETTINGS), (BsonDocument)document, encoderContext);
return writer.toString();
}
public static <T> void writeSync (@Nonnull Path path, @Nonnull Codec<T> codec, T value, @Nonnull HytaleLogger logger) throws IOException {
Path parent = PathUtil.getParent(path);
if (!Files.exists(parent, new LinkOption [0 ])) {
Files.createDirectories(parent);
}
if (Files.isRegularFile(path, new LinkOption [0 ])) {
Path resolve = path.resolveSibling(String.valueOf(path.getFileName()) + ".bak" );
Files.move(path, resolve, StandardCopyOption.REPLACE_EXISTING);
}
ExtraInfo extraInfo = (ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
BsonValue bsonValue = codec.encode(value, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(logger);
BsonDocument document = bsonValue.asDocument();
BufferedWriter writer = Files.newBufferedWriter(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
try {
BSON_DOCUMENT_CODEC.encode(new JsonWriter (writer, SETTINGS), (BsonDocument)document, encoderContext);
} catch (Throwable var12) {
if (writer != null ) {
try {
writer.close();
} catch (Throwable var11) {
var12.addSuppressed(var11);
}
}
throw var12;
}
if (writer != null ) {
writer.close();
}
}
static {
SETTINGS = JsonWriterSettings.builder().outputMode(JsonMode.STRICT).indent(true ).newLineCharacters("\n" ).int64Converter((value, writer) -> writer.writeNumber(Long.toString(value))).build();
codec = new BsonDocumentCodec ();
decoderContext = DecoderContext.builder().build();
encoderContext = EncoderContext.builder().build();
BSON_DOCUMENT_CODEC = new BsonDocumentCodec ();
}
}
com/hypixel/hytale/server/core/util/Config.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Config <T> {
@Nonnull
private final Path path;
private final String name;
private final BuilderCodec<T> codec;
@Nullable
private T config;
@Nullable
private CompletableFuture<T> loadingConfig;
public Config (@Nonnull Path path, String name, BuilderCodec<T> codec) {
this .path = path.resolve(name + ".json" );
this .name = name;
this .codec = codec;
}
@Nonnull
@Deprecated(
forRemoval = true
)
public static <T> Config<T> {
Config<T> c = <T>(path, name, codec);
c.config = config;
c;
}
CompletableFuture<T> {
( .loadingConfig != ) {
.loadingConfig;
} (!Files.exists( .path, [ ])) {
.config = .codec.getDefaultValue();
CompletableFuture.completedFuture( .config);
} {
.loadingConfig = CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> {
.config = (T)RawJsonReader.readSync( .path, .codec, HytaleLogger.getLogger());
.loadingConfig = ;
.config;
})));
}
}
T {
( .config == && .loadingConfig == ) {
( );
} {
(T)( .loadingConfig != ? .loadingConfig.join() : .config);
}
}
CompletableFuture<Void> {
( .config == && .loadingConfig == ) {
( );
} {
.loadingConfig != ? CompletableFuture.completedFuture((Object) ) : BsonUtil.writeDocument( .path, .codec.encode( .config, ()));
}
}
}
com/hypixel/hytale/server/core/util/ConsoleColorUtil.java
package com.hypixel.hytale.server.core.util;
public class ConsoleColorUtil {
public static final String BLACK = "\u001b[0;30m" ;
public static final String RED = "\u001b[0;31m" ;
public static final String GREEN = "\u001b[0;32m" ;
public static final String YELLOW = "\u001b[0;33m" ;
public static final String BLUE = "\u001b[0;34m" ;
public static final String PURPLE = "\u001b[0;35m" ;
public static final String CYAN = "\u001b[0;36m" ;
;
{
}
}
com/hypixel/hytale/server/core/util/DumpUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.fastutil.longs.Long2ObjectConcurrentHashMap;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.common.util.StringUtil;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.metric.ArchetypeChunkData;
import com.hypixel.hytale.component.system.ISystem;
import com.hypixel.hytale.logger.backend.HytaleFileHandler;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.metrics.InitStackThread;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import com.hypixel.hytale.plugin.early.ClassTransformer;
import com.hypixel.hytale.plugin.early.EarlyPluginLoader;
import com.hypixel.hytale.protocol.io.PacketStatsRecorder;
import com.hypixel.hytale.protocol.packets.connection.PongType;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.HytaleServerConfig;
import com.hypixel.hytale.server.core.ShutdownReason;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.CameraManager;
import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementManager;
import com.hypixel.hytale.server.core.entity.movement.MovementStatesComponent;
import com.hypixel.hytale.server.core.io.PacketHandler;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
com.hypixel.hytale.server.core.plugin.PluginBase;
com.hypixel.hytale.server.core.universe.PlayerRef;
com.hypixel.hytale.server.core.universe.Universe;
com.hypixel.hytale.server.core.universe.world.World;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.universe.world.storage.provider.IndexedStorageChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenTimingsCollector;
com.hypixel.hytale.storage.IndexedStorageFile;
io.netty.buffer.ByteBuf;
io.netty.buffer.ByteBufUtil;
it.unimi.dsi.fastutil.longs.Long2ObjectMap;
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
java.io.BufferedWriter;
java.io.FileOutputStream;
java.io.IOException;
java.io.OutputStream;
java.io.OutputStreamWriter;
java.io.PrintWriter;
java.lang.management.ClassLoadingMXBean;
java.lang.management.GarbageCollectorMXBean;
java.lang.management.ManagementFactory;
java.lang.management.MemoryMXBean;
java.lang.management.MemoryPoolMXBean;
java.lang.management.MemoryUsage;
java.lang.management.OperatingSystemMXBean;
java.lang.management.RuntimeMXBean;
java.lang.management.ThreadInfo;
java.lang.management.ThreadMXBean;
java.nio.charset.StandardCharsets;
java.nio.file.Files;
java.nio.file.LinkOption;
java.nio.file.Path;
java.nio.file.Paths;
java.time.LocalDateTime;
java.util.Arrays;
java.util.Collection;
java.util.Date;
java.util.List;
java.util.Map;
java.util.UUID;
java.util.concurrent.CompletableFuture;
java.util.concurrent.CompletionException;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.TimeUnit;
java.util.concurrent.TimeoutException;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bouncycastle.util.io.TeeOutputStream;
org.bson.BsonArray;
org.bson.BsonDocument;
org.bson.BsonString;
org.bson.BsonValue;
{
{
}
Path IOException {
Map<UUID, BsonDocument> playerComponents = collectPlayerComponentMetrics();
HytaleServer.METRICS_REGISTRY.dumpToBson(HytaleServer.get()).asDocument();
Universe.METRICS_REGISTRY.dumpToBson(Universe.get()).asDocument();
();
(PlayerRef ref : Universe.get().getPlayers()) {
PlayerRef.METRICS_REGISTRY.dumpToBson(ref).asDocument();
(BsonDocument)playerComponents.get(ref.getUuid());
(componentData != ) {
playerBson.putAll(componentData);
}
playersArray.add((BsonValue)playerBson);
}
universeBson.put((String) , (BsonValue)playersArray);
bson.put((String) , (BsonValue)universeBson);
();
(ClassTransformer transformer : EarlyPluginLoader.getTransformers()) {
earlyPluginsArray.add((BsonValue)( (transformer.getClass().getName())));
}
bson.put((String) , (BsonValue)earlyPluginsArray);
MetricsRegistry.createDumpPath( );
Files.writeString(path, BsonUtil.toJson(bson));
path;
}
Map<UUID, BsonDocument> {
ConcurrentHashMap<UUID, BsonDocument> result = ();
Collection<World> worlds = Universe.get().getWorlds().values();
CompletableFuture[] futures = (CompletableFuture[])worlds.stream().map((world) -> CompletableFuture.runAsync(() -> {
(PlayerRef playerRef : world.getPlayerRefs()) {
PlayerRef.COMPONENT_METRICS_REGISTRY.dumpToBson(playerRef);
result.put(playerRef.getUuid(), bson.asDocument());
}
}, world).orTimeout( , TimeUnit.SECONDS)).toArray((x$ ) -> [x$ ]);
CompletableFuture.allOf(futures).join();
result;
}
Map<UUID, PlayerTextData> {
ConcurrentHashMap<UUID, PlayerTextData> result = ();
Collection<World> worlds = Universe.get().getWorlds().values();
CompletableFuture[] futures = (CompletableFuture[])worlds.stream().map((world) -> CompletableFuture.runAsync(() -> {
(PlayerRef playerRef : world.getPlayerRefs()) {
Ref<EntityStore> entityRef = playerRef.getReference();
(entityRef != ) {
Store<EntityStore> store = entityRef.getStore();
(MovementStatesComponent)store.getComponent(entityRef, MovementStatesComponent.getComponentType());
(MovementManager)store.getComponent(entityRef, MovementManager.getComponentType());
(CameraManager)store.getComponent(entityRef, CameraManager.getComponentType());
result.put(playerRef.getUuid(), (playerRef.getUuid(), ms != ? ms.getMovementStates().toString() : , mm != ? mm.toString() : , cm != ? cm.toString() : ));
}
}
}, world).orTimeout( , TimeUnit.SECONDS)).toArray((x$ ) -> [x$ ]);
CompletableFuture.allOf(futures).join();
result;
}
String {
buf.readerIndex();
[] data = [buf.readableBytes()];
buf.readBytes(data);
buf.readerIndex(readerIndex);
hexDump(data);
}
String {
data.length == ? : ByteBufUtil.hexDump(data);
}
Path {
createDumpPath(crash, );
;
OutputStream outputStream;
{
fileOutputStream = (filePath.toFile());
(printToConsole) {
outputStream = (fileOutputStream, System.err);
} {
outputStream = fileOutputStream;
}
} (IOException e) {
e.printStackTrace();
System.err.println();
System.err.println( + String.valueOf(filePath));
System.err.println( + String.valueOf(filePath));
System.err.println();
outputStream = System.err;
}
{
write( ( ( (outputStream, StandardCharsets.UTF_8)), ));
} {
(fileOutputStream != ) {
{
fileOutputStream.close();
} (IOException var12) {
}
}
}
filePath;
}
Path {
Paths.get( );
{
(!Files.exists(path, [ ])) {
Files.createDirectories(path);
}
} (IOException e) {
e.printStackTrace();
}
(crash ? : ) + HytaleFileHandler.LOG_FILE_DATE_FORMAT.format(LocalDateTime.now());
path.resolve(name + + ext);
( ; Files.exists(filePath, [ ]); filePath = path.resolve(name + + i++ + + ext)) {
}
filePath;
}
{
;
;
System.nanoTime();
section( , () -> {
Universe.get();
writer.println( + universe.getWorlds().size());
(World world : universe.getWorlds().values()) {
writer.println( + world.getName());
world.getBufferedTickLengthMetricSet();
[] periodsNanos = metrics.getPeriodsNanos();
periodsNanos.length - ;
periodsNanos[periodIndex];
metrics.getAverage(periodIndex);
metrics.calculateMax(periodIndex);
metrics.calculateMin(periodIndex);
FormatUtil.timeUnitToString(lastTime, TimeUnit.NANOSECONDS, );
FormatUtil.simpleTimeUnitFormat(min, average, max, TimeUnit.NANOSECONDS, TimeUnit.MILLISECONDS, );
FormatUtil.simpleTimeUnitFormat(( )world.getTickStepNanos(), TimeUnit.NANOSECONDS, );
writer.printf( , length, value, limit);
writer.printf( , world.getPlayerCount());
}
writer.println( + universe.getPlayerCount());
(PlayerRef ref : universe.getPlayers()) {
writer.printf( , ref.getUsername(), ref.getUuid());
PacketHandler. ref.getPacketHandler().getPingInfo(PongType.Raw);
pingInfo.getPingMetricSet();
pingMetricSet.calculateMin( );
( )pingMetricSet.getAverage( );
pingMetricSet.calculateMax( );
FormatUtil.timeUnitToString(min, PacketHandler.PingInfo.TIME_UNIT);
writer.println( + var10001 + + FormatUtil.timeUnitToString(average, PacketHandler.PingInfo.TIME_UNIT) + + FormatUtil.timeUnitToString(max, PacketHandler.PingInfo.TIME_UNIT));
}
}, writer);
section( , () -> {
HytaleServer.get();
writer.println( + String.valueOf(server.getBoot()));
writer.println( + server.getBootStart());
writer.println( + server.isBooting());
writer.println( + server.isBooted());
writer.println( + server.isShuttingDown());
server.getShutdownReason();
(shutdownReason != ) {
writer.println( + String.valueOf(shutdownReason));
}
}, writer);
section( , () -> {
List<ClassTransformer> transformers = EarlyPluginLoader.getTransformers();
writer.println( + transformers.size());
(ClassTransformer transformer : transformers) {
transformer.getClass().getName();
writer.println( + var10001 + + transformer.priority() + );
}
}, writer);
section( , () -> {
List<PluginBase> plugins = HytaleServer.get().getPluginManager().getPlugins();
writer.println( + plugins.size());
(PluginBase plugin : plugins) {
var10000;
label22: {
(plugin JavaPlugin javaPlugin) {
(javaPlugin.getClassLoader().isInServerClassPath()) {
var10000 = ;
label22;
}
}
var10000 = ;
}
var10000;
String.valueOf(plugin.getIdentifier());
writer.println( + var10001 + (isBuiltin ? : ));
writer.println( + plugin.getType().getDisplayName());
writer.println( + String.valueOf(plugin.getState()));
writer.println( );
PluginManifest.CODEC.encode(plugin.getManifest()).asDocument();
printIndented(writer, BsonUtil.toJson(manifestBson), );
}
}, writer);
section( , () -> {
HytaleServer.get().getConfig();
HytaleServerConfig.CODEC.encode(config).asDocument();
printIndented(writer, BsonUtil.toJson(bson), );
}, writer);
Map<UUID, PlayerTextData> playerTextData = collectPlayerTextData();
section( , () -> {
writer.println( );
writer.println( + String.valueOf(HytaleServer.get()));
writer.println( + HytaleServer.get().isBooting());
writer.println( + HytaleServer.get().isShuttingDown());
writer.println();
writer.println( );
Map<String, World> worlds = Universe.get().getWorlds();
worlds.forEach((worldName, world) -> {
writer.println( + worldName + );
writer.println( + String.valueOf(world));
world.getBufferedTickLengthMetricSet();
[] periods = bufferedDeltaMetricSet.getPeriodsNanos();
( ; i < periods.length; ++i) {
periods[i];
FormatUtil.timeUnitToString(period, TimeUnit.NANOSECONDS, );
bufferedDeltaMetricSet.getAverage(i);
bufferedDeltaMetricSet.calculateMin(i);
bufferedDeltaMetricSet.calculateMax(i);
writer.println( + historyLengthFormatted + + FormatUtil.simpleTimeUnitFormat(min, TimeUnit.NANOSECONDS, ) + + FormatUtil.simpleTimeUnitFormat(Math.round(average), TimeUnit.NANOSECONDS, ) + + FormatUtil.simpleTimeUnitFormat(max, TimeUnit.NANOSECONDS, ));
[] historyTimestamps = bufferedDeltaMetricSet.getTimestamps(i);
[] historyValues = bufferedDeltaMetricSet.getValues(i);
();
sb.append( ).append(historyLengthFormatted).append( );
StringUtil.generateGraph(sb, width, height, startNanos - period, startNanos, , ( )Math.max(max, ( )world.getTickStepNanos()), (value) -> FormatUtil.simpleTimeUnitFormat(MathUtil.fastCeil(value), TimeUnit.NANOSECONDS, ), historyTimestamps.length, (ii) -> historyTimestamps[ii], (ii) -> ( )historyValues[ii]);
writer.println(sb);
}
writer.println( );
(Player player : world.getPlayers()) {
writer.println( + String.valueOf(player));
(PlayerTextData)playerTextData.get(player.getUuid());
playerData != ? playerData.movementStates() : ;
writer.println( + var10001);
var10001 = playerData != ? playerData.movementManager() : ;
writer.println( + var10001);
writer.println( + String.valueOf(player.getPageManager()));
writer.println( + String.valueOf(player.getHudManager()));
var10001 = playerData != ? playerData.cameraManager() : ;
writer.println( + var10001);
writer.println( );
(String line : player.getPlayerRef().getChunkTracker().getLoadedChunksDebug().split( )) {
writer.println( + line);
}
writer.println( + player.getPlayerConnection().getQueuedPacketsCount());
writer.println( );
(PongType pongType : PongType.values()) {
PacketHandler. player.getPlayerConnection().getPingInfo(pongType);
writer.println( + pongType.name() + );
pingInfo.getPingMetricSet();
( )pingMetricSet.getAverage( );
pingMetricSet.calculateMin( );
pingMetricSet.calculateMax( );
writer.println( + min + + average + + max);
var10001 = FormatUtil.timeUnitToString(min, PacketHandler.PingInfo.TIME_UNIT);
writer.println( + var10001 + + FormatUtil.timeUnitToString(average, PacketHandler.PingInfo.TIME_UNIT) + + FormatUtil.timeUnitToString(max, PacketHandler.PingInfo.TIME_UNIT));
[] pingPeriods = pingMetricSet.getPeriodsNanos();
( ; i < pingPeriods.length; ++i) {
min = pingPeriods[i];
max = pingMetricSet.calculateMin( );
pingMetricSet.calculateMax( );
[] historyTimestamps = pingMetricSet.getTimestamps(i);
[] historyValues = pingMetricSet.getValues(i);
FormatUtil.timeUnitToString(min, TimeUnit.NANOSECONDS, );
();
sb.append( ).append(historyLengthFormatted).append( );
StringUtil.generateGraph(sb, width, height, startNanos - min, startNanos, ( )max, ( )max, (value) -> FormatUtil.timeUnitToString(MathUtil.fastCeil(value), PacketHandler.PingInfo.TIME_UNIT), historyTimestamps.length, (ii) -> historyTimestamps[ii], (ii) -> ( )historyValues[ii]);
writer.println(sb);
}
pingInfo.getPacketQueueMetric().getMin();
writer.println( + var81 + + ( )pingInfo.getPacketQueueMetric().getAverage() + + pingInfo.getPacketQueueMetric().getMax());
}
writer.println();
player.getPlayerConnection().getPacketStatsRecorder();
(recorder != ) {
;
;
;
;
;
;
;
writer.println( );
( ; i < ; ++i) {
PacketStatsRecorder. recorder.getEntry(i);
(entry.getSentCount() > ) {
totalSentCount += ( )entry.getSentCount();
totalSentUncompressed += entry.getSentUncompressedTotal();
totalSentWire += entry.getSentCompressedTotal() > ? entry.getSentCompressedTotal() : entry.getSentUncompressedTotal();
var10001 = entry.getName();
writer.println( + var10001 + + i + );
printPacketStats(writer, , , entry.getSentCount(), entry.getSentUncompressedTotal(), entry.getSentCompressedTotal(), entry.getSentUncompressedMin(), entry.getSentUncompressedMax(), entry.getSentCompressedMin(), entry.getSentCompressedMax(), entry.getSentUncompressedAvg(), entry.getSentCompressedAvg(), );
PacketStatsRecorder. entry.getSentRecently();
(recent.count() > ) {
recentSentCount += recent.count();
recentSentUncompressed += recent.uncompressedTotal();
recentSentWire += recent.compressedTotal() > ? recent.compressedTotal() : recent.uncompressedTotal();
printPacketStats(writer, , , recent.count(), recent.uncompressedTotal(), recent.compressedTotal(), ( )recent.uncompressedMin(), ( )recent.uncompressedMax(), ( )recent.compressedMin(), ( )recent.compressedMax(), ( )recent.uncompressedTotal() / ( )recent.count(), recent.compressedTotal() > ? ( )recent.compressedTotal() / ( )recent.count() : , recentSeconds);
}
}
}
writer.println( );
writer.println( + totalSentCount + + FormatUtil.bytesToString(totalSentUncompressed) + + FormatUtil.bytesToString(totalSentWire) + );
(recentSentCount > ) {
writer.println(String.format( , recentSentCount, ( )recentSentCount / ( )recentSeconds, FormatUtil.bytesToString(recentSentUncompressed), FormatUtil.bytesToString(recentSentWire)));
}
writer.println();
;
;
;
;
;
;
writer.println( );
( ; i < ; ++i) {
PacketStatsRecorder. recorder.getEntry(i);
(entry.getReceivedCount() > ) {
totalRecvCount += ( )entry.getReceivedCount();
totalRecvUncompressed += entry.getReceivedUncompressedTotal();
totalRecvWire += entry.getReceivedCompressedTotal() > ? entry.getReceivedCompressedTotal() : entry.getReceivedUncompressedTotal();
var10001 = entry.getName();
writer.println( + var10001 + + i + );
printPacketStats(writer, , , entry.getReceivedCount(), entry.getReceivedUncompressedTotal(), entry.getReceivedCompressedTotal(), entry.getReceivedUncompressedMin(), entry.getReceivedUncompressedMax(), entry.getReceivedCompressedMin(), entry.getReceivedCompressedMax(), entry.getReceivedUncompressedAvg(), entry.getReceivedCompressedAvg(), );
PacketStatsRecorder. entry.getReceivedRecently();
(recent.count() > ) {
recentRecvCount += recent.count();
recentRecvUncompressed += recent.uncompressedTotal();
recentRecvWire += recent.compressedTotal() > ? recent.compressedTotal() : recent.uncompressedTotal();
printPacketStats(writer, , , recent.count(), recent.uncompressedTotal(), recent.compressedTotal(), ( )recent.uncompressedMin(), ( )recent.uncompressedMax(), ( )recent.compressedMin(), ( )recent.compressedMax(), ( )recent.uncompressedTotal() / ( )recent.count(), recent.compressedTotal() > ? ( )recent.compressedTotal() / ( )recent.count() : , recentSeconds);
}
}
}
writer.println( );
writer.println( + totalRecvCount + + FormatUtil.bytesToString(totalRecvUncompressed) + + FormatUtil.bytesToString(totalRecvWire) + );
(recentRecvCount > ) {
writer.println(String.format( , recentRecvCount, ( )recentRecvCount / ( )recentSeconds, FormatUtil.bytesToString(recentRecvUncompressed), FormatUtil.bytesToString(recentRecvWire)));
}
writer.println();
}
}
writer.println( );
{
CompletableFuture.runAsync(() -> {
printComponentStore(writer, width, height, , startNanos, world.getChunkStore().getStore());
printComponentStore(writer, width, height, , startNanos, world.getEntityStore().getStore());
}, world).orTimeout( , TimeUnit.SECONDS).join();
} (CompletionException e) {
(!(e.getCause() TimeoutException)) {
e.printStackTrace();
writer.println( );
} {
writer.println( );
}
}
writer.println();
writer.println();
world.getChunkStore().getGenerator().getTimings();
writer.println( );
(timings != ) {
writer.println( + timings.getChunkCounter());
writer.println( + timings.getChunkTime());
writer.println( + timings.zoneBiomeResult());
writer.println( + timings.prepare());
writer.println( + timings.blocksGeneration());
writer.println( + timings.caveGeneration());
writer.println( + timings.prefabGeneration());
writer.println( + timings.getQueueLength());
writer.println( + timings.getGeneratingCount());
} {
writer.println( );
}
IndexedStorageChunkStorageProvider. (IndexedStorageChunkStorageProvider.IndexedStorageCache)world.getChunkStore().getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType());
(storageCache != ) {
Long2ObjectConcurrentHashMap<IndexedStorageFile> cache = storageCache.getCache();
writer.println();
writer.println( );
(Long2ObjectMap.Entry<IndexedStorageFile> entry : cache.long2ObjectEntrySet()) {
entry.getLongKey();
ChunkUtil.xOfChunkIndex(key);
writer.println( + var84 + + ChunkUtil.zOfChunkIndex(key));
(IndexedStorageFile)entry.getValue();
{
writer.println( + FormatUtil.bytesToString(storageFile.size()));
} (IOException e) {
writer.println( + e.getMessage());
}
writer.println( + storageFile.keys().size());
storageFile.segmentSize();
storageFile.segmentCount();
writer.println( + segmentSize);
writer.println( + segmentCount);
writer.println( + ( )(segmentCount * ) / ( )segmentSize + );
writer.println( + String.valueOf(storageFile));
}
}
});
List<PlayerRef> playersNotInWorld = Universe.get().getPlayers().stream().filter((refx) -> refx.getReference() == ).toList();
(!playersNotInWorld.isEmpty()) {
writer.println();
writer.println( + playersNotInWorld.size() + );
(PlayerRef ref : playersNotInWorld) {
ref.getUsername();
writer.println( + var10001 + + String.valueOf(ref.getUuid()) + );
writer.println( + ref.getPacketHandler().getQueuedPacketsCount());
PacketHandler. ref.getPacketHandler().getPingInfo(PongType.Raw);
pingInfo.getPingMetricSet();
pingMetricSet.calculateMin( );
( )pingMetricSet.getAverage( );
pingMetricSet.calculateMax( );
var10001 = FormatUtil.timeUnitToString(min, PacketHandler.PingInfo.TIME_UNIT);
writer.println( + var10001 + + FormatUtil.timeUnitToString(avg, PacketHandler.PingInfo.TIME_UNIT) + + FormatUtil.timeUnitToString(max, PacketHandler.PingInfo.TIME_UNIT));
}
}
}, writer);
section( , () -> {
ManagementFactory.getRuntimeMXBean();
ManagementFactory.getOperatingSystemMXBean();
System.currentTimeMillis();
String.valueOf( (runtimeMXBean.getStartTime()));
writer.println( + var10001 + + runtimeMXBean.getStartTime() + );
var10001 = String.valueOf( (currentTimeMillis));
writer.println( + var10001 + + currentTimeMillis + );
var10001 = FormatUtil.timeUnitToString(runtimeMXBean.getUptime(), TimeUnit.MILLISECONDS);
writer.println( + var10001 + + runtimeMXBean.getUptime() + );
Runtime.getRuntime().availableProcessors();
writer.println( + var9 + + operatingSystemMXBean.getAvailableProcessors());
writer.println( + operatingSystemMXBean.getSystemLoadAverage());
writer.println();
(operatingSystemMXBean com.sun.management.OperatingSystemMXBean sunOSBean) {
FormatUtil.bytesToString(sunOSBean.getTotalPhysicalMemorySize());
writer.println( + var10 + + sunOSBean.getTotalPhysicalMemorySize() + );
var10 = FormatUtil.bytesToString(sunOSBean.getFreePhysicalMemorySize());
writer.println( + var10 + + sunOSBean.getFreePhysicalMemorySize() + );
var10 = FormatUtil.bytesToString(sunOSBean.getTotalSwapSpaceSize());
writer.println( + var10 + + sunOSBean.getTotalSwapSpaceSize() + );
var10 = FormatUtil.bytesToString(sunOSBean.getFreeSwapSpaceSize());
writer.println( + var10 + + sunOSBean.getFreeSwapSpaceSize() + );
writer.println( + sunOSBean.getSystemCpuLoad());
writer.println( + sunOSBean.getProcessCpuLoad());
writer.println();
}
writer.println( + System.getenv( ));
writer.println( + System.getenv( ));
writer.println( + System.getenv( ));
writer.println( + System.getenv( ));
writer.println();
writer.println( + runtimeMXBean.getName());
writer.println();
writer.println( + operatingSystemMXBean.getName());
writer.println( + operatingSystemMXBean.getArch());
writer.println( + operatingSystemMXBean.getVersion());
writer.println();
writer.println( + runtimeMXBean.getSpecName());
writer.println( + runtimeMXBean.getSpecVendor());
writer.println( + runtimeMXBean.getSpecVersion());
writer.println();
writer.println( + runtimeMXBean.getVmName());
writer.println( + runtimeMXBean.getVmVendor());
writer.println( + runtimeMXBean.getVmVersion());
writer.println();
writer.println( + runtimeMXBean.getManagementSpecVersion());
writer.println();
writer.println( + runtimeMXBean.getLibraryPath());
{
writer.println( + runtimeMXBean.getBootClassPath());
} (UnsupportedOperationException var6) {
}
writer.println( + runtimeMXBean.getClassPath());
writer.println();
writer.println( + String.valueOf(runtimeMXBean.getInputArguments()));
writer.println( + String.valueOf(runtimeMXBean.getSystemProperties()));
}, writer);
section( , () -> {
ManagementFactory.getMemoryMXBean();
writeMemoryUsage(writer, , memoryMXBean.getHeapMemoryUsage());
writeMemoryUsage(writer, , memoryMXBean.getNonHeapMemoryUsage());
writer.println( + memoryMXBean.getObjectPendingFinalizationCount());
}, writer);
section( , () -> {
(GarbageCollectorMXBean garbageCollectorMXBean : ManagementFactory.getGarbageCollectorMXBeans()) {
writer.println( + garbageCollectorMXBean.getName());
writer.println( + Arrays.toString(garbageCollectorMXBean.getMemoryPoolNames()));
writer.println( + garbageCollectorMXBean.getCollectionCount());
writer.println( + garbageCollectorMXBean.getCollectionTime());
writer.println();
}
}, writer);
section( , () -> {
(MemoryPoolMXBean memoryPoolMXBean : ManagementFactory.getMemoryPoolMXBeans()) {
writer.println( + memoryPoolMXBean.getName());
writer.println( + String.valueOf(memoryPoolMXBean.getType()));
writer.println( + String.valueOf(memoryPoolMXBean.getPeakUsage()));
writer.println( + String.valueOf(memoryPoolMXBean.getUsage()));
writer.println( + memoryPoolMXBean.isUsageThresholdSupported());
(memoryPoolMXBean.isUsageThresholdSupported()) {
writer.println( + memoryPoolMXBean.getUsageThreshold());
writer.println( + memoryPoolMXBean.getUsageThresholdCount());
writer.println( + memoryPoolMXBean.isUsageThresholdExceeded());
}
writer.println( + String.valueOf(memoryPoolMXBean.getCollectionUsage()));
writer.println( + memoryPoolMXBean.isCollectionUsageThresholdSupported());
(memoryPoolMXBean.isCollectionUsageThresholdSupported()) {
writer.println( + memoryPoolMXBean.getCollectionUsageThreshold());
writer.println( + memoryPoolMXBean.getCollectionUsageThresholdCount());
writer.println( + memoryPoolMXBean.isCollectionUsageThresholdExceeded());
}
writer.println();
}
}, writer);
ManagementFactory.getThreadMXBean();
ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads( , );
section( + threadInfos.length + , () -> {
Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
Long2ObjectMap<Thread> threadIdMap = <Thread>();
(Thread thread : allStackTraces.keySet()) {
threadIdMap.put(thread.getId(), thread);
}
(ThreadInfo threadInfo : threadInfos) {
(Thread)threadIdMap.get(threadInfo.getThreadId());
(thread == ) {
writer.println( );
} {
writer.println( + thread.getName());
writer.println( + String.valueOf(threadInfo.getThreadState()));
writer.println( + String.valueOf(thread.getClass()));
writer.println( + String.valueOf(thread.getThreadGroup()));
writer.println( + thread.getPriority());
threadMXBean.getThreadCpuTime(threadInfo.getThreadId());
writer.println( + var10001);
writer.println( + threadInfo.getWaitedTime());
writer.println( + threadInfo.getWaitedCount());
writer.println( + threadInfo.getBlockedTime());
writer.println( + threadInfo.getBlockedCount());
writer.println( + threadInfo.getLockName());
writer.println( + threadInfo.getLockOwnerId());
writer.println( + threadInfo.getLockOwnerName());
writer.println( + thread.isDaemon());
writer.println( + thread.isInterrupted());
writer.println( + String.valueOf(thread.getUncaughtExceptionHandler().getClass()));
(thread InitStackThread) {
writer.println( );
StackTraceElement[] trace = ((InitStackThread)thread).getInitStack();
(StackTraceElement traceElement : trace) {
writer.println( + String.valueOf(traceElement));
}
}
writer.println( );
StackTraceElement[] trace = (StackTraceElement[])allStackTraces.get(thread);
(StackTraceElement traceElement : trace) {
writer.println( + String.valueOf(traceElement));
}
}
writer.println(threadInfo);
}
}, writer);
section( , () -> {
System.getSecurityManager();
(securityManager != ) {
writer.println( + securityManager.getClass().getName());
} {
writer.println( );
}
}, writer);
section( , () -> {
ManagementFactory.getClassLoadingMXBean();
writer.println( + classLoadingMXBean.getLoadedClassCount());
writer.println( + classLoadingMXBean.getUnloadedClassCount());
writer.println( + classLoadingMXBean.getTotalLoadedClassCount());
}, writer);
section( , () -> {
ClassLoader.getSystemClassLoader();
writeClassLoader(writer, systemClassLoader);
}, writer);
section( , () -> {
DumpUtil.class.getClassLoader();
writeClassLoader(writer, systemClassLoader);
}, writer);
}
{
();
sb.append(label).append( ).append(count).append( ).append(count != ? : );
(recentSeconds > ) {
sb.append(String.format( , ( )count / ( )recentSeconds));
}
sb.append( ).append(indent).append( ).append(FormatUtil.bytesToString(uncompressedTotal));
(compressedTotal > ) {
sb.append( ).append(FormatUtil.bytesToString(compressedTotal)).append( );
* ( )compressedTotal / ( )uncompressedTotal;
sb.append(String.format( , ratio));
}
sb.append( ).append(indent).append( ).append(FormatUtil.bytesToString(( )uncompressedAvg));
(compressedAvg > ) {
sb.append( ).append(FormatUtil.bytesToString(( )compressedAvg)).append( );
}
sb.append( ).append(indent).append( ).append(FormatUtil.bytesToString(uncompressedMin)).append( ).append(FormatUtil.bytesToString(uncompressedMax));
(compressedMax > ) {
sb.append( ).append(FormatUtil.bytesToString(compressedMin)).append( ).append(FormatUtil.bytesToString(compressedMax)).append( );
}
writer.println(indent + String.valueOf(sb));
}
{
writer.println( + name + );
writer.println( + componentStore.getArchetypeChunkCount());
writer.println( + componentStore.getEntityCount());
ComponentRegistry.Data<?> data = componentStore.getRegistry().getData();
HistoricMetric[] systemMetrics = componentStore.getSystemMetrics();
( ; systemIndex < data.getSystemSize(); ++systemIndex) {
ISystem<?> system = data.getSystem(systemIndex);
systemMetrics[systemIndex];
writer.println( + system.getClass().getName());
writer.println( + String.valueOf(system));
componentStore.getArchetypeChunkCountFor(systemIndex);
writer.println( + var10001);
var10001 = componentStore.getEntityCountFor(systemIndex);
writer.println( + var10001);
(systemMetric != ) {
[] periods = systemMetric.getPeriodsNanos();
( ; i < periods.length; ++i) {
periods[i];
FormatUtil.timeUnitToString(period, TimeUnit.NANOSECONDS, );
systemMetric.getAverage(i);
systemMetric.calculateMin(i);
systemMetric.calculateMax(i);
writer.println( + historyLengthFormatted + + FormatUtil.timeUnitToString(min, TimeUnit.NANOSECONDS) + + FormatUtil.timeUnitToString(( )average, TimeUnit.NANOSECONDS) + + FormatUtil.timeUnitToString(max, TimeUnit.NANOSECONDS));
[] historyTimestamps = systemMetric.getTimestamps(i);
[] historyValues = systemMetric.getValues(i);
();
StringUtil.generateGraph(sb, width, height, startNanos - period, startNanos, ( )min, ( )max, (value) -> FormatUtil.timeUnitToString(MathUtil.fastCeil(value), TimeUnit.NANOSECONDS), historyTimestamps.length, (ii) -> historyTimestamps[ii], (ii) -> ( )historyValues[ii]);
writer.println(sb);
}
}
}
writer.println( );
(ArchetypeChunkData chunkData : componentStore.collectArchetypeChunkData()) {
chunkData.getEntityCount();
writer.println( + var31 + + Arrays.toString(chunkData.getComponentTypes()));
}
}
{
writer.println( + name + );
{
runnable.run();
} (Throwable t) {
( ( + name, t)).printStackTrace(writer);
}
writer.println();
writer.println();
}
{
(String line : text.split( )) {
writer.println(indent + line);
}
}
{
writer.println(title);
FormatUtil.bytesToString(memoryUsage.getInit());
writer.println( + var10001 + + memoryUsage.getInit() + );
var10001 = FormatUtil.bytesToString(memoryUsage.getUsed());
writer.println( + var10001 + + memoryUsage.getUsed() + );
var10001 = FormatUtil.bytesToString(memoryUsage.getCommitted());
writer.println( + var10001 + + memoryUsage.getCommitted() + );
memoryUsage.getMax();
(max > ) {
var10001 = FormatUtil.bytesToString(max);
writer.println( + var10001 + + max + );
max - memoryUsage.getCommitted();
var10001 = FormatUtil.bytesToString(free);
writer.println( + var10001 + + free + );
}
}
{
(systemClassLoader != ) {
writer.println( + systemClassLoader.getClass().getName());
(systemClassLoader.getParent() != ) {
systemClassLoader = systemClassLoader.getParent();
writer.println( + systemClassLoader.getClass().getName());
}
} {
writer.println( );
}
}
{
}
}
com/hypixel/hytale/server/core/util/EventTitleUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.protocol.packets.interface_.HideEventTitle;
import com.hypixel.hytale.protocol.packets.interface_.ShowEventTitle;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class EventTitleUtil {
public static final String DEFAULT_ZONE = "Void" ;
public static final float DEFAULT_DURATION = 4.0F ;
public static final float DEFAULT_FADE_DURATION = 1.5F ;
public EventTitleUtil () {
}
public static void showEventTitleToUniverse (@Nonnull Message primaryTitle, Message secondaryTitle, isMajor, String icon, duration, fadeInDuration, fadeOutDuration) {
(World world : Universe.get().getWorlds().values()) {
world.execute(() -> {
Store<EntityStore> store = world.getEntityStore().getStore();
showEventTitleToWorld(primaryTitle, secondaryTitle, isMajor, icon, duration, fadeInDuration, fadeOutDuration, store);
});
}
}
{
((EntityStore)store.getExternalData()).getWorld();
(PlayerRef playerRef : world.getPlayerRefs()) {
showEventTitleToPlayer(playerRef, primaryTitle, secondaryTitle, isMajor, icon, duration, fadeInDuration, fadeOutDuration);
}
}
{
((EntityStore)store.getExternalData()).getWorld();
(PlayerRef playerRef : world.getPlayerRefs()) {
hideEventTitleFromPlayer(playerRef, fadeOutDuration);
}
}
{
playerRefComponent.getPacketHandler().writeNoCache( (fadeInDuration, fadeOutDuration, duration, icon, isMajor, primaryTitle.getFormattedMessage(), secondaryTitle.getFormattedMessage()));
}
{
showEventTitleToPlayer(playerRefComponent, primaryTitle, secondaryTitle, isMajor, (String) , , , );
}
{
playerRefComponent.getPacketHandler().writeNoCache( (fadeOutDuration));
}
}
com/hypixel/hytale/server/core/util/FillerBlockUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.function.consumer.TriIntConsumer;
import com.hypixel.hytale.function.predicate.TriIntPredicate;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import javax.annotation.Nonnull;
public class FillerBlockUtil {
public static final float THRESHOLD = 0.0F ;
public static final int NO_FILLER = 0 ;
private static final int BITS_PER_AXIS = 5 ;
private static final int MASK = 31 ;
private static final int INVERT = -32 ;
{
}
{
forEachFillerBlock( , blockBoundingBoxes, consumer);
}
{
(!(threshold < ) && !(threshold >= )) {
blockBoundingBoxes.getBoundingBox();
( )boundingBox.min.x;
( )boundingBox.min.y;
( )boundingBox.min.z;
(( )minX - boundingBox.min.x > ( )threshold) {
--minX;
}
(( )minY - boundingBox.min.y > ( )threshold) {
--minY;
}
(( )minZ - boundingBox.min.z > ( )threshold) {
--minZ;
}
( )boundingBox.max.x;
( )boundingBox.max.y;
( )boundingBox.max.z;
(boundingBox.max.x - ( )maxX > ( )threshold) {
++maxX;
}
(boundingBox.max.y - ( )maxY > ( )threshold) {
++maxY;
}
(boundingBox.max.z - ( )maxZ > ( )threshold) {
++maxZ;
}
Math.max(maxX - minX, );
Math.max(maxY - minY, );
Math.max(maxZ - minZ, );
( ; x < blockWidth; ++x) {
( ; y < blockHeight; ++y) {
( ; z < blockDepth; ++z) {
consumer.accept(minX + x, minY + y, minZ + z);
}
}
}
} {
( );
}
}
{
testFillerBlocks( , blockBoundingBoxes, predicate);
}
{
(!(threshold < ) && !(threshold >= )) {
blockBoundingBoxes.getBoundingBox();
( )boundingBox.min.x;
( )boundingBox.min.y;
( )boundingBox.min.z;
(( )minX - boundingBox.min.x > ( )threshold) {
--minX;
}
(( )minY - boundingBox.min.y > ( )threshold) {
--minY;
}
(( )minZ - boundingBox.min.z > ( )threshold) {
--minZ;
}
( )boundingBox.max.x;
( )boundingBox.max.y;
( )boundingBox.max.z;
(boundingBox.max.x - ( )maxX > ( )threshold) {
++maxX;
}
(boundingBox.max.y - ( )maxY > ( )threshold) {
++maxY;
}
(boundingBox.max.z - ( )maxZ > ( )threshold) {
++maxZ;
}
Math.max(maxX - minX, );
Math.max(maxY - minY, );
Math.max(maxZ - minZ, );
( ; x < blockWidth; ++x) {
( ; y < blockHeight; ++y) {
( ; z < blockDepth; ++z) {
(!predicate.test(minX + x, minY + y, minZ + z)) {
;
}
}
}
}
;
} {
( );
}
}
<A, B> ValidationResult {
(blockId == ) {
FillerBlockUtil.ValidationResult.OK;
} {
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
blockTypeAssetMap.getAsset(blockId);
(blockType == ) {
FillerBlockUtil.ValidationResult.OK;
} {
blockType.getId();
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitboxAssetMap = BlockBoundingBoxes.getAssetMap();
(filler != ) {
unpackX(filler);
unpackY(filler);
unpackZ(filler);
fetcher.getBlock(a, b, x - fillerX, y - fillerY, z - fillerZ);
blockTypeAssetMap.getAsset(baseBlockId);
(baseBlock == ) {
FillerBlockUtil.ValidationResult.INVALID_BLOCK;
} {
baseBlock.getId();
hitboxAssetMap.getAsset(baseBlock.getHitboxTypeIndex());
(hitbox == ) {
FillerBlockUtil.ValidationResult.OK;
} {
fetcher.getFiller(a, b, x - fillerX, y - fillerY, z - fillerZ);
fetcher.getRotationIndex(a, b, x - fillerX, y - fillerY, z - fillerZ);
baseFiller == && baseRotation == rotation && id.equals(baseId) && hitbox.get(baseRotation).getBoundingBox().containsBlock(fillerX, fillerY, fillerZ) ? FillerBlockUtil.ValidationResult.OK : FillerBlockUtil.ValidationResult.INVALID_BLOCK;
}
}
} {
hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex());
(hitbox != && hitbox.protrudesUnitBox()) {
testFillerBlocks(hitbox.get(rotation), (x1, y1, z1) -> {
(x1 == && y1 == && z1 == ) {
;
} {
x + x1;
y + y1;
z + z1;
fetcher.getBlock(a, b, worldX, worldY, worldZ);
blockTypeAssetMap.getAsset(fillerBlockId);
pack(x1, y1, z1);
(fetcher.getFiller(a, b, worldX, worldY, worldZ) != expectedFiller) {
;
} (fetcher.getRotationIndex(a, b, worldX, worldY, worldZ) != rotation) {
;
} (fillerBlock == ) {
;
} {
fillerBlock.getId();
blockTypeKey.equals(id);
}
}
});
result ? FillerBlockUtil.ValidationResult.OK : FillerBlockUtil.ValidationResult.INVALID_FILLER;
} {
FillerBlockUtil.ValidationResult.OK;
}
}
}
}
}
{
x & | (z & ) << | (y & ) << ;
}
{
val & ;
((result & ) != ) {
result |= - ;
}
result;
}
{
val >> & ;
((result & ) != ) {
result |= - ;
}
result;
}
{
val >> & ;
((result & ) != ) {
result |= - ;
}
result;
}
{
OK,
INVALID_BLOCK,
INVALID_FILLER;
{
}
}
<A, B> {
;
;
;
}
}
com/hypixel/hytale/server/core/util/HashUtil.java
package com.hypixel.hytale.server.core.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.annotation.Nonnull;
import org.bouncycastle.util.encoders.Hex;
public class HashUtil {
public HashUtil () {
}
@Nonnull
public static String sha256 (byte [] bytes) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256" );
messageDigest.update(bytes);
return Hex.toHexString(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException (e);
}
}
}
com/hypixel/hytale/server/core/util/MessageUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.protocol.BoolParamValue;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.protocol.DoubleParamValue;
import com.hypixel.hytale.protocol.FormattedMessage;
import com.hypixel.hytale.protocol.IntParamValue;
import com.hypixel.hytale.protocol.LongParamValue;
import com.hypixel.hytale.protocol.ParamValue;
import com.hypixel.hytale.protocol.StringParamValue;
import com.hypixel.hytale.protocol.packets.asseteditor.FailureReply;
import com.hypixel.hytale.protocol.packets.asseteditor.SuccessReply;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
import com.hypixel.hytale.server.core.modules.i18n.I18nModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import org.jline.utils.Colors;
public class MessageUtil {
public MessageUtil () {
}
public static AttributedString toAnsiString (@Nonnull Message message) {
AttributedStyle style AttributedStyle.DEFAULT;
message.getColor();
(color != ) {
style = hexToStyle(color);
}
();
sb.style(style).append((CharSequence)message.getAnsiMessage());
(Message child : message.getChildren()) {
sb.append(toAnsiString(child));
}
sb.toAttributedString();
}
AttributedStyle {
ColorParseUtil.parseColor(str);
(color == ) {
AttributedStyle.DEFAULT;
} {
Colors.roundRgbColor(color.red & , color.green & , color.blue & , );
AttributedStyle.DEFAULT.foreground(colorId);
}
}
{
sendSuccessReply(playerRef, token, (Message) );
}
{
message != ? message.getFormattedMessage() : ;
playerRef.getPacketHandler().writeNoCache( (token, msg));
}
{
message != ? message.getFormattedMessage() : ;
playerRef.getPacketHandler().writeNoCache( (token, msg));
}
String {
(text == ) {
( );
} (params == && messageParams == ) {
text;
} {
text.length();
(text.length());
;
( ; i < len; ++i) {
text.charAt(i);
(ch == ) {
(i + < len && text.charAt(i + ) == ) {
(i > lastWritePos) {
sb.append(text, lastWritePos, i);
}
sb.append( );
++i;
lastWritePos = i + ;
} {
findMatchingBrace(text, i);
(end >= ) {
(i > lastWritePos) {
sb.append(text, lastWritePos, i);
}
i + ;
text.indexOf( , contentStart, end);
c1 >= ? text.indexOf( , c1 + , end) : - ;
c1 >= && c1 < end ? c1 : end;
trimStart(text, contentStart, nameEndExclusive - );
trimEnd(text, ns, nameEndExclusive - );
nl > ? text.substring(ns, ns + nl) : ;
;
(c1 >= && c1 < end) {
c1 + ;
c2 >= ? c2 : end;
trimStart(text, formatStart, formatEndExclusive - );
trimEnd(text, fs, formatEndExclusive - );
(fl > ) {
format = text.substring(fs, fs + fl);
}
}
;
(c2 >= && c2 < end) {
c2 + ;
trimStart(text, optionsStart, end - );
trimEnd(text, os, end - );
(ol > ) {
options = text.substring(os, os + ol);
}
}
params != ? (ParamValue)params.get(key) : ;
messageParams != ? (FormattedMessage)messageParams.get(key) : ;
(replacementMessage != ) {
(replacementMessage.rawText != ) {
sb.append(replacementMessage.rawText);
} (replacementMessage.messageId != ) {
I18nModule.get().getMessage( , replacementMessage.messageId);
(message != ) {
sb.append(formatText(message, replacementMessage.params, replacementMessage.messageParams));
} {
sb.append(replacementMessage.messageId);
}
}
} (replacement == ) {
sb.append(text, i, end);
} {
String formattedReplacement;
formattedReplacement = ;
;
label185:
(format.typeSwitch<invokedynamic>(format, var23)) {
- :
:
;
:
(replacement StringParamValue) {
(StringParamValue)replacement;
formattedReplacement = s.value.toUpperCase();
}
;
:
(replacement StringParamValue) {
(StringParamValue)replacement;
formattedReplacement = s.value.toLowerCase();
}
;
:
;
(options.typeSwitch<invokedynamic>(options, var45)) {
- :
:
:
Objects.requireNonNull(replacement);
;
String var63;
(replacement.typeSwitch<invokedynamic>(replacement, var49)) {
:
(StringParamValue)replacement;
var63 = s.value;
;
:
(BoolParamValue)replacement;
var63 = b.value ? : ;
;
:
(DoubleParamValue)replacement;
var63 = Double.toString(( )(( )d.value));
;
:
(IntParamValue)replacement;
var63 = Integer.toString(iv.value);
;
:
(LongParamValue)replacement;
var63 = Long.toString(l.value);
;
:
var63 = ;
}
formattedReplacement = var63;
label185;
:
Objects.requireNonNull(replacement);
;
String var10000;
(replacement.typeSwitch<invokedynamic>(replacement, var48)) {
:
(StringParamValue)replacement;
var10000 = s.value;
;
:
(BoolParamValue)replacement;
var10000 = b.value ? : ;
;
:
(DoubleParamValue)replacement;
var10000 = Integer.toString(( )d.value);
;
:
(IntParamValue)replacement;
var10000 = Integer.toString(iv.value);
;
:
(LongParamValue)replacement;
var10000 = Long.toString(l.value);
;
:
var10000 = ;
}
formattedReplacement = var10000;
label185;
}
:
(options != ) {
;
;
options.indexOf( );
options.indexOf( );
(oneIdx >= ) {
oneIdx + .length();
findMatchingBrace(options, oneStart - );
(oneEnd > oneStart) {
oneText = options.substring(oneStart, oneEnd);
}
}
(otherIdx >= ) {
otherIdx + .length();
findMatchingBrace(options, otherStart - );
(otherEnd > otherStart) {
otherText = options.substring(otherStart, otherEnd);
}
}
Integer.parseInt(replacement.toString());
String selected;
(value == && oneText != ) {
selected = oneText;
} (otherText != ) {
selected = otherText;
} (oneText != ) {
selected = oneText;
} {
selected = ;
}
formattedReplacement = formatText(selected, params, messageParams);
}
}
(format == ) {
Objects.requireNonNull(replacement);
var23 = ;
String var64;
(replacement.typeSwitch<invokedynamic>(replacement, var23)) {
:
(StringParamValue)replacement;
var64 = s.value;
;
:
(BoolParamValue)replacement;
var64 = Boolean.toString(b.value);
;
:
(DoubleParamValue)replacement;
var64 = Double.toString(d.value);
;
:
(IntParamValue)replacement;
var64 = Integer.toString(iv.value);
;
:
(LongParamValue)replacement;
var64 = Long.toString(l.value);
;
:
var64 = ;
}
formattedReplacement = var64;
}
sb.append(formattedReplacement);
}
i = end;
lastWritePos = end + ;
}
}
} (ch == && i + < len && text.charAt(i + ) == ) {
(i > lastWritePos) {
sb.append(text, lastWritePos, i);
}
sb.append( );
++i;
lastWritePos = i + ;
}
}
(lastWritePos < len) {
sb.append(text, lastWritePos, len);
}
sb.toString();
}
}
{
;
text.length();
( start; i < len; ++i) {
(text.charAt(i) == ) {
++depth;
} (text.charAt(i) == ) {
--depth;
(depth == ) {
i;
}
}
}
- ;
}
{
i;
(i = start; i <= end && Character.isWhitespace(text.charAt(i)); ++i) {
}
i;
}
{
i;
(i = start; end >= i && Character.isWhitespace(text.charAt(i)); --end) {
}
end >= i ? end - i + : ;
}
}
com/hypixel/hytale/server/core/util/NotificationUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.protocol.ItemWithAllMetadata;
import com.hypixel.hytale.protocol.packets.interface_.Notification;
import com.hypixel.hytale.protocol.packets.interface_.NotificationStyle;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.io.PacketHandler;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class NotificationUtil {
public NotificationUtil () {
}
public static void sendNotificationToUniverse (@Nonnull Message message, @Nullable Message secondaryMessage, @Nullable String icon, @Nullable ItemWithAllMetadata item, @Nonnull NotificationStyle style) {
for (World world : Universe.get().getWorlds().values()) {
world.execute(() -> {
Store<EntityStore> store = world.getEntityStore().getStore();
sendNotificationToWorld(message, secondaryMessage, icon, item, style, store);
});
}
}
public static void sendNotificationToUniverse {
sendNotificationToUniverse(Message.raw(message), (Message) , (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotificationToUniverse(Message.raw(message), Message.raw(secondaryMessage), (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotificationToUniverse(Message.raw(message), (Message) , (String) , (ItemWithAllMetadata) , style);
}
{
sendNotificationToUniverse(message, (Message) , (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotificationToUniverse(message, (Message) , (String) , (ItemWithAllMetadata) , style);
}
{
sendNotificationToUniverse(message, (Message) , icon, (ItemWithAllMetadata) , style);
}
{
sendNotificationToUniverse(message, (Message) , (String) , item, style);
}
{
sendNotificationToUniverse(message, secondaryMessage, icon, (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotificationToUniverse(message, secondaryMessage, (String) , item, NotificationStyle.Default);
}
{
sendNotificationToUniverse(message, secondaryMessage, (String) , (ItemWithAllMetadata) , style);
}
{
sendNotificationToUniverse(message, secondaryMessage, icon, (ItemWithAllMetadata) , style);
}
{
sendNotificationToUniverse(message, secondaryMessage, (String) , item, style);
}
{
((EntityStore)store.getExternalData()).getWorld();
(PlayerRef playerRefComponent : world.getPlayerRefs()) {
sendNotification(playerRefComponent.getPacketHandler(), message, secondaryMessage, icon, item, style);
}
}
{
Objects.requireNonNull(message, );
Objects.requireNonNull(style, );
handler.writeNoCache( (message.getFormattedMessage(), secondaryMessage != ? secondaryMessage.getFormattedMessage() : , icon, item, style));
}
{
sendNotification(handler, Message.raw(message), (Message) , (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, (Message) , icon, (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, (Message) , icon, (ItemWithAllMetadata) , notificationStyle);
}
{
sendNotification(handler, Message.raw(message), (Message) , (String) , (ItemWithAllMetadata) , style);
}
{
sendNotification(handler, message, (Message) , (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, (Message) , (String) , (ItemWithAllMetadata) , style);
}
{
sendNotification(handler, Message.raw(message), Message.raw(secondaryMessage), (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, secondaryMessage, icon, (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, secondaryMessage, (String) , (ItemWithAllMetadata) , NotificationStyle.Default);
}
{
sendNotification(handler, message, secondaryMessage, (String) , item, NotificationStyle.Default);
}
{
sendNotification(handler, message, secondaryMessage, (String) , (ItemWithAllMetadata) , style);
}
{
sendNotification(handler, message, secondaryMessage, icon, (ItemWithAllMetadata) , style);
}
{
sendNotification(handler, message, secondaryMessage, (String) , item, style);
}
}
com/hypixel/hytale/server/core/util/PositionUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.Transform;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PositionUtil {
public PositionUtil () {
}
@Nonnull
public static Transform toTransformPacket (@Nonnull com.hypixel.hytale.math.vector.Transform transform) {
Vector3d position = transform.getPosition();
Vector3f rotation = transform.getRotation();
return new Transform (toPositionPacket(position), toDirectionPacket(rotation));
}
@Nonnull
public static Position toPositionPacket (@Nonnull Vector3d position) {
return new Position (position.x, position.y, position.z);
}
@Nonnull
public static Direction toDirectionPacket ( Vector3f rotation) {
(rotation.getYaw(), rotation.getPitch(), rotation.getRoll());
}
com.hypixel.hytale.math.vector.Transform {
transform == ? : .hypixel.hytale.math.vector.Transform(toVector3d(transform.position), toRotation(transform.orientation));
}
Vector3d {
(position_.x, position_.y, position_.z);
}
Vector3f {
(orientation.pitch, orientation.yaw, orientation.roll);
}
{
vector.x == position.x && vector.y == position.y && vector.z == position.z;
}
{
position.x = vector.x;
position.y = vector.y;
position.z = vector.z;
}
{
vector.x == direction.pitch && vector.y == direction.yaw && vector.z == direction.roll;
}
{
direction.pitch = vector.x;
direction.yaw = vector.y;
direction.roll = vector.z;
}
{
position.x = other.x;
position.y = other.y;
position.z = other.z;
}
{
direction.pitch = other.pitch;
direction.yaw = other.yaw;
direction.roll = other.roll;
}
}
com/hypixel/hytale/server/core/util/PrefabUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
import com.hypixel.hytale.server.core.modules.entity.component.FromPrefab;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.prefab.PrefabCopyableComponent;
import com.hypixel.hytale.server.core.prefab.PrefabRotation;
import com.hypixel.hytale.server.core.prefab.event.PrefabPasteEvent;
import com.hypixel.hytale.server.core.prefab.event.PrefabPlaceEntityEvent;
import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferCall;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.accessor.LocalCachedChunkAccessor;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
it.unimi.dsi.fastutil.ints.IntSet;
java.util.Random;
java.util.concurrent.CompletableFuture;
java.util.concurrent.atomic.AtomicInteger;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
;
;
;
( );
{
}
{
( )(prefabBuffer.getMaxX() - prefabBuffer.getMinX());
( )(prefabBuffer.getMaxZ() - prefabBuffer.getMinZ());
( )MathUtil.fastFloor( * Math.sqrt(xLength * xLength + zLength * zLength));
LocalCachedChunkAccessor.atWorldCoords(world, position.getX(), position.getZ(), prefabRadius);
prefabBuffer.compare((x, y, z, blockId, rotation, holder, prefabBufferCall) -> {
position.x + x;
position.y + y;
position.z + z;
chunkAccessor.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(bx, bz));
chunk.getBlock(bx, by, bz);
blockIdAtPos == blockId;
}, (random, PrefabRotation.fromRotation(yaw)));
}
{
( )(prefabBuffer.getMaxX() - prefabBuffer.getMinX());
( )(prefabBuffer.getMaxZ() - prefabBuffer.getMinZ());
( )MathUtil.fastFloor( * Math.sqrt(xLength * xLength + zLength * zLength));
LocalCachedChunkAccessor.atWorldCoords(world, position.getX(), position.getZ(), prefabRadius);
prefabBuffer.compare((x, y, z, blockId, rotation, holder, prefabBufferCall) -> {
(ignoreOrigin && x == && y == && z == ) {
;
} {
position.x + x;
position.y + y;
position.z + z;
chunkAccessor.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(bx, bz));
chunk.testPlaceBlock(bx, by, bz, (BlockType)BlockType.getAssetMap().getAsset(blockId), rotation, (x1, y1, z1, blockType, _rotation, filler) -> mask != && mask.contains(BlockType.getAssetMap().getIndex(blockType.getId())));
}
}, (random, PrefabRotation.fromRotation(yaw)));
}
{
paste(buffer, world, position, yaw, force, random, , componentAccessor);
}
{
paste(buffer, world, position, yaw, force, random, setBlockSettings, , , , componentAccessor);
}
{
PREFAB_ID_SOURCE.getAndIncrement();
}
{
( )(buffer.getMaxX() - buffer.getMinX());
( )(buffer.getMaxZ() - buffer.getMinZ());
( )MathUtil.fastFloor( * Math.sqrt(xLength * xLength + zLength * zLength));
LocalCachedChunkAccessor.atWorldCoords(world, position.getX(), position.getZ(), prefabRadius);
BlockTypeAssetMap<String, BlockType> blockTypeMap = BlockType.getAssetMap();
blockTypeMap.getIndex( );
(editorBlock == - ) {
( );
} {
PrefabRotation.fromRotation(yaw);
getNextPrefabId();
(prefabId, );
componentAccessor.invoke(startEvent);
(!startEvent.isCancelled()) {
buffer.forEach(IPrefabBuffer.iterateAllColumns(), (x, y, z, blockId, holder, supportValue, blockRotation, filler, call, fluidId, fluidLevel) -> {
position.x + x;
position.y + y;
position.z + z;
chunkAccessor.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(bx, bz));
Store<ChunkStore> fluidStore = world.getChunkStore().getStore();
(ChunkColumn)fluidStore.getComponent(chunk.getReference(), ChunkColumn.getComponentType());
Ref<ChunkStore> section = fluidColumn.getSection(ChunkUtil.chunkCoordinate(by));
(FluidSection)fluidStore.ensureAndGetComponent(section, FluidSection.getComponentType());
fluidSection.setFluid(bx, by, bz, fluidId, ( )fluidLevel);
BlockType block;
(technicalPaste) {
(blockId == && fluidId == ) {
block = (BlockType)blockTypeMap.getAsset( );
} {
block = blockTypeMap.getAsset(blockId);
}
} {
block = blockTypeMap.getAsset(blockId);
}
block.getId();
(filler != ) {
(holder != ) {
chunk.setState(bx, by, bz, holder.clone());
}
} {
(pasteAnchorAsBlock && technicalPaste && x == buffer.getAnchorX() && y == buffer.getAnchorY() && z == buffer.getAnchorZ()) {
blockTypeMap.getIndex( );
blockTypeMap.getAsset(index);
chunk.setBlock(bx, by, bz, index, type, blockRotation, filler, setBlockSettings);
} (!force) {
RotationTuple.get(blockRotation);
chunk.placeBlock(bx, by, bz, blockKey, rot.yaw(), rot.pitch(), rot.roll(), setBlockSettings);
} {
blockTypeMap.getIndex(blockKey);
blockTypeMap.getAsset(index);
chunk.setBlock(bx, by, bz, index, type, blockRotation, filler, setBlockSettings);
}
(supportValue != ) {
(!world.isInThread()) {
CompletableFutureUtil._catch(CompletableFuture.runAsync(() -> {
Ref<ChunkStore> ref = chunk.getReference();
Store<ChunkStore> store = ref.getStore();
(ChunkColumn)store.getComponent(ref, ChunkColumn.getComponentType());
BlockPhysics.setSupportValue(store, column.getSection(ChunkUtil.chunkCoordinate(by)), bx, by, bz, supportValue);
}, world));
} {
Ref<ChunkStore> ref = chunk.getReference();
Store<ChunkStore> store = ref.getStore();
(ChunkColumn)store.getComponent(ref, ChunkColumn.getComponentType());
BlockPhysics.setSupportValue(store, column.getSection(ChunkUtil.chunkCoordinate(by)), bx, by, bz, supportValue);
}
}
(holder != ) {
chunk.setState(bx, by, bz, holder.clone());
}
}
}, (x, z, entityWrappers, t) -> {
(loadEntities) {
(entityWrappers != && entityWrappers.length != ) {
( ; i < entityWrappers.length; ++i) {
Holder<EntityStore> entityToAdd = entityWrappers[i].clone();
(TransformComponent)entityToAdd.getComponent(TransformComponent.getComponentType());
(transformComp != ) {
transformComp.getPosition().clone();
rotation.rotate(entityPosition);
entityPosition.add(position);
transformComp = (TransformComponent)entityToAdd.getComponent(TransformComponent.getComponentType());
(transformComp != ) {
entityPosition = transformComp.getPosition();
entityPosition.x = entityWorldPosition.x;
entityPosition.y = entityWorldPosition.y;
entityPosition.z = entityWorldPosition.z;
(prefabId, entityToAdd);
componentAccessor.invoke(prefabPlaceEntityEvent);
entityToAdd.ensureComponent(FromPrefab.getComponentType());
(technicalPaste) {
entityToAdd.ensureComponent(PrefabCopyableComponent.getComponentType());
}
componentAccessor.addEntity(entityToAdd, AddReason.LOAD);
}
}
}
}
}
}, (x, y, z, path, fitHeightmap, inheritSeed, inheritHeightCondition, weights, rot, t) -> {
}, (random, rotation));
(prefabId, );
componentAccessor.invoke(endEvent);
}
}
}
{
remove(prefabBuffer, world, position, force, random, setBlockSettings, );
}
{
}
{
( )(prefabBuffer.getMaxX() - prefabBuffer.getMinX());
( )(prefabBuffer.getMaxZ() - prefabBuffer.getMinZ());
( )MathUtil.fastFloor( * Math.sqrt(xLength * xLength + zLength * zLength));
LocalCachedChunkAccessor.atWorldCoords(world, position.getX(), position.getZ(), prefabRadius);
BlockTypeAssetMap<String, BlockType> blockTypeMap = BlockType.getAssetMap();
prefabBuffer.forEach(IPrefabBuffer.iterateAllColumns(), (x, y, z, blockId, state, support, rotation, filler, call, fluidId, fluidLevel) -> {
position.x + x;
position.y + y;
position.z + z;
chunkAccessor.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(bx, bz));
Store<ChunkStore> store = world.getChunkStore().getStore();
(fluidId != ) {
(ChunkColumn)store.getComponent(chunk.getReference(), ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(by));
(FluidSection)store.ensureAndGetComponent(section, FluidSection.getComponentType());
fluidSection.setFluid(bx, by, bz, , ( ) );
}
(blockId != ) {
(filler == ) {
setBlockSettings;
((setBlockSettings & ) != && random.nextDouble() > brokenParticlesRate) {
updatedSetBlockSettings = setBlockSettings | ;
}
(!force) {
chunk.breakBlock(bx, by, bz, updatedSetBlockSettings);
} {
chunk.setBlock(bx, by, bz, , updatedSetBlockSettings);
}
}
}
}, (x, z, entityWrappers, t) -> {
}, (x, y, z, path, fitHeightmap, inheritSeed, inheritHeightCondition, weights, rotation, t) -> {
}, (random, PrefabRotation.fromRotation(prefabRotation)));
}
}
com/hypixel/hytale/server/core/util/ProcessUtil.java
package com.hypixel.hytale.server.core.util;
public class ProcessUtil {
public ProcessUtil () {
}
public static boolean isProcessRunning (int pid) {
return ProcessHandle.of((long )pid).isPresent();
}
}
com/hypixel/hytale/server/core/util/TargetUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.function.predicate.BiIntPredicate;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.iterator.BlockIterator;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector2d;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.modules.collision.CollisionMath;
import com.hypixel.hytale.server.core.modules.collision.WorldUtil;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
it.unimi.dsi.fastutil.objects.ObjectList;
java.util.LinkedList;
java.util.List;
java.util.function.IntPredicate;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
;
{
}
Vector3i {
(world);
buffer.updateChunk(( )originX, ( )originZ);
BlockIterator.iterate(originX, originY, originZ, directionX, directionY, directionZ, maxDistance, (x, y, z, px, py, pz, qx, qy, qz, iBuffer) -> {
(y >= && y < ) {
iBuffer.updateChunk(x, z);
(iBuffer.currentBlockChunk != && iBuffer.currentChunkColumn != ) {
iBuffer.x = x;
iBuffer.y = y;
iBuffer.z = z;
iBuffer.currentBlockChunk.getSectionAtBlockY(y);
blockSection.get(x, y, z);
WorldUtil.getFluidIdAtPosition(iBuffer.chunkStoreAccessor, iBuffer.currentChunkColumn, x, y, z);
!blockIdPredicate.test(blockId, fluidId);
} {
;
}
} {
;
}
}, buffer);
success ? : (buffer.x, buffer.y, buffer.z);
}
Vector3d {
(world);
buffer.updateChunk(( )originX, ( )originZ);
BlockIterator.iterate(originX, originY, originZ, directionX, directionY, directionZ, maxDistance, (x, y, z, px, py, pz, qx, qy, qz, iBuffer) -> {
(y >= && y < ) {
iBuffer.updateChunk(x, z);
(iBuffer.currentBlockChunk == ) {
;
} {
iBuffer.x = ( )x + px;
iBuffer.y = ( )y + py;
iBuffer.z = ( )z + pz;
iBuffer.currentBlockChunk.getSectionAtBlockY(y);
blockSection.get(x, y, z);
!blockIdPredicate.test(blockId);
}
} {
;
}
}, buffer);
success ? : (buffer.x, buffer.y, buffer.z);
}
Vector3i {
(world);
buffer.updateChunk(( )originX, ( )originZ);
BlockIterator.iterate(originX, originY, originZ, directionX, directionY, directionZ, maxDistance, (x, y, z, px, py, pz, qx, qy, qz, iBuffer) -> {
(y >= && y < ) {
iBuffer.updateChunk(x, z);
(iBuffer.currentBlockChunk == ) {
;
} {
iBuffer.x = x;
iBuffer.y = y;
iBuffer.z = z;
iBuffer.currentBlockChunk.getSectionAtBlockY(y);
blockSection.get(x, y, z);
(blockId != ) {
BlockUtil.pack(x, y, z);
(LongOpenHashSet locations : blocksToIgnore) {
(locations.contains(packedBlockLocation)) {
;
}
}
}
!blockIdPredicate.test(blockId);
}
} {
;
}
}, buffer);
success ? : (buffer.x, buffer.y, buffer.z);
}
Vector3i {
getTargetBlock(ref, (blockId) -> blockId != , maxDistance, componentAccessor);
}
Vector3i {
((EntityStore)componentAccessor.getExternalData()).getWorld();
getLook(ref, componentAccessor);
transform.getPosition();
transform.getDirection();
getTargetBlock(world, (id, _fluidId) -> blockIdPredicate.test(id), pos.x, pos.y, pos.z, dir.x, dir.y, dir.z, maxDistance);
}
Vector3d {
getTargetLocation(ref, (blockId) -> blockId != , maxDistance, componentAccessor);
}
Vector3d {
getLook(ref, componentAccessor);
getTargetLocation(transform, blockIdPredicate, maxDistance, componentAccessor);
}
Vector3d {
((EntityStore)componentAccessor.getExternalData()).getWorld();
transform.getPosition();
transform.getDirection();
getTargetLocation(world, blockIdPredicate, pos.x, pos.y, pos.z, dir.x, dir.y, dir.z, maxDistance);
}
List<Ref<EntityStore>> {
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
SpatialResource<Ref<EntityStore>, EntityStore> entitySpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getEntitySpatialResourceType());
entitySpatialResource.getSpatialStructure().collect(position, ( )(( )radius), results);
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
playerSpatialResource.getSpatialStructure().collect(position, ( )(( )radius), results);
results;
}
List<Ref<EntityStore>> {
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
SpatialResource<Ref<EntityStore>, EntityStore> entitySpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getEntitySpatialResourceType());
entitySpatialResource.getSpatialStructure().collectCylinder(position, radius, height, results);
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
playerSpatialResource.getSpatialStructure().collectCylinder(position, radius, height, results);
results;
}
List<Ref<EntityStore>> {
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
SpatialResource<Ref<EntityStore>, EntityStore> entitySpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getEntitySpatialResourceType());
entitySpatialResource.getSpatialStructure().collectBox(min, max, results);
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
playerSpatialResource.getSpatialStructure().collectBox(min, max, results);
results;
}
Ref<EntityStore> {
getTargetEntity(ref, , componentAccessor);
}
Ref<EntityStore> {
(TransformComponent)componentAccessor.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
getLook(ref, componentAccessor);
lookVec.getPosition();
lookVec.getDirection();
List<Ref<EntityStore>> targetEntities = getAllEntitiesInSphere(position, ( )radius, componentAccessor);
targetEntities.removeIf((targetRefx) -> {
(targetRefx != && targetRefx.isValid() && !targetRefx.equals(ref)) {
!isHitByRay(targetRefx, position, direction, componentAccessor);
} {
;
}
});
(targetEntities.isEmpty()) {
;
} {
Ref<EntityStore> closest = ;
;
(Ref<EntityStore> targetRef : targetEntities) {
(targetRef != && targetRef.isValid()) {
(TransformComponent)componentAccessor.getComponent(targetRef, TransformComponent.getComponentType());
targetTransformComponent != ;
transformPosition.distanceSquaredTo(targetTransformComponent.getPosition());
(distance < minDist2) {
minDist2 = distance;
closest = targetRef;
}
}
}
closest;
}
}
Transform {
(TransformComponent)componentAccessor.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
;
(ModelComponent)componentAccessor.getComponent(ref, ModelComponent.getComponentType());
(modelComponent != ) {
eyeHeight = modelComponent.getModel().getEyeHeight(ref, componentAccessor);
}
(HeadRotation)componentAccessor.getComponent(ref, HeadRotation.getComponentType());
headRotationComponent != ;
transformComponent.getPosition();
headRotationComponent.getRotation();
(position.getX(), position.getY() + ( )eyeHeight, position.getZ(), headRotation.getPitch(), headRotation.getYaw(), headRotation.getRoll());
}
{
(BoundingBox)componentAccessor.getComponent(ref, BoundingBox.getComponentType());
(TransformComponent)componentAccessor.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
(boundingBoxComponent == ) {
;
} {
boundingBoxComponent.getBoundingBox();
transformComponent.getPosition();
();
CollisionMath.intersectRayAABB(rayStart, rayDir, position.getX(), position.getY(), position.getZ(), boundingBox, minMax);
}
}
{
World world;
ComponentAccessor<ChunkStore> chunkStoreAccessor;
x;
y;
z;
currentChunkX;
currentChunkZ;
Ref<ChunkStore> currentChunkRef;
ChunkColumn currentChunkColumn;
BlockChunk currentBlockChunk;
{
.world = world;
.chunkStoreAccessor = world.getChunkStore().getStore();
}
{
ChunkUtil.chunkCoordinate(blockX);
ChunkUtil.chunkCoordinate(blockZ);
( .currentChunkRef == || chunkX != .currentChunkX || chunkZ != .currentChunkZ) {
.currentChunkX = chunkX;
.currentChunkZ = chunkZ;
ChunkUtil.indexChunk(chunkX, chunkZ);
.currentChunkRef = .world.getChunkStore().getChunkReference(chunkIndex);
( .currentChunkRef != && .currentChunkRef.isValid()) {
.currentChunkColumn = (ChunkColumn) .chunkStoreAccessor.getComponent( .currentChunkRef, ChunkColumn.getComponentType());
.currentBlockChunk = (BlockChunk) .chunkStoreAccessor.getComponent( .currentChunkRef, BlockChunk.getComponentType());
} {
.currentChunkColumn = ;
.currentBlockChunk = ;
}
}
}
}
{
World world;
ComponentAccessor<ChunkStore> chunkStoreAccessor;
x;
y;
z;
currentChunkX;
currentChunkZ;
Ref<ChunkStore> currentChunkRef;
BlockChunk currentBlockChunk;
{
.world = world;
.chunkStoreAccessor = world.getChunkStore().getStore();
}
{
ChunkUtil.chunkCoordinate(blockX);
ChunkUtil.chunkCoordinate(blockZ);
( .currentChunkRef == || chunkX != .currentChunkX || chunkZ != .currentChunkZ) {
.currentChunkX = chunkX;
.currentChunkZ = chunkZ;
ChunkUtil.indexChunk(chunkX, chunkZ);
.currentChunkRef = .world.getChunkStore().getChunkReference(chunkIndex);
( .currentChunkRef != && .currentChunkRef.isValid()) {
.currentBlockChunk = (BlockChunk) .chunkStoreAccessor.getComponent( .currentChunkRef, BlockChunk.getComponentType());
} {
.currentBlockChunk = ;
}
}
}
}
}
com/hypixel/hytale/server/core/util/TempAssetIdUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
import java.util.logging.Level;
@Deprecated(
forRemoval = true
)
public class TempAssetIdUtil {
public static final String SOIL_GRASS = "Soil_Grass" ;
public static final String SOUND_EVENT_ITEM_REPAIR = "SFX_Item_Repair" ;
public static final String SOUND_EVENT_PLAYER_PICKUP_ITEM = "SFX_Player_Pickup_Item" ;
public static final String SOUND_EVENT_ITEM_BREAK = "SFX_Item_Break" ;
public static final String SOUND_EVENT_PLAYER_CRAFT_ITEM_INVENTORY = "SFX_Player_Craft_Item_Inventory" ;
public static final ;
;
;
;
{
}
{
SoundEvent.getAssetMap().getIndex(soundEventId);
(soundEventIndex == - ) {
HytaleLogger.getLogger().at(Level.WARNING).log( , soundEventId);
soundEventIndex = ;
}
soundEventIndex;
}
}
com/hypixel/hytale/server/core/util/UUIDUtil.java
package com.hypixel.hytale.server.core.util;
import java.util.UUID;
import javax.annotation.Nonnull;
public class UUIDUtil {
public static final UUID EMPTY_UUID = new UUID (0L , 0L );
public UUIDUtil () {
}
@Nonnull
public static UUID generateVersion3UUID () {
UUID out = UUID.randomUUID();
if (out.version() != 3 ) {
long msb = out.getMostSignificantBits();
msb &= -16385L ;
msb |= 12288L ;
out = new UUID (msb, out.getLeastSignificantBits());
}
return out;
}
public static boolean isEmptyOrNull (UUID uuid) {
return uuid == null || uuid.equals(EMPTY_UUID);
}
}
com/hypixel/hytale/server/core/util/ValidateUtil.java
package com.hypixel.hytale.server.core.util;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.Position;
import javax.annotation.Nonnull;
public class ValidateUtil {
public ValidateUtil () {
}
public static boolean isSafeDouble (double x) {
return !Double.isNaN(x) && Double.isFinite(x);
}
public static boolean isSafeFloat (float x) {
return !Float.isNaN(x) && Float.isFinite(x);
}
public static boolean isSafePosition (@Nonnull Position position) {
return isSafeDouble(position.x) && isSafeDouble(position.y) && isSafeDouble(position.z);
}
public static boolean isSafeDirection (@Nonnull Direction direction) {
return isSafeFloat(direction.yaw) && isSafeFloat(direction.pitch) && isSafeFloat(direction.roll);
}
}
com/hypixel/hytale/server/core/util/WildcardMatch.java
package com.hypixel.hytale.server.core.util;
public final class WildcardMatch {
private WildcardMatch () {
}
public static boolean test (String text, String pattern) {
return test(text, pattern, false );
}
public static boolean test (String text, String pattern, boolean ignoreCase) {
if (ignoreCase) {
text = text.toLowerCase();
pattern = pattern.toLowerCase();
}
if (text.equals(pattern)) {
return true ;
} else {
int t = 0 ;
int p = 0 ;
int starIdx = -1 ;
int match = 0 ;
while (t < text.length()) {
if (p >= pattern.length() || pattern.charAt(p) != '?' && pattern.charAt(p) != text.charAt(t)) {
if (p < pattern.length() && pattern.charAt(p) == ) {
starIdx = p++;
match = t;
} {
(starIdx == - ) {
;
}
p = starIdx + ;
++match;
t = match;
}
} {
++t;
++p;
}
}
(p < pattern.length() && pattern.charAt(p) == ) {
++p;
}
p == pattern.length();
}
}
}
com/hypixel/hytale/server/core/util/backup/BackupTask.java
package com.hypixel.hytale.server.core.util.backup;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Options;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.FileTime;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BackupTask {
private static final DateTimeFormatter BACKUP_FILE_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss" );
private static final Duration BACKUP_ARCHIVE_FREQUENCY;
private static final HytaleLogger LOGGER;
@Nonnull
private final CompletableFuture<Void> completion = new CompletableFuture ();
public CompletableFuture<Void> {
(universeDir, backupDir);
task.completion;
}
{
( ( ) {
{
.setDaemon( );
}
{
BackupUtil.broadcastBackupStatus( );
{
backupDir.resolve( );
Files.createDirectories(backupDir);
Files.createDirectories(archiveDir);
BackupTask.cleanOrArchiveOldBackups(backupDir, archiveDir);
BackupTask.cleanOldBackups(archiveDir);
BackupTask.BACKUP_FILE_DATE_FORMATTER;
var10000.format(LocalDateTime.now()) + ;
backupDir.resolve(backupName + );
BackupUtil.walkFileTreeAndZip(universeDir, tempZip);
backupDir.resolve(backupName);
Files.move(tempZip, backupZip, StandardCopyOption.REPLACE_EXISTING);
BackupTask.LOGGER.at(Level.INFO).log( , backupZip);
BackupTask. .completion.complete((Object) );
} (Throwable t) {
((HytaleLogger.Api)BackupTask.LOGGER.at(Level.SEVERE).withCause(t)).log( );
BackupUtil.broadcastBackupError(t);
BackupTask. .completion.completeExceptionally(t);
} {
BackupUtil.broadcastBackupStatus( );
}
}
}).start();
}
IOException {
(Integer)Options.getOptionSet().valueOf(Options.BACKUP_MAX_COUNT);
(maxCount >= ) {
List<Path> oldBackups = BackupUtil.findOldBackups(sourceDir, maxCount);
(oldBackups != && !oldBackups.isEmpty()) {
(Path)oldBackups.getFirst();
Files.getLastModifiedTime(oldestBackup);
getMostRecentArchive(archiveDir);
lastArchive == || Duration.between(oldestBackupTime.toInstant(), lastArchive.toInstant()).compareTo(BACKUP_ARCHIVE_FREQUENCY) > ;
(doArchive) {
oldBackups = oldBackups.subList( , oldBackups.size());
Files.move(oldestBackup, archiveDir.resolve(oldestBackup.getFileName()), StandardCopyOption.REPLACE_EXISTING);
LOGGER.at(Level.INFO).log( , oldestBackup);
}
(Path path : oldBackups) {
LOGGER.at(Level.INFO).log( , path);
Files.deleteIfExists(path);
}
}
}
}
IOException {
(Integer)Options.getOptionSet().valueOf(Options.BACKUP_MAX_COUNT);
(maxCount >= ) {
List<Path> oldBackups = BackupUtil.findOldBackups(dir, maxCount);
(oldBackups != && !oldBackups.isEmpty()) {
(Path path : oldBackups) {
LOGGER.at(Level.INFO).log( , path);
Files.deleteIfExists(path);
}
}
}
}
FileTime IOException {
;
DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
{
(Path path : stream) {
(Files.isRegularFile(path, [ ])) {
Files.getLastModifiedTime(path);
(mostRecent == || modifiedTime.compareTo(mostRecent) > ) {
mostRecent = modifiedTime;
}
}
}
} (Throwable var7) {
(stream != ) {
{
stream.close();
} (Throwable var6) {
var7.addSuppressed(var6);
}
}
var7;
}
(stream != ) {
stream.close();
}
mostRecent;
}
{
BACKUP_ARCHIVE_FREQUENCY = Duration.of( , ChronoUnit.HOURS);
LOGGER = HytaleLogger.forEnclosingClass();
}
}
com/hypixel/hytale/server/core/util/backup/BackupUtil.java
package com.hypixel.hytale.server.core.util.backup;
import com.hypixel.hytale.common.util.java.ManifestUtil;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.packets.interface_.WorldSavingStatus;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.server.core.universe.Universe;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
class BackupUtil {
BackupUtil() {
}
static void walkFileTreeAndZip (@Nonnull Path sourceDir, @Nonnull Path zipPath) throws IOException {
ZipOutputStream zipOutputStream = new ZipOutputStream (Files.newOutputStream(zipPath));
try {
zipOutputStream.setMethod(0 );
zipOutputStream.setLevel( );
ManifestUtil.getImplementationVersion();
zipOutputStream.setComment( + var10001 + + ManifestUtil.getImplementationRevisionId());
Stream<Path> stream = Files.walk(sourceDir);
{
(Path path : stream.filter((x$ ) -> Files.isRegularFile(x$ , [ ])).toList()) {
Files.size(path);
();
Files.newInputStream(path);
{
[] buffer = [ ];
len;
((len = inputStream.read(buffer)) != - ) {
crc.update(buffer, , len);
}
} (Throwable var16) {
(inputStream != ) {
{
inputStream.close();
} (Throwable var15) {
var16.addSuppressed(var15);
}
}
var16;
}
(inputStream != ) {
inputStream.close();
}
(sourceDir.relativize(path).toString());
zipEntry.setSize(size);
zipEntry.setCompressedSize(size);
zipEntry.setCrc(crc.getValue());
zipOutputStream.putNextEntry(zipEntry);
Files.copy(path, zipOutputStream);
zipOutputStream.closeEntry();
}
} (Throwable var17) {
(stream != ) {
{
stream.close();
} (Throwable var14) {
var17.addSuppressed(var14);
}
}
var17;
}
(stream != ) {
stream.close();
}
} (Throwable var18) {
{
zipOutputStream.close();
} (Throwable var13) {
var18.addSuppressed(var13);
}
var18;
}
zipOutputStream.close();
}
{
Universe.get().broadcastPacket((Packet)( (isWorldSaving)));
}
{
Message.translation( ).param( , cause.getLocalizedMessage());
Universe.get().getPlayers().forEach((player) -> {
PermissionsModule.get().hasPermission(player.getUuid(), );
(hasPermission) {
player.sendMessage(message);
}
});
}
List<Path> IOException {
(!backupDirectory.toFile().isDirectory()) {
;
} {
Stream<Path> files = Files.list(backupDirectory);
List var4;
label44: {
{
List<Path> zipFiles = files.filter((p) -> p.getFileName().toString().endsWith( )).sorted(Comparator.comparing((p) -> {
{
Files.readAttributes(p, BasicFileAttributes.class).creationTime();
} (IOException var2) {
FileTime.fromMillis( );
}
})).toList();
(zipFiles.size() > maxBackupCount) {
var4 = zipFiles.subList( , zipFiles.size() - maxBackupCount);
label44;
}
} (Throwable var6) {
(files != ) {
{
files.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(files != ) {
files.close();
}
;
}
(files != ) {
files.close();
}
var4;
}
}
}
com/hypixel/hytale/server/core/util/concurrent/ThreadUtil.java
package com.hypixel.hytale.server.core.util.concurrent;
import java.security.Permission;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Semaphore;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
public class ThreadUtil {
public ThreadUtil () {
}
public static void forceTimeHighResolution () {
Thread t = new Thread (() -> {
try {
while (!Thread.interrupted()) {
Thread.sleep(9223372036854775807L );
}
} catch (InterruptedException var1) {
Thread.currentThread().interrupt();
}
}, "ForceTimeHighResolution" );
t.setDaemon(true );
t.start();
}
public static void createKeepAliveThread (@Nonnull Semaphore alive) {
(() -> {
{
alive.acquire();
} (InterruptedException var2) {
Thread.currentThread().interrupt();
}
}, );
t.setDaemon( );
t.start();
}
ExecutorService {
( , maximumPoolSize, , TimeUnit.SECONDS, (), threadFactory);
}
ThreadFactory {
(r) -> {
(r, name);
t.setDaemon( );
t;
};
}
ThreadFactory {
();
(r) -> {
(r, String.format(name, count.incrementAndGet()));
t.setDaemon( );
t;
};
}
{
Predicate<Thread> predicate;
Consumer<Thread> action;
{
.predicate = predicate;
.action = action;
}
{
}
{
}
{
Thread.currentThread();
( .predicate.test(creatingThread)) {
.action.accept(creatingThread);
}
}
}
}
com/hypixel/hytale/server/core/util/io/BlockingDiskFile.java
package com.hypixel.hytale.server.core.util.io;
import com.hypixel.hytale.server.core.Options;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.annotation.Nonnull;
public abstract class BlockingDiskFile {
protected final ReadWriteLock fileLock = new ReentrantReadWriteLock ();
protected final Path path;
public BlockingDiskFile (Path path) {
this .path = path;
}
protected abstract void read (BufferedReader var1) throws IOException;
protected abstract void write (BufferedWriter var1) IOException;
IOException;
{
.fileLock.writeLock().lock();
{
.toLocalFile();
{
(!file.exists()) {
(Options.getOptionSet().has(Options.BARE)) {
();
[] bytes;
{
( (out));
{
.create(buf);
bytes = out.toByteArray();
} (Throwable var26) {
{
buf.close();
} (Throwable var24) {
var26.addSuppressed(var24);
}
var26;
}
buf.close();
} (Throwable var27) {
{
out.close();
} (Throwable var23) {
var27.addSuppressed(var23);
}
var27;
}
out.close();
( ( (bytes)));
{
.read(buf);
} (Throwable var25) {
{
buf.close();
} (Throwable var22) {
var25.addSuppressed(var22);
}
var25;
}
buf.close();
;
}
Files.newBufferedWriter(file.toPath());
{
.create(fileWriter);
} (Throwable var29) {
(fileWriter != ) {
{
fileWriter.close();
} (Throwable var21) {
var29.addSuppressed(var21);
}
}
var29;
}
(fileWriter != ) {
fileWriter.close();
}
}
Files.newBufferedReader(file.toPath());
{
.read(fileReader);
} (Throwable var28) {
(fileReader != ) {
{
fileReader.close();
} (Throwable var20) {
var28.addSuppressed(var20);
}
}
var28;
}
(fileReader != ) {
fileReader.close();
}
} (Exception ex) {
( + file.getAbsolutePath(), ex);
}
} {
.fileLock.writeLock().unlock();
}
}
{
;
.fileLock.readLock().lock();
{
file = .toLocalFile();
Files.newBufferedWriter(file.toPath());
{
.write(fileWriter);
} (Throwable var11) {
(fileWriter != ) {
{
fileWriter.close();
} (Throwable var10) {
var11.addSuppressed(var10);
}
}
var11;
}
(fileWriter != ) {
fileWriter.close();
}
} (Exception ex) {
( + (file != ? file.getAbsolutePath() : ), ex);
} {
.fileLock.readLock().unlock();
}
}
File {
.path.toFile();
}
}
com/hypixel/hytale/server/core/util/io/ByteBufUtil.java
package com.hypixel.hytale.server.core.util.io;
import com.hypixel.hytale.common.util.BitSetUtil;
import com.hypixel.hytale.unsafe.UnsafeUtil;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;
import java.util.BitSet;
import javax.annotation.Nonnull;
public class ByteBufUtil {
private static int MAX_UNSIGNED_SHORT_VALUE = 65535 ;
public ByteBufUtil () {
}
public static void writeUTF (@Nonnull ByteBuf buf, @Nonnull String string) {
if (io.netty.buffer.ByteBufUtil.utf8MaxBytes(string) >= MAX_UNSIGNED_SHORT_VALUE) {
throw new IllegalArgumentException ("String is too large" );
} else {
int before = buf.writerIndex();
buf.writeShort(-1 );
int length = buf.writeCharSequence(string, StandardCharsets.UTF_8);
if (length >= 0 && length < MAX_UNSIGNED_SHORT_VALUE) {
int after = buf.writerIndex();
buf.writerIndex(before);
buf.writeShort(length);
buf.writerIndex(after);
} {
( );
}
}
}
String {
buf.readUnsignedShort();
buf.readCharSequence(length, StandardCharsets.UTF_8).toString();
}
{
writeByteArray(buf, arr, , arr.length);
}
{
(length > && length < MAX_UNSIGNED_SHORT_VALUE) {
buf.writeShort(length);
buf.writeBytes(arr, src, length);
} {
( );
}
}
[] readByteArray( ByteBuf buf) {
buf.readUnsignedShort();
[] bytes = [length];
buf.readBytes(bytes);
bytes;
}
[] getBytesRelease( ByteBuf buf) {
[] var1;
{
var1 = io.netty.buffer.ByteBufUtil.getBytes(buf, , buf.writerIndex(), );
} {
buf.release();
}
var1;
}
{
(bytes) {
:
buf.writeByte(value);
;
:
buf.writeShort(value);
:
:
;
:
buf.writeInt(value);
}
}
{
var10000;
(bytes) {
:
var10000 = buf.readByte() & ;
;
:
var10000 = buf.readShort() & ;
;
:
:
var10000 = ;
;
:
var10000 = buf.readInt();
}
var10000;
}
{
wordsInUse;
[] words;
(UnsafeUtil.UNSAFE == ) {
words = bitset.toLongArray();
wordsInUse = words.length;
} {
wordsInUse = UnsafeUtil.UNSAFE.getInt(bitset, BitSetUtil.WORDS_IN_USE_OFFSET);
words = ( [])UnsafeUtil.UNSAFE.getObject(bitset, BitSetUtil.WORDS_OFFSET);
}
buf.writeInt(wordsInUse);
( ; i < wordsInUse; ++i) {
buf.writeLong(words[i]);
}
}
{
buf.readInt();
(UnsafeUtil.UNSAFE == ) {
[] words = [wordsInUse];
( ; i < wordsInUse; ++i) {
words[i] = buf.readLong();
}
bitset.clear();
bitset.or(BitSet.valueOf(words));
} {
UnsafeUtil.UNSAFE.putInt(bitset, BitSetUtil.WORDS_IN_USE_OFFSET, wordsInUse);
[] words = ( [])UnsafeUtil.UNSAFE.getObject(bitset, BitSetUtil.WORDS_OFFSET);
(wordsInUse > words.length) {
words = [wordsInUse];
UnsafeUtil.UNSAFE.putObject(bitset, BitSetUtil.WORDS_OFFSET, words);
}
( ; i < wordsInUse; ++i) {
words[i] = buf.readLong();
}
}
}
}
com/hypixel/hytale/server/core/util/io/FileUtil.java
package com.hypixel.hytale.server.core.util.io;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.CopyOption;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Comparator;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipInputStream;
import javax.annotation.Nonnull;
public class FileUtil {
public static final Set<OpenOption> DEFAULT_WRITE_OPTIONS;
public static final Set<FileVisitOption> DEFAULT_WALK_TREE_OPTIONS_SET;
public static final FileVisitOption[] DEFAULT_WALK_TREE_OPTIONS_ARRAY;
public static final Pattern INVALID_FILENAME_CHARACTERS;
public FileUtil () {
}
public static void unzipFile (@Nonnull Path path, [] buffer, ZipInputStream zipStream, ZipEntry zipEntry, String name) IOException {
path.resolve(name);
(!filePath.toAbsolutePath().startsWith(path)) {
( + zipEntry.getName());
} {
(zipEntry.isDirectory()) {
Files.createDirectory(filePath);
} {
Files.newOutputStream(filePath);
len;
{
((len = zipStream.read(buffer)) > ) {
stream.write(buffer, , len);
}
} (Throwable var10) {
(stream != ) {
{
stream.close();
} (Throwable var9) {
var10.addSuppressed(var9);
}
}
var10;
}
(stream != ) {
stream.close();
}
}
zipStream.closeEntry();
}
}
IOException {
Stream<Path> paths = Files.walk(origin);
{
paths.forEach((originSubPath) -> {
{
origin.relativize(originSubPath);
destination.resolve(relative);
Files.copy(originSubPath, destinationSubPath);
} (Throwable t) {
( , t);
}
});
} (Throwable var6) {
(paths != ) {
{
paths.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(paths != ) {
paths.close();
}
}
IOException {
Stream<Path> paths = Files.walk(origin);
{
paths.forEach((originSubPath) -> {
(!originSubPath.equals(origin)) {
{
origin.relativize(originSubPath);
destination.resolve(relative);
Files.move(originSubPath, destinationSubPath, options);
} (Throwable t) {
( , t);
}
}
});
} (Throwable var7) {
(paths != ) {
{
paths.close();
} (Throwable var6) {
var7.addSuppressed(var6);
}
}
var7;
}
(paths != ) {
paths.close();
}
}
IOException {
Stream<Path> stream = Files.walk(path);
{
stream.sorted(Comparator.reverseOrder()).forEach(SneakyThrow.sneakyConsumer(Files::delete));
} (Throwable var5) {
(stream != ) {
{
stream.close();
} (Throwable var4) {
var5.addSuppressed(var4);
}
}
var5;
}
(stream != ) {
stream.close();
}
}
{
DEFAULT_WRITE_OPTIONS = Set.of(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
DEFAULT_WALK_TREE_OPTIONS_SET = Set.of();
DEFAULT_WALK_TREE_OPTIONS_ARRAY = [ ];
INVALID_FILENAME_CHARACTERS = Pattern.compile( );
}
}
package com.hypixel.hytale.server.core.util.message;
import com.hypixel.hytale.server.core.Message;
import java.awt.Color;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class MessageFormat {
private static final Message ENABLED;
private static final Message DISABLED;
private static final int LIST_MAX_INLINE_VALUES = 4 ;
public MessageFormat () {
}
@Nonnull
public static Message enabled (boolean b) {
return b ? ENABLED : DISABLED;
}
@Nonnull
public static Message list (@Nullable Message header, @Nonnull Collection<Message> values) {
Message msg = Message.empty();
if (header != null ) {
msg.insert(Message.translation("server.formatting.list.header" ).param( , header).param( , values.size()));
(values.size() <= ) {
msg.insert(Message.translation( ));
}
}
(values.isEmpty()) {
msg.insert(Message.translation( ));
msg;
} {
(values.size() <= ) {
Message.translation( );
Message[] array = (Message[])values.toArray((x$ ) -> [x$ ]);
( ; i < array.length; ++i) {
msg.insert(array[i]);
(i < array.length - ) {
msg.insert(separator);
}
}
} {
Message.raw( );
(Message value : values) {
msg.insert(delim);
msg.insert(Message.translation( ).param( , value));
}
}
msg;
}
}
{
ENABLED = Message.translation( ).color(Color.GREEN);
DISABLED = Message.translation( ).color(Color.RED);
}
}
com/hypixel/hytale/server/core/util/thread/TickingThread.java
package com.hypixel.hytale.server.core.util.thread;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class TickingThread implements Runnable {
public static final int NANOS_IN_ONE_MILLI = 1000000 ;
public static final int NANOS_IN_ONE_SECOND = 1000000000 ;
public static final int TPS = 30 ;
public static long SLEEP_OFFSET = 3000000L ;
private final String threadName;
private final boolean daemon;
private AtomicBoolean needsShutdown;
tps;
tickStepNanos;
HistoricMetric bufferedTickLengthMetricSet;
Thread thread;
CompletableFuture<Void> startedFuture;
{
(threadName, , );
}
{
.needsShutdown = ( );
.startedFuture = ();
.threadName = threadName;
.daemon = daemon;
.tps = tps;
.tickStepNanos = / tps;
.bufferedTickLengthMetricSet = HistoricMetric.builder(( ) .tickStepNanos, TimeUnit.NANOSECONDS).addPeriod( , TimeUnit.SECONDS).addPeriod( , TimeUnit.MINUTES).addPeriod( , TimeUnit.MINUTES).build();
}
{
{
.onStart();
.startedFuture.complete((Object) );
System.nanoTime() - ( ) .tickStepNanos;
( .thread != && ! .thread.isInterrupted()) {
delta;
(! .isIdle()) {
((delta = System.nanoTime() - beforeTick) < ( ) .tickStepNanos) {
Thread.onSpinWait();
}
} {
delta = System.nanoTime() - beforeTick;
}
beforeTick = System.nanoTime();
.tick(( )delta / );
System.nanoTime() - beforeTick;
.bufferedTickLengthMetricSet.add(System.nanoTime(), tickLength);
( ) .tickStepNanos - tickLength;
(! .isIdle()) {
sleepLength -= SLEEP_OFFSET;
}
(sleepLength > ) {
Thread.sleep(sleepLength / );
}
}
} (InterruptedException var9) {
Thread.currentThread().interrupt();
} (Throwable t) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(t)).log( , .thread);
}
( .needsShutdown.getAndSet( )) {
.onShutdown();
}
}
{
;
}
;
{
}
;
CompletableFuture<Void> {
( .thread == ) {
.thread = ( , .threadName);
.thread.setDaemon( .daemon);
} ( .thread.isAlive()) {
( + .thread.getName() + );
}
.thread.start();
.startedFuture;
}
{
( .thread != && .thread.isAlive()) {
.thread.interrupt();
;
} {
;
}
}
{
.thread;
(thread != ) {
{
;
(thread.isAlive()) {
thread.interrupt();
thread.join(( )( .tickStepNanos / ));
i += .tickStepNanos / ;
(i > ) {
();
(StackTraceElement traceElement : thread.getStackTrace()) {
sb.append( ).append(traceElement).append( );
}
HytaleLogger.getLogger().at(Level.SEVERE).log( , thread, sb.toString());
thread.stop();
;
( .needsShutdown.getAndSet( )) {
.onShutdown();
}
;
}
}
;
} (InterruptedException var8) {
Thread.currentThread().interrupt();
}
}
}
{
.debugAssertInTickingThread();
(tps > && tps <= ) {
.tps = tps;
.tickStepNanos = / tps;
.bufferedTickLengthMetricSet = HistoricMetric.builder(( ) .tickStepNanos, TimeUnit.NANOSECONDS).addPeriod( , TimeUnit.SECONDS).addPeriod( , TimeUnit.MINUTES).addPeriod( , TimeUnit.MINUTES).build();
} {
( + tps);
}
}
{
.tps;
}
{
.tickStepNanos;
}
HistoricMetric {
.bufferedTickLengthMetricSet;
}
{
.bufferedTickLengthMetricSet.clear();
}
{
(!Thread.currentThread().equals( .thread) && .thread != ) {
( );
}
}
{
Thread.currentThread().equals( .thread);
}
{
.thread != && .thread.isAlive() && .needsShutdown.get();
}
{
.thread = thread;
}
Thread {
.thread;
}
}