com/hypixel/hytale/common/benchmark/ContinuousValueRecorder.java
package com.hypixel.hytale.common.benchmark;
public class ContinuousValueRecorder {
protected double minValue = 1.7976931348623157E308 ;
protected double maxValue = -1.7976931348623157E308 ;
protected double sumValues = 0.0 ;
protected long count = 0L ;
public ContinuousValueRecorder () {
}
public void reset () {
this .minValue = 1.7976931348623157E308 ;
this .maxValue = -1.7976931348623157E308 ;
this .sumValues = 0.0 ;
this .count = 0L ;
}
public double getMinValue (double def) {
return this .count > 0L ? this .minValue : def;
}
public double getMinValue () {
return this .getMinValue(0.0 );
}
public double getMaxValue (double def) {
return this .count > 0L ? this .maxValue : def;
}
public double getMaxValue () {
return this .getMaxValue(0.0 );
}
public long getCount () {
return this .count;
}
public double getAverage (double def) {
return this .count > 0L ? this .sumValues / (double )this .count : def;
}
public double getAverage () {
return this .getAverage(0.0 );
}
public double record (double value) {
if (this .minValue > value) {
this .minValue = value;
}
if (this .maxValue < value) {
this .maxValue = value;
}
++this .count;
this .sumValues += value;
return value;
}
}
com/hypixel/hytale/common/benchmark/DiscreteValueRecorder.java
package com.hypixel.hytale.common.benchmark;
import com.hypixel.hytale.common.util.FormatUtil;
import java.util.Formatter;
import javax.annotation.Nonnull;
public class DiscreteValueRecorder {
public static final String DEFAULT_COLUMN_SEPARATOR = "|" ;
public static final String DEFAULT_COLUMN_FORMAT_HEADER = "|%-6.6s" ;
public static final String DEFAULT_COLUMN_FORMAT_VALUE = "|%6.6s" ;
public static final String[] DEFAULT_COLUMNS = new String []{"AVG" , "MIN" , "MAX" , "COUNT" };
protected long minValue;
protected long maxValue;
protected long sumValues;
protected long count;
public DiscreteValueRecorder () {
this .reset();
}
{
.minValue = ;
.maxValue = - ;
.sumValues = ;
.count = ;
}
{
.count > ? .minValue : def;
}
{
.getMinValue( );
}
{
.count > ? .maxValue : def;
}
{
.getMaxValue( );
}
{
.count;
}
{
.count > ? ( * .sumValues + .count) / ( * .count) : def;
}
{
.getAverage( );
}
{
( .minValue > value) {
.minValue = value;
}
( .maxValue < value) {
.maxValue = value;
}
++ .count;
.sumValues += value;
}
String {
String.format( , .getAverage(), .getMinValue(), .getMaxValue());
}
{
.formatHeader(formatter, );
}
{
FormatUtil.formatArray(formatter, columnFormatHeader, DEFAULT_COLUMNS);
}
{
.formatValues(formatter, );
}
{
FormatUtil.formatArgs(formatter, columnFormatValue, .getAverage(), .getMinValue(), .getMaxValue(), .count);
}
}
com/hypixel/hytale/common/benchmark/TimeDistributionRecorder.java
package com.hypixel.hytale.common.benchmark;
import com.hypixel.hytale.math.util.MathUtil;
import java.util.Formatter;
import javax.annotation.Nonnull;
public class TimeDistributionRecorder extends TimeRecorder {
protected int minLogRange;
protected int maxLogRange;
protected int logSteps;
protected long [] valueBins;
public TimeDistributionRecorder (double maxSecs, double minSecs, int logSteps) {
if (!(maxSecs < 1.0E-6 ) && !(maxSecs > 0.1 )) {
if (!(minSecs < 1.0E-6 ) && !(minSecs > 0.1 )) {
if (maxSecs <= minSecs) {
throw new IllegalArgumentException ("Max seconds must be larger than min seconds" );
} else if (logSteps >= 2 && logSteps <= 10 ) {
this .maxLogRange = MathUtil.ceil(Math.log10(maxSecs));
this .minLogRange = MathUtil.floor(Math.log10(minSecs));
this .logSteps = MathUtil.clamp(logSteps, 2 , 10 );
.valueBins = [( .maxLogRange - .minLogRange) * .logSteps + ];
;
( .valueBins.length; i < length; ++i) {
.valueBins[i] = ;
}
} {
( );
}
} {
( );
}
} {
( );
}
}
{
(maxSecs, minSecs, );
}
{
( , );
}
{
.reset();
;
( .valueBins.length; i < length; ++i) {
.valueBins[i] = ;
}
}
{
.recordNanos(nanos);
.valueBins[ .timeToIndex(secs)]++;
secs;
}
{
Math.log10(secs);
(( ) .maxLogRange - logSecs) * ( ) .logSteps;
MathUtil.ceil(indexDbl);
(index < ) {
index = ;
} (index >= .valueBins.length) {
index = .valueBins.length - ;
}
index;
}
{
(index < ) {
index = ;
} (index >= .valueBins.length) {
index = .valueBins.length - ;
}
(index == .valueBins.length - ) {
;
} {
( ) .maxLogRange - ( )index / ( ) .logSteps;
Math.pow( , exp);
}
}
{
.valueBins.length;
}
{
.valueBins[index];
}
String {
( * .size());
stringBuilder.append( ).append( .getCount());
( ; i < .size(); ++i) {
stringBuilder.append( ).append(formatTime( .indexToTime(i))).append( ).append( .get(i));
}
.toString();
var10000 + + String.valueOf(stringBuilder);
}
{
.formatHeader(formatter, columnFormatHeader);
( ; i < .size(); ++i) {
formatter.format(columnFormatHeader, formatTime( .indexToTime(i)));
}
}
{
.formatValues(formatter, , columnFormatValue);
}
{
.formatValues(formatter, normalValue, );
}
{
.formatValues(formatter, columnFormatValue);
.count > && normalValue > ? ( )normalValue / ( ) .count : ;
( ; i < .size(); ++i) {
formatter.format(columnFormatValue, ( )Math.round(( ) .get(i) * norm));
}
}
}
com/hypixel/hytale/common/benchmark/TimeRecorder.java
package com.hypixel.hytale.common.benchmark;
import com.hypixel.hytale.common.util.FormatUtil;
import java.util.Formatter;
import javax.annotation.Nonnull;
public class TimeRecorder extends ContinuousValueRecorder {
public static final String DEFAULT_COLUMN_SEPARATOR = "|" ;
public static final String DEFAULT_COLUMN_FORMAT_HEADER = "|%-6.6s" ;
public static final String DEFAULT_COLUMN_FORMAT_VALUE = "|%6.6s" ;
public static final String[] DEFAULT_COLUMNS;
public static final double NANOS_TO_SECONDS = 1.0E-9 ;
public TimeRecorder () {
}
public long start () {
return System.nanoTime();
}
public {
.recordNanos(System.nanoTime() - start);
}
{
.record(( )nanos * );
}
String {
String.format( , formatTime( .getAverage( )), formatTime( .getMinValue( )), formatTime( .getMaxValue( )));
}
String {
(secs <= ) {
;
} (secs >= ) {
format(secs, );
} {
secs *= ;
(secs >= ) {
format(secs, );
} {
secs *= ;
(secs >= ) {
format(secs, );
} {
secs *= ;
format(secs, );
}
}
}
}
String {
( )Math.round(val);
var10000 + suffix;
}
{
.formatHeader(formatter, );
}
{
FormatUtil.formatArray(formatter, columnFormatHeader, DEFAULT_COLUMNS);
}
{
.formatValues(formatter, );
}
{
FormatUtil.formatArgs(formatter, columnFormatValue, formatTime( .getAverage()), formatTime( .getMinValue()), formatTime( .getMaxValue()), .count);
}
{
DEFAULT_COLUMNS = DiscreteValueRecorder.DEFAULT_COLUMNS;
}
}
com/hypixel/hytale/common/collection/BucketItem.java
package com.hypixel.hytale.common.collection;
import javax.annotation.Nonnull;
public class BucketItem <E> {
public E item;
public double squaredDistance;
public BucketItem () {
}
@Nonnull
public BucketItem<E> set (E reference, double squaredDistance) {
this .item = reference;
this .squaredDistance = squaredDistance;
return this ;
}
}
com/hypixel/hytale/common/collection/BucketItemPool.java
package com.hypixel.hytale.common.collection;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
public class BucketItemPool <E> {
@Nonnull
protected final List<BucketItem<E>> pool = new ObjectArrayList <BucketItem<E>>();
public BucketItemPool () {
}
public void deallocate (BucketItem<E>[] entityHolders, int count) {
this .pool.addAll(Arrays.asList(entityHolders).subList(0 , count));
}
public BucketItem<E> allocate (E reference, double squaredDistance) {
int l = this .pool.size();
BucketItem<E> holder = l == 0 ? new BucketItem () : (BucketItem)this .pool.remove(l - 1 );
return holder.set(reference, squaredDistance);
}
}
com/hypixel/hytale/common/collection/BucketList.java
package com.hypixel.hytale.common.collection;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrays;
import it.unimi.dsi.fastutil.objects.ObjectArrays;
import java.util.Comparator;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BucketList <E> {
public static final int INITIAL_BUCKET_ITEM_ARRAY_SIZE = 4 ;
public static final Comparator<BucketItem<?>> CLOSER_TO_SELF = Comparator.comparingDouble((bucketItem) -> bucketItem.squaredDistance);
protected static final byte [] EMPTY_INDICES = new byte []{-1 };
protected BucketItemPool<E> bucketItemPool;
@Nullable
protected Bucket<E>[] buckets;
protected byte [] bucketIndices;
protected int bucketCount;
protected int squaredMaxDistance;
public BucketList (BucketItemPool<E> bucketItemPool) {
this .bucketIndices = EMPTY_INDICES;
this .bucketItemPool = bucketItemPool;
}
{
.clear();
.bucketItemPool = bucketItemPool;
}
{
( .buckets != && .bucketItemPool != ) {
(Bucket<E> bucket : .buckets) {
bucket.clear( .bucketItemPool);
}
}
}
{
.clear();
.buckets = ;
.bucketCount = ;
.bucketIndices = EMPTY_INDICES;
}
{
.configure(bucketRanges, );
}
{
(bucketRanges == ) {
( );
} (bucketRanges.length <= ) {
( );
} {
[] copyRanges = ( [])(([I)bucketRanges).clone();
IntArrays.quickSort(copyRanges);
(copyRanges[ ] <= ) {
( );
} {
.configureWithPreSortedArray(copyRanges, initialBucketItemArraySize);
}
}
}
{
.configureWithPreSortedArray(bucketRanges, );
}
{
.clear();
.bucketCount = bucketRanges.length;
.squaredMaxDistance = bucketRanges[ .bucketCount - ];
.squaredMaxDistance *= .squaredMaxDistance;
.buckets = [ .bucketCount];
.bucketIndices = [ .squaredMaxDistance + ];
;
( ; i < .bucketCount; ++i) {
bucketRanges[i] * bucketRanges[i];
.buckets[i] = (initialBucketItemArraySize);
( inner; j < outer; ++j) {
.bucketIndices[j] = ( )i;
}
inner = outer;
}
.bucketIndices[ .bucketIndices.length - ] = - ;
}
{
.configureWithPreSortedArray(bucketRanges.toIntArray(), initialBucketItemArraySize);
}
{
.getFirstBucketIndex(( )squaredDistance);
(bucketIndex < ) {
;
} {
BucketItem<E> bucketItem = .bucketItemPool.allocate(item, squaredDistance);
.buckets[bucketIndex].add(bucketItem);
;
}
}
{
.buckets != ? .buckets.length : ;
}
Bucket<E> {
index >= && index < .getBucketCount() ? .buckets[index] : ;
}
{
(distanceSquared == ) {
.bucketIndices[ ];
} {
distanceSquared = Math.min(distanceSquared, .squaredMaxDistance);
distanceSquared <= ? - : .bucketIndices[distanceSquared];
}
}
{
Math.min(distanceSquared, .squaredMaxDistance) - ;
d < ? - : .bucketIndices[d];
}
E {
minRange * minRange;
.getFirstBucketIndex(minRangeSquared);
(startBucket < ) {
;
} {
maxRange * maxRange;
.getLastBucketIndex(maxRangeSquared);
( startBucket; i <= endBucket; ++i) {
Bucket<E> bucket = .buckets[i];
(!bucket.isEmpty) {
(bucket.isUnsorted) {
bucket.sort(sortBufferProvider);
}
BucketItem<E>[] entityHolders = bucket.bucketItems;
;
( bucket.size; i1 < entityHoldersSize; ++i1) {
BucketItem<E> holder = entityHolders[i1];
holder.squaredDistance;
(!(squaredDistance < ( )minRangeSquared)) {
(squaredDistance >= ( )maxRangeSquared) {
;
}
holder.item;
(item != && filter.test(item)) {
item;
}
}
}
}
}
;
}
}
{
addBucketDistance(bucketRanges, maxBucketCount, distance, - );
}
{
(distance >= ) {
;
length;
(length = bucketRanges.size(); i < length; ++i) {
bucketRanges.getInt(i);
(v == distance) {
;
}
(v > distance) {
;
}
}
bucketRanges.add(i, distance);
++length;
(length > maxBucketCount) {
bucketRanges.getInt( );
area( , middle);
;
- ;
( ; var13 < length; ++var13) {
bucketRanges.getInt(var13);
area(middle, outer);
innerArea + outerArea;
(sumAreas <= area && middle != keepDistance) {
pos = var13 - ;
area = sumAreas;
}
middle = outer;
innerArea = outerArea;
}
bucketRanges.removeInt(pos);
}
}
}
{
outer * outer - inner * inner;
}
<E> {
BucketItem<E>[] bucketItems;
size;
isUnsorted;
isEmpty;
{
.bucketItems = [initialBucketArraySize];
.size = ;
.isUnsorted = ;
.isEmpty = ;
}
BucketItem<E>[] getItems() {
.bucketItems;
}
{
.size;
}
{
.isUnsorted;
}
{
.isEmpty;
}
{
(! .isEmpty) {
pool.deallocate( .bucketItems, .size);
( ; i < .size; ++i) {
.bucketItems[i] = ;
}
.size = ;
.isUnsorted = ;
.isEmpty = ;
}
}
{
.isEmpty = ;
( .size == .bucketItems.length) {
.bucketItems = (BucketItem[])ObjectArrays.grow( .bucketItems, .size + );
}
.bucketItems[ .size++] = item;
.isUnsorted = ;
}
{
.isUnsorted = ;
( .size > ) {
BucketItem[] sortBuffer = sortBufferProvider.apply( .size);
System.arraycopy( .bucketItems, , sortBuffer, , .size);
ObjectArrays.mergeSort( .bucketItems, , .size, BucketList.CLOSER_TO_SELF, sortBuffer);
}
}
}
<BucketItem[]> {
BucketItem[] buffer = [ ];
{
}
BucketItem[] apply( size) {
(size <= .buffer.length) {
.buffer;
} {
.buffer = (BucketItem[])ObjectArrays.grow( .buffer, size);
.buffer;
}
}
}
}
com/hypixel/hytale/common/collection/Flag.java
package com.hypixel.hytale.common.collection;
public interface Flag {
String name () ;
int mask () ;
}
com/hypixel/hytale/common/collection/Flags.java
package com.hypixel.hytale.common.collection;
import com.hypixel.hytale.common.util.StringUtil;
import javax.annotation.Nonnull;
public class Flags <T extends Flag > {
private int flags;
public Flags (@Nonnull T flag) {
this .set(flag, true );
}
@SafeVarargs
public Flags (@Nonnull T... flags) {
for (T flag : flags) {
this .set(flag, true );
}
}
public Flags (int flags) {
this .flags = flags;
}
public int getFlags () {
return this .flags;
}
public boolean is (@Nonnull T flag) {
return (this .flags & flag.mask()) != 0 ;
}
public boolean not (@Nonnull T flag) {
return ( .flags & flag.mask()) == ;
}
{
(value) {
.flags != ( .flags |= flag.mask());
} {
.flags != ( .flags &= ~flag.mask());
}
}
{
(( .flags ^= flag.mask()) & flag.mask()) != ;
}
String {
StringUtil.toPaddedBinaryString( .flags);
}
}
com/hypixel/hytale/common/fastutil/HLongOpenHashSet.java
package com.hypixel.hytale.common.fastutil;
import com.hypixel.hytale.function.predicate.LongTriIntBiObjPredicate;
import it.unimi.dsi.fastutil.HashCommon;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import javax.annotation.Nonnull;
public class HLongOpenHashSet extends LongOpenHashSet implements HLongSet {
public HLongOpenHashSet () {
}
public <T, V> void removeIf (@Nonnull LongTriIntBiObjPredicate<T, V> predicate, int ia, int ib, int ic, T obj1, V obj2) {
int pos = super .n;
int last = -1 ;
int c = super .size;
boolean mustReturnNull = super .containsNull;
LongArrayList wrapped = null ;
label84:
while (c != 0 ) {
long ;
--c;
(mustReturnNull) {
mustReturnNull = ;
last = .n;
value = .key[ .n];
} {
[] key1 = .key;
( ) {
--pos;
(pos < ) {
;
}
(key1[pos] != ) {
last = pos;
value = key1[pos];
;
}
}
(pos < ) {
last = - ;
value = wrapped.getLong(-pos - );
}
}
(predicate.test(value, ia, ib, ic, obj1, obj2)) {
(last == .n) {
.containsNull = ;
.key[ .n] = ;
-- .size;
last = - ;
} (pos < ) {
.remove(wrapped.getLong(-pos - ));
last = - ;
} {
last;
[] key1 = .key;
( ) {
pos1;
pos1 = pos1 + & .mask;
curr;
( ) {
((curr = key1[pos1]) == ) {
key1[last1] = ;
-- .size;
last = - ;
label84;
}
( )HashCommon.mix(curr) & .mask;
(last1 <= pos1) {
(last1 >= slot || slot > pos1) {
;
}
} (last1 >= slot && slot > pos1) {
;
}
pos1 = pos1 + & .mask;
}
(pos1 < last1) {
(wrapped == ) {
wrapped = ( );
}
wrapped.add(key1[pos1]);
}
key1[last1] = curr;
}
}
}
}
}
}
com/hypixel/hytale/common/fastutil/HLongSet.java
package com.hypixel.hytale.common.fastutil;
import com.hypixel.hytale.function.predicate.LongTriIntBiObjPredicate;
import it.unimi.dsi.fastutil.longs.LongSet;
public interface HLongSet extends LongSet {
<T, V> void removeIf (LongTriIntBiObjPredicate<T, V> var1, int var2, int var3, int var4, T var5, V var6) ;
}
com/hypixel/hytale/common/fastutil/HObjectOpenHashSet.java
package com.hypixel.hytale.common.fastutil;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class HObjectOpenHashSet <K> extends ObjectOpenHashSet <K> {
public HObjectOpenHashSet () {
}
@Nullable
public K first () {
if (this .containsNull) {
return (K)this .key[this .n];
} else {
K[] key = this .key;
int pos = this .n;
while (pos-- != 0 ) {
if (key[pos] != null ) {
return (K)key[pos];
}
}
return null ;
}
}
public void pushInto (@Nonnull Collection<K> c) {
if (this .containsNull) {
c.add(this .key[this .n]);
}
K[] key = this .key;
.n;
(pos-- != ) {
(key[pos] != ) {
c.add(key[pos]);
}
}
}
}
com/hypixel/hytale/common/map/DefaultMap.java
package com.hypixel.hytale.common.map;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DefaultMap <K, V> implements Map <K, V> {
private final Map<K, V> delegate;
private final boolean allowReplacing;
private final boolean replaceNullWithDefault;
private V defaultValue;
public DefaultMap (V defaultValue) {
this (defaultValue, new HashMap ());
}
public DefaultMap (V defaultValue, Map<K, V> delegate) {
this (defaultValue, delegate, true );
}
public DefaultMap (V defaultValue, Map<K, V> delegate, boolean allowReplacing) {
this (defaultValue, delegate, allowReplacing, true );
}
public DefaultMap {
.defaultValue = defaultValue;
.delegate = delegate;
.allowReplacing = allowReplacing;
.replaceNullWithDefault = replaceNullWithDefault;
}
V {
.defaultValue;
}
{
.defaultValue = defaultValue;
}
Map<K, V> {
.delegate;
}
{
.delegate.size();
}
{
.delegate.isEmpty();
}
{
.delegate.containsKey(key);
}
{
.delegate.containsValue(value);
}
V {
( .replaceNullWithDefault && key == ) {
.defaultValue;
} {
(V) .delegate.get(key);
(V)(value != ? value : .defaultValue);
}
}
V {
( .allowReplacing) {
(V) .delegate.put(key, value);
} {
(V) .delegate.putIfAbsent(key, value);
(oldValue == ) {
;
} {
( + String.valueOf(key) + );
}
}
}
V {
(V) .delegate.remove(key);
}
{
.delegate.putAll(m);
}
{
.delegate.clear();
}
Set<K> {
.delegate.keySet();
}
Collection<V> {
.delegate.values();
}
Set<Map.Entry<K, V>> entrySet() {
.delegate.entrySet();
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
DefaultMap<?, ?> that = (DefaultMap)o;
( .allowReplacing != that.allowReplacing) {
;
} ( .replaceNullWithDefault != that.replaceNullWithDefault) {
;
} {
( .delegate != ) {
(! .delegate.equals(that.delegate)) {
;
}
} (that.delegate != ) {
;
}
.defaultValue != ? .defaultValue.equals(that.defaultValue) : that.defaultValue == ;
}
} {
;
}
}
{
.delegate != ? .delegate.hashCode() : ;
result = * result + ( .allowReplacing ? : );
result = * result + ( .replaceNullWithDefault ? : );
result = * result + ( .defaultValue != ? .defaultValue.hashCode() : );
result;
}
V {
(V) .delegate.getOrDefault(key, defaultValue);
}
{
.delegate.forEach(action);
}
{
.delegate.replaceAll(function);
}
V {
(V) .delegate.putIfAbsent(key, value);
}
{
.delegate.remove(key, value);
}
{
.delegate.replace(key, oldValue, newValue);
}
V {
(V) .delegate.replace(key, value);
}
V {
(V) .delegate.computeIfAbsent(key, mappingFunction);
}
V {
(V) .delegate.computeIfPresent(key, remappingFunction);
}
V {
(V) .delegate.compute(key, remappingFunction);
}
V {
(V) .delegate.merge(key, value, remappingFunction);
}
String {
String.valueOf( .defaultValue);
+ var10000 + + String.valueOf( .delegate) + ;
}
}
com/hypixel/hytale/common/map/IWeightedElement.java
package com.hypixel.hytale.common.map;
public interface IWeightedElement {
double getWeight () ;
}
com/hypixel/hytale/common/map/IWeightedMap.java
package com.hypixel.hytale.common.map;
import com.hypixel.hytale.function.function.BiDoubleToDoubleFunction;
import com.hypixel.hytale.function.function.BiIntToDoubleFunction;
import com.hypixel.hytale.function.function.BiLongToDoubleFunction;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.DoubleSupplier;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.ObjDoubleConsumer;
import javax.annotation.Nullable;
public interface IWeightedMap <T> {
@Nullable
T get (double var1) ;
@Nullable
T get (DoubleSupplier var1) ;
@Nullable
T get (Random var1) ;
@Nullable
T get (int var1, int var2, BiIntToDoubleFunction var3) ;
@Nullable
T get (long var1, long var3, BiLongToDoubleFunction var5) ;
@Nullable
T get (double var1, double var3, BiDoubleToDoubleFunction var5) ;
@Nullable
<K> T get (int var1, int var2, var3, SeedCoordinateFunction<K> var4, K var5) ;
;
;
;
;
T[] internalKeys();
T[] toArray();
<K> IWeightedMap<K> ;
<T> {
;
}
}
com/hypixel/hytale/common/map/WeightedMap.java
package com.hypixel.hytale.common.map;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.function.function.BiDoubleToDoubleFunction;
import com.hypixel.hytale.function.function.BiIntToDoubleFunction;
import com.hypixel.hytale.function.function.BiLongToDoubleFunction;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.DoubleSupplier;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.ObjDoubleConsumer;
import java.util.function.ToDoubleFunction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class WeightedMap <T> implements IWeightedMap <T> {
public static final double EPSILON = 0.99999 ;
public static final double ONE_MINUS_EPSILON = 9.99999999995449E-6 ;
@Nonnull
private final Set<T> keySet = new HashSet ();
T[] keys;
[] values;
sum;
<T> Builder<T> {
<T>(emptyKeys);
}
{
Collections.addAll( .keySet, keys);
.keys = keys;
.values = values;
.sum = sum;
}
T {
Math.min(value, ) * .sum;
( ; i < .keys.length; ++i) {
((weightPercentSum -= .values[i]) <= ) {
(T) .keys[i];
}
}
;
}
T {
(T) .get(supplier.getAsDouble());
}
T {
(T) .get(random.nextDouble());
}
T {
(T) .get(supplier.apply(x, z));
}
T {
(T) .get(supplier.apply(x, z));
}
T {
(T) .get(supplier.apply(x, z));
}
<K> T {
(T) .get(supplier.apply(seed, x, z, k));
}
{
.keys.length;
}
{
.keySet.contains(obj);
}
{
(T o : .keys) {
consumer.accept(o);
}
}
{
( ; i < .keys.length; ++i) {
consumer.accept( .keys[i], .values[i]);
}
}
T[] internalKeys() {
.keys;
}
T[] toArray() {
(T[])Arrays.copyOf( .keys, .keys.length);
}
<K> IWeightedMap<K> {
K[] array = (K[])((Object[])arraySupplier.apply( .keys.length));
( ; i < .keys.length; ++i) {
array[i] = mapper.apply( .keys[i]);
}
<K>(array, .values, .sum);
}
String {
String.valueOf( .keySet);
+ var10000 + + .sum + + Arrays.toString( .keys) + + Arrays.toString( .values) + ;
}
<T> <T> {
T[] keys;
T key;
{
.keys = keys;
.key = (T)(keys.length > ? keys[ ] : );
}
T {
.key;
}
T {
.key;
}
T {
.key;
}
T {
.key;
}
T {
.key;
}
T {
.key;
}
<K> T {
.key;
}
{
.keys.length;
}
{
obj != && (obj == .key || obj.equals( .key));
}
{
( .key != ) {
consumer.accept( .key);
}
}
{
( .key != ) {
consumer.accept( .key, );
}
}
T[] internalKeys() {
.keys;
}
T[] toArray() {
(T[])Arrays.copyOf( .keys, .keys.length);
}
<K> IWeightedMap<K> {
K[] array = (K[])((Object[])arraySupplier.apply( ));
array[ ] = mapper.apply( .key);
<K>(array);
}
String {
+ String.valueOf( .key) + ;
}
}
<T> {
T[] emptyKeys;
T[] keys;
[] values;
size;
{
.emptyKeys = emptyKeys;
.keys = emptyKeys;
.values = ArrayUtil.EMPTY_DOUBLE_ARRAY;
}
Builder<T> {
(map != ) {
.ensureCapacity(map.size());
map.forEachEntry( ::insert);
}
;
}
Builder<T> {
(arr != && arr.length != ) {
.ensureCapacity(arr.length);
(T t : arr) {
.insert(t, weight.applyAsDouble(t));
}
;
} {
;
}
}
Builder<T> {
.ensureCapacity( );
.insert(obj, weight);
;
}
{
.size + toAdd;
.allocated();
(minCapacity > allocated) {
Math.max(allocated + (allocated >> ), minCapacity);
.resize(newLength);
}
}
{
.keys = (T[])Arrays.copyOf( .keys, newLength);
.values = Arrays.copyOf( .values, newLength);
}
{
.keys[ .size] = key;
.values[ .size] = value;
++ .size;
}
{
.size;
}
{
.keys.length;
}
{
.keys = .emptyKeys;
.values = ArrayUtil.EMPTY_DOUBLE_ARRAY;
.size = ;
}
IWeightedMap<T> {
( .size < .allocated()) {
.resize( .size);
}
( .keys.length != && .keys.length != ) {
;
( value : .values) {
sum += value;
}
<T>( .keys, .values, sum);
} {
<T>( .keys);
}
}
}
}
com/hypixel/hytale/common/plugin/AuthorInfo.java
package com.hypixel.hytale.common.plugin;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class AuthorInfo {
@Nonnull
public static final Codec<AuthorInfo> CODEC;
@Nullable
private String name;
@Nullable
private String email;
@Nullable
private String url;
public AuthorInfo () {
}
@Nullable
public String getName () {
return this .name;
}
@Nullable
public String getEmail () {
return this .email;
}
@Nullable
public String getUrl () {
return this .url;
}
public void setName (@Nullable String name) {
this .name = name;
}
{
.email = email;
}
{
.url = url;
}
String {
+ .name + + .email + + .url + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(AuthorInfo.class, AuthorInfo:: ).append( ( , Codec.STRING), (authorInfo, s) -> authorInfo.name = s, (authorInfo) -> authorInfo.name).add()).append( ( , Codec.STRING), (authorInfo, s) -> authorInfo.email = s, (authorInfo) -> authorInfo.email).add()).append( ( , Codec.STRING), (authorInfo, s) -> authorInfo.url = s, (authorInfo) -> authorInfo.url).add()).build();
}
}
com/hypixel/hytale/common/plugin/PluginIdentifier.java
package com.hypixel.hytale.common.plugin;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PluginIdentifier {
@Nonnull
private final String group;
@Nonnull
private final String name;
public PluginIdentifier (@Nonnull String group, @Nonnull String name) {
this .group = group;
this .name = name;
}
public PluginIdentifier (@Nonnull PluginManifest manifest) {
this (manifest.getGroup(), manifest.getName());
}
@Nonnull
public String getGroup () {
return this .group;
}
@Nonnull
public String getName () {
return this .name;
}
public int hashCode () {
int result = this .group.hashCode();
result = 31 * result + this .name.hashCode();
result;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(PluginIdentifier)o;
!Objects.equals( .group, that.group) ? : Objects.equals( .name, that.name);
} {
;
}
}
String {
.group + + .name;
}
PluginIdentifier {
String[] split = str.split( );
(split.length != ) {
( );
} {
(split[ ], split[ ]);
}
}
}
com/hypixel/hytale/common/plugin/PluginManifest.java
package com.hypixel.hytale.common.plugin;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.codecs.map.ObjectMapCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.common.semver.Semver;
import com.hypixel.hytale.common.semver.SemverRange;
import com.hypixel.hytale.common.util.java.ManifestUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PluginManifest {
@Nonnull
private static final BuilderCodec.Builder<PluginManifest> BUILDER = BuilderCodec.<PluginManifest>builder(PluginManifest.class, PluginManifest::new );
@Nonnull
public static final Codec<PluginManifest> CODEC;
@Nonnull
public static final Codec<PluginManifest[]> ARRAY_CODEC;
private static final String ;
Semver CORE_VERSION;
String group;
String name;
Semver version;
String description;
List<AuthorInfo> authors = <AuthorInfo>();
String website;
String main;
SemverRange serverVersion;
Map<PluginIdentifier, SemverRange> dependencies = <PluginIdentifier, SemverRange>();
Map<PluginIdentifier, SemverRange> optionalDependencies = <PluginIdentifier, SemverRange>();
Map<PluginIdentifier, SemverRange> loadBefore = <PluginIdentifier, SemverRange>();
List<PluginManifest> subPlugins = ();
;
;
{
}
{
.group = group;
.name = name;
.version = version;
.description = description;
.authors = authors;
.website = website;
.main = main;
.serverVersion = serverVersion;
.dependencies = dependencies;
.optionalDependencies = optionalDependencies;
.loadBefore = loadBefore;
.subPlugins = subPlugins;
.disabledByDefault = disabledByDefault;
}
String {
.group;
}
String {
.name;
}
Semver {
.version;
}
String {
.description;
}
List<AuthorInfo> {
Collections.unmodifiableList( .authors);
}
String {
.website;
}
{
.group = group;
}
{
.name = name;
}
{
.version = version;
}
{
.description = description;
}
{
.authors = authors;
}
{
.website = website;
}
String {
.main;
}
SemverRange {
.serverVersion;
}
Map<PluginIdentifier, SemverRange> {
Collections.unmodifiableMap( .dependencies);
}
{
.dependencies.put(identifier, range);
}
Map<PluginIdentifier, SemverRange> {
Collections.unmodifiableMap( .optionalDependencies);
}
Map<PluginIdentifier, SemverRange> {
Collections.unmodifiableMap( .loadBefore);
}
{
.disabledByDefault;
}
{
.includesAssetPack;
}
List<PluginManifest> {
Collections.unmodifiableList( .subPlugins);
}
{
( .group == ) {
.group = manifest.group;
}
( .version == ) {
.version = manifest.version;
}
( .description == ) {
.description = manifest.description;
}
( .authors.isEmpty()) {
.authors = manifest.authors;
}
( .website == ) {
.website = manifest.website;
}
(! .disabledByDefault) {
.disabledByDefault = manifest.disabledByDefault;
}
.dependencies.put( (manifest), SemverRange.fromString(manifest.version.toString()));
}
String {
.group;
+ var10000 + + .name + + String.valueOf( .version) + + .description + + String.valueOf( .authors) + + .website + + .main + + String.valueOf( .serverVersion) + + String.valueOf( .dependencies) + + String.valueOf( .optionalDependencies) + + .disabledByDefault + ;
}
CoreBuilder {
( , pluginClass.getSimpleName(), CORE_VERSION, pluginClass.getName());
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BUILDER.append( ( , Codec.STRING), (manifest, o) -> manifest.group = o, (manifest) -> manifest.group).add()).append( ( , Codec.STRING), (manifest, o) -> manifest.name = o, (manifest) -> manifest.name).addValidator(Validators.nonNull()).add()).append( ( , Semver.CODEC), (manifest, o) -> manifest.version = o, (manifest) -> manifest.version).add()).append( ( , Codec.STRING), (manifest, o) -> manifest.description = o, (manifest) -> manifest.description).add()).append( ( , (AuthorInfo.CODEC, (x$ ) -> [x$ ])), (manifest, o) -> manifest.authors = List.of(o), (manifest) -> (AuthorInfo[])manifest.authors.toArray((x$ ) -> [x$ ])).add()).append( ( , Codec.STRING), (manifest, o) -> manifest.website = o, (manifest) -> manifest.website).add()).append( ( , Codec.STRING), (manifest, o) -> manifest.main = o, (manifest) -> manifest.main).add()).append( ( , SemverRange.CODEC), (manifest, o) -> manifest.serverVersion = o, (manifest) -> manifest.serverVersion).add()).append( ( , (SemverRange.CODEC, Object2ObjectLinkedOpenHashMap:: , PluginIdentifier::toString, PluginIdentifier::fromString)), (manifest, o) -> manifest.dependencies = o, (manifest) -> manifest.dependencies).add()).append( ( , (SemverRange.CODEC, Object2ObjectLinkedOpenHashMap:: , PluginIdentifier::toString, PluginIdentifier::fromString)), (manifest, o) -> manifest.optionalDependencies = o, (manifest) -> manifest.optionalDependencies).add()).append( ( , (SemverRange.CODEC, Object2ObjectLinkedOpenHashMap:: , PluginIdentifier::toString, PluginIdentifier::fromString)), (manifest, o) -> manifest.loadBefore = o, (manifest) -> manifest.loadBefore).add()).append( ( , Codec.BOOLEAN), (manifest, o) -> manifest.disabledByDefault = o, (manifest) -> manifest.disabledByDefault).add()).append( ( , Codec.BOOLEAN), (manifest, o) -> manifest.includesAssetPack = o, (o) -> o.includesAssetPack).add()).build();
BUILDER.append( ( , (CODEC, (x$ ) -> [x$ ])), (manifest, o) -> manifest.subPlugins = List.of(o), (manifest) -> (PluginManifest[])manifest.subPlugins.toArray((x$ ) -> [x$ ])).add();
ARRAY_CODEC = <PluginManifest[]>(CODEC, (x$ ) -> [x$ ]);
CORE_VERSION = ManifestUtil.getVersion() == ? Semver.fromString( ) : ManifestUtil.getVersion();
}
{
;
ManifestUtil.getVersion() == ? Semver.fromString( ) : ManifestUtil.getVersion();
String group;
String name;
Semver version;
String description;
String main;
Map<PluginIdentifier, SemverRange> dependencies = <PluginIdentifier, SemverRange>();
Map<PluginIdentifier, SemverRange> optionalDependencies = <PluginIdentifier, SemverRange>();
Map<PluginIdentifier, SemverRange> loadBefore = <PluginIdentifier, SemverRange>();
CoreBuilder {
( , pluginClass.getSimpleName(), CORE_VERSION, pluginClass.getName());
}
{
.group = group;
.name = name;
.version = version;
.main = main;
}
CoreBuilder {
.description = description;
;
}
CoreBuilder {
(Class<?> dependency : dependencies) {
.dependencies.put( ( , dependency.getSimpleName()), SemverRange.WILDCARD);
}
;
}
CoreBuilder {
(Class<?> optionalDependency : dependencies) {
.optionalDependencies.put( ( , optionalDependency.getSimpleName()), SemverRange.WILDCARD);
}
;
}
CoreBuilder {
(Class<?> plugin : plugins) {
.loadBefore.put( ( , plugin.getSimpleName()), SemverRange.WILDCARD);
}
;
}
PluginManifest {
( .group, .name, .version, .description, Collections.emptyList(), (String) , .main, (SemverRange) , .dependencies, .optionalDependencies, .loadBefore, Collections.emptyList(), );
}
}
}
com/hypixel/hytale/common/semver/Semver.java
package com.hypixel.hytale.common.semver;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import com.hypixel.hytale.common.util.StringUtil;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Semver implements Comparable <Semver> {
public static final Codec<Semver> CODEC;
private final long major;
private final long minor;
private final long patch;
private final String[] preRelease;
private final String build;
public Semver (long major, long minor, long patch) {
this (major, minor, patch, (String[])null , (String)null );
}
public Semver (long major, long minor, long patch, String[] preRelease, String build) {
if (major < 0L ) {
( );
} (minor < ) {
( );
} (patch < ) {
( );
} {
validatePreRelease(preRelease);
validateBuild(build);
.major = major;
.minor = minor;
.patch = patch;
.preRelease = preRelease;
.build = build;
}
}
{
.major;
}
{
.minor;
}
{
.patch;
}
String[] getPreRelease() {
(String[]) .preRelease.clone();
}
String {
.build;
}
{
range.satisfies( );
}
{
( .major != other.major) {
Long.compare( .major, other.major);
} ( .minor != other.minor) {
Long.compare( .minor, other.minor);
} ( .patch != other.patch) {
Long.compare( .patch, other.patch);
} ( .preRelease == || other.preRelease != && other.preRelease.length != ) {
(( .preRelease == || .preRelease.length == ) && other.preRelease != ) {
;
} ( .preRelease == ) {
;
} {
i;
(i = ; i < .preRelease.length && i < other.preRelease.length; ++i) {
.preRelease[i];
other.preRelease[i];
(StringUtil.isNumericString(pre) && StringUtil.isNumericString(otherPre)) {
Integer.compare(Integer.parseInt(pre), Integer.parseInt(otherPre));
(compare != ) {
compare;
}
} {
pre.compareTo(otherPre);
(compare != ) {
compare;
}
}
}
( .preRelease.length > i) {
;
} {
other.preRelease.length > i ? - : ;
}
}
} {
- ;
}
}
String {
( ()).append( .major).append( ).append( .minor).append( ).append( .patch);
( .preRelease != && .preRelease.length > ) {
ver.append( ).append(String.join( , .preRelease));
}
( .build != && ! .build.isEmpty()) {
ver.append( ).append( .build);
}
ver.toString();
}
Semver {
fromString(str, );
}
Semver {
Objects.requireNonNull(str, );
str = str.trim();
(str.isEmpty()) {
( );
} {
(str.charAt( ) == || str.charAt( ) == ) {
str = str.substring( );
}
(str.charAt( ) == || str.charAt( ) == ) {
str = str.substring( );
}
str = str.trim();
(str.isEmpty()) {
( );
} {
;
(str.contains( )) {
String[] buildSplit = str.split( , );
str = buildSplit[ ];
build = buildSplit[ ];
validateBuild(build);
}
String[] preRelease = ;
(str.contains( )) {
String[] preReleaseSplit = str.split( , );
str = preReleaseSplit[ ];
preRelease = preReleaseSplit[ ].split( );
validatePreRelease(preRelease);
}
(str.isEmpty() || str.charAt( ) != && str.charAt(str.length() - ) != ) {
String[] split = str.split( );
(split.length < ) {
( + str + );
} {
Long.parseLong(split[ ]);
(major < ) {
( + str + );
} (!strict && split.length == ) {
(major, , , preRelease, build);
} (split.length < ) {
( + str + );
} {
Long.parseLong(split[ ]);
(minor < ) {
( + str + );
} (!strict && split.length == ) {
(major, minor, , preRelease, build);
} (split.length != ) {
( + str + );
} {
split[ ];
(!strict && preRelease == ) {
;
();
( ; i < patchStr.length(); ++i) {
patchStr.charAt(i);
(!Character.isDigit(c)) {
pre = patchStr.substring(i);
patchStr = s.toString();
;
}
s.append(c);
}
(!pre.trim().isEmpty()) {
preRelease = pre.split( );
validatePreRelease(preRelease);
}
}
Long.parseLong(patchStr);
(patch < ) {
( + str + );
} {
(major, minor, patch, preRelease, build);
}
}
}
}
} {
( + str + );
}
}
}
}
{
(build != ) {
(build.isEmpty() || !StringUtil.isAlphaNumericHyphenString(build)) {
( + build + );
}
}
}
{
(preRelease != ) {
(String preReleasePart : preRelease) {
(preReleasePart.isEmpty() || !StringUtil.isAlphaNumericHyphenString(preReleasePart)) {
( + Arrays.toString(preRelease) + );
}
}
}
}
{
CODEC = (Codec.STRING, Semver::fromString, Semver::toString);
}
}
com/hypixel/hytale/common/semver/SemverComparator.java
package com.hypixel.hytale.common.semver;
import java.util.Objects;
import java.util.function.BiPredicate;
import javax.annotation.Nonnull;
public class SemverComparator implements SemverSatisfies {
private final ComparisonType comparisonType;
private final Semver compareTo;
public SemverComparator (ComparisonType comparisonType, Semver compareTo) {
this .comparisonType = comparisonType;
this .compareTo = compareTo;
}
public boolean satisfies (Semver semver) {
return this .comparisonType.satisfies(this .compareTo, semver);
}
@Nonnull
public String toString () {
String var10000 = this .comparisonType.getPrefix();
return var10000 + String.valueOf(this .compareTo);
}
@Nonnull
public static SemverComparator fromString (String str) {
Objects.requireNonNull(str, "String can't be null!" );
str = str.trim();
if (str.isEmpty()) {
throw ( );
} {
(ComparisonType comparisonType : SemverComparator.ComparisonType.values()) {
(str.startsWith(comparisonType.getPrefix())) {
Semver.fromString(str.substring(comparisonType.getPrefix().length()));
(comparisonType, semver);
}
}
( + str);
}
}
{
GTE( , (ct, s) -> ct.compareTo(s) <= ),
GT( , (ct, s) -> ct.compareTo(s) < ),
LTE( , (ct, s) -> ct.compareTo(s) >= ),
LT( , (ct, s) -> ct.compareTo(s) > ),
EQUAL( , (ct, s) -> ct.compareTo(s) == );
String prefix;
BiPredicate<Semver, Semver> satisfies;
{
.prefix = prefix;
.satisfies = satisfies;
}
String {
.prefix;
}
{
.satisfies.test(compareTo, semver);
}
{
(ComparisonType comparisonType : values()) {
(range.startsWith(comparisonType.prefix)) {
;
}
}
;
}
}
}
com/hypixel/hytale/common/semver/SemverRange.java
package com.hypixel.hytale.common.semver;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import java.util.Objects;
import java.util.StringJoiner;
import javax.annotation.Nonnull;
public class SemverRange implements SemverSatisfies {
public static final Codec<SemverRange> CODEC;
public static final SemverRange WILDCARD;
private final SemverSatisfies[] comparators;
private final boolean and;
public SemverRange (SemverSatisfies[] comparators, boolean and) {
this .comparators = comparators;
this .and = and;
}
public boolean satisfies (Semver semver) {
if (this .and) {
for (SemverSatisfies comparator : this .comparators) {
if (!comparator.satisfies(semver)) {
return false ;
}
}
return true ;
} else {
for (SemverSatisfies comparator : .comparators) {
(comparator.satisfies(semver)) {
;
}
}
;
}
}
String {
( );
(SemverSatisfies comparator : .comparators) {
joiner.add(comparator.toString());
}
joiner.toString();
}
SemverRange {
fromString(str, );
}
SemverRange {
Objects.requireNonNull(str, );
str = str.trim();
(!str.isBlank() && ! .equals(str)) {
String[] split = str.split( );
SemverSatisfies[] comparators = [split.length];
( ; i < split.length; ++i) {
split[i].trim();
(subRange.contains( )) {
String[] range = subRange.split( );
(range.length != ) {
( );
}
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, Semver.fromString(range[ ], strict)), (SemverComparator.ComparisonType.LTE, Semver.fromString(range[ ], strict))}, );
} (subRange.charAt( ) == ) {
Semver.fromString(subRange.substring( ), strict);
(semver.getMinor() > ) {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, (semver.getMajor(), semver.getMinor() + , , (String[]) , (String) ))}, );
} {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, (semver.getMajor() + , , , (String[]) , (String) ))}, );
}
} (subRange.charAt( ) == ) {
Semver.fromString(subRange.substring( ), strict);
(semver.getMajor() > ) {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, (semver.getMajor() + , , , (String[]) , (String) ))}, );
} (semver.getMinor() > ) {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, ( , semver.getMinor() + , , (String[]) , (String) ))}, );
} {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, ( , , semver.getPatch() + , (String[]) , (String) ))}, );
}
} (SemverComparator.ComparisonType.hasAPrefix(subRange)) {
comparators[i] = SemverComparator.fromString(subRange);
} (!subRange.contains( )) {
Semver.fromString(subRange.replace( , ).replace( , ), strict);
(semver.getPatch() == && semver.getMinor() == && semver.getMajor() == ) {
comparators[i] = (SemverComparator.ComparisonType.GTE, ( , , ));
} (semver.getPatch() == && semver.getMinor() == ) {
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, (semver.getMajor() + , , , (String[]) , (String) ))}, );
} {
(semver.getPatch() != ) {
( + subRange);
}
comparators[i] = ( []{ (SemverComparator.ComparisonType.GTE, semver), (SemverComparator.ComparisonType.LT, (semver.getMajor(), semver.getMinor() + , , (String[]) , (String) ))}, );
}
} {
String[] comparatorStrings = subRange.split( );
SemverSatisfies[] comparatorsAnd = [comparatorStrings.length];
( ; y < comparatorStrings.length; ++y) {
comparatorsAnd[i] = SemverComparator.fromString(comparatorStrings[i]);
}
comparators[i] = (comparatorsAnd, );
}
}
(comparators, );
} {
WILDCARD;
}
}
{
CODEC = (Codec.STRING, SemverRange::fromString, SemverRange::toString);
WILDCARD = ( [ ], );
}
}
com/hypixel/hytale/common/semver/SemverSatisfies.java
package com.hypixel.hytale.common.semver;
public interface SemverSatisfies {
boolean satisfies (Semver var1) ;
}
com/hypixel/hytale/common/thread/HytaleForkJoinThreadFactory.java
package com.hypixel.hytale.common.thread;
import com.hypixel.hytale.metrics.InitStackThread;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
import javax.annotation.Nonnull;
public class HytaleForkJoinThreadFactory implements ForkJoinPool .ForkJoinWorkerThreadFactory {
public HytaleForkJoinThreadFactory () {
}
@Nonnull
public ForkJoinWorkerThread newThread (@Nonnull ForkJoinPool pool) {
return new WorkerThread (pool);
}
public static class WorkerThread extends ForkJoinWorkerThread implements InitStackThread {
@Nonnull
private final StackTraceElement[] initStack = Thread.currentThread().getStackTrace();
protected WorkerThread (@Nonnull ForkJoinPool pool) {
super (pool);
}
@Nonnull
public StackTraceElement[] getInitStack() {
return this .initStack;
}
}
}
com/hypixel/hytale/common/thread/ticking/Tickable.java
package com.hypixel.hytale.common.thread.ticking;
public interface Tickable {
void tick (float var1) ;
}
com/hypixel/hytale/common/tuple/BoolDoublePair.java
package com.hypixel.hytale.common.tuple;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BoolDoublePair implements Comparable <BoolDoublePair> {
private final boolean left;
private final double right;
public BoolDoublePair (boolean left, double right) {
this .left = left;
this .right = right;
}
public final boolean getKey () {
return this .getLeft();
}
public boolean getLeft () {
return this .left;
}
public final double getValue () {
return this .getRight();
}
public double getRight () {
return this .right;
}
public int {
Boolean.compare( .left, other.left);
compare != ? compare : Double.compare( .right, other.right);
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(BoolDoublePair)o;
( .left != that.left) {
;
} {
Double.compare(that.right, .right) == ;
}
} {
;
}
}
{
.left ? : ;
Double.doubleToLongBits( .right);
result = * result + ( )(temp ^ temp >>> );
result;
}
String {
.getLeft();
+ var10000 + + .getRight() + ;
}
String {
String.format(format, .getLeft(), .getRight());
}
BoolDoublePair {
(left, right);
}
}
com/hypixel/hytale/common/tuple/BoolIntPair.java
package com.hypixel.hytale.common.tuple;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BoolIntPair implements Comparable <BoolIntPair> {
private final boolean left;
private final int right;
public BoolIntPair (boolean left, int right) {
this .left = left;
this .right = right;
}
public final boolean getKey () {
return this .getLeft();
}
public boolean getLeft () {
return this .left;
}
public final int getValue () {
return this .getRight();
}
public int getRight () {
return this .right;
}
public int compareTo {
Boolean.compare( .left, other.left);
compare != ? compare : Integer.compare( .right, other.right);
}
{
.left ? : ;
result = * result + .right;
result;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(BoolIntPair)o;
( .left != that.left) {
;
} {
.right == that.right;
}
} {
;
}
}
String {
.getLeft();
+ var10000 + + .getRight() + ;
}
String {
String.format(format, .getLeft(), .getRight());
}
BoolIntPair {
(left, right);
}
}
com/hypixel/hytale/common/util/ArrayUtil.java
package com.hypixel.hytale.common.util;
import com.hypixel.hytale.function.predicate.UnaryBiPredicate;
import com.hypixel.hytale.math.util.MathUtil;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ArrayUtil {
public static final String[] EMPTY_STRING_ARRAY = new String [0 ];
public static final double [] EMPTY_DOUBLE_ARRAY = new double [0 ];
public static final int [] EMPTY_INT_ARRAY = new int [0 ];
public static final long [] EMPTY_LONG_ARRAY = new long [0 ];
public static [] EMPTY_BOOLEAN_ARRAY = [ ];
Integer[] EMPTY_INTEGER_ARRAY = [ ];
[] EMPTY_BYTE_ARRAY = [ ];
BitSet[] EMPTY_BITSET_ARRAY = [ ];
[] EMPTY_FLOAT_ARRAY = [ ];
Object[] EMPTY_OBJECT_ARRAY = [ ];
Supplier[] EMPTY_SUPPLIER_ARRAY = [ ];
Map.Entry[] EMPTY_ENTRY_ARRAY = .Entry[ ];
{
}
<T> T[] emptyArray() {
(T[])EMPTY_OBJECT_ARRAY;
}
<T> Supplier<T>[] emptySupplierArray() {
EMPTY_SUPPLIER_ARRAY;
}
<K, V> Map.Entry<K, V>[] emptyEntryArray() {
EMPTY_ENTRY_ARRAY;
}
{
( )MathUtil.clamp(( )oldSize + ( )(oldSize >> ), , );
}
<StartType, EndType> EndType[] copyAndMutate( StartType[] array, Function<StartType, EndType> adapter, IntFunction<EndType[]> arrayProvider) {
(array == ) {
;
} {
EndType[] endArray = (EndType[])((Object[])arrayProvider.apply(array.length));
( ; i < endArray.length; ++i) {
endArray[i] = adapter.apply(array[i]);
}
endArray;
}
}
<T> T[] combine( T[] a1, T[] a2) {
(a1 != && a1.length != ) {
(a2 != && a2.length != ) {
T[] newArray = (T[])Arrays.copyOf(a1, a1.length + a2.length);
System.arraycopy(a2, , newArray, a1.length, a2.length);
newArray;
} {
a1;
}
} {
a2;
}
}
<T> T[] append( T[] arr, T t) {
(arr == ) {
T[] newArray = (T[])((Object[])Array.newInstance(t.getClass(), ));
newArray[ ] = t;
newArray;
} {
T[] newArray = (T[])Arrays.copyOf(arr, arr.length + );
newArray[arr.length] = t;
newArray;
}
}
<T> T[] remove( T[] arr, index) {
arr.length - ;
T[] newArray = (T[])((Object[])Array.newInstance(arr.getClass().getComponentType(), newLength));
System.arraycopy(arr, , newArray, , index);
(index < newLength) {
System.arraycopy(arr, index + , newArray, index, newLength - index);
}
newArray;
}
{
(start.length > array.length) {
;
} {
( ; i < start.length; ++i) {
(array[i] != start[i]) {
;
}
}
;
}
}
<T> {
(a == a2) {
;
} (a != && a2 != ) {
a.length;
(a2.length != length) {
;
} {
;
( ) {
(i >= length) {
;
}
(T)a[i];
(T)a2[i];
(o1 == ) {
(o2 != ) {
;
}
} (!predicate.test(o1, o2)) {
;
}
++i;
}
;
}
} {
;
}
}
<T> T[][] split( T[] data, size) {
Class<? []> aClass = data.getClass();
T[][] ret = (T[][])((Object[][])Array.newInstance(aClass.getComponentType(), []{MathUtil.ceil(( )data.length / ( )size), }));
;
( ; i < ret.length; ++i) {
ret[i] = Arrays.copyOfRange(data, start, Math.min(start + size, data.length));
start += size;
}
ret;
}
[][] split( [] data, size) {
[][] ret = [MathUtil.ceil(( )data.length / ( )size)][];
;
( ; i < ret.length; ++i) {
ret[i] = Arrays.copyOfRange(data, start, Math.min(start + size, data.length));
start += size;
}
ret;
}
{
Objects.checkFromToIndex(from, to, ar.length);
( to - ; i > from; --i) {
rnd.nextInt(i + - from) + from;
ar[index];
ar[index] = ar[i];
ar[i] = a;
}
}
{
Objects.checkFromToIndex(from, to, ar.length);
( to - ; i > from; --i) {
rnd.nextInt(i + - from) + from;
ar[index];
ar[index] = ar[i];
ar[i] = a;
}
}
<T> {
indexOf(array, obj) >= ;
}
<T> {
indexOf(array, obj, start, end) >= ;
}
<T> {
indexOf(array, obj, , array.length);
}
<T> {
(obj == ) {
( start; i < end; ++i) {
(array[i] == ) {
i;
}
}
} {
( start; i < end; ++i) {
(obj.equals(array[i])) {
i;
}
}
}
- ;
}
}
com/hypixel/hytale/common/util/AudioUtil.java
package com.hypixel.hytale.common.util;
public class AudioUtil {
public static final float MIN_DECIBEL_VOLUME = -100.0F ;
public static final float MAX_DECIBEL_VOLUME = 10.0F ;
public static final float MIN_SEMITONE_PITCH = -12.0F ;
public static final float MAX_SEMITONE_PITCH = 12.0F ;
public AudioUtil () {
}
public static float decibelsToLinearGain (float decibels) {
return decibels <= -100.0F ? 0.0F : (float )Math.pow(10.0 , (double )(decibels / 20.0F ));
}
public static float linearGainToDecibels {
linearGain <= ? - : ( )(Math.log(( )linearGain) / Math.log( ) * );
}
{
( )( / Math.pow( , ( )(-semitones / )));
}
{
( )(Math.log(( )linearPitch) / Math.log( ) * );
}
}
com/hypixel/hytale/common/util/BitSetUtil.java
package com.hypixel.hytale.common.util;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import com.hypixel.hytale.unsafe.UnsafeUtil;
import java.util.BitSet;
import javax.annotation.Nonnull;
public class BitSetUtil {
public static final long WORDS_OFFSET;
public static final long WORDS_IN_USE_OFFSET;
public BitSetUtil () {
}
public static void copyValues (@Nonnull BitSet from, @Nonnull BitSet to) {
if (UnsafeUtil.UNSAFE == null ) {
copyValuesSlow(from, to);
} else {
int wordsInUse = UnsafeUtil.UNSAFE.getInt(from, WORDS_IN_USE_OFFSET);
UnsafeUtil.UNSAFE.putInt(to, WORDS_IN_USE_OFFSET, wordsInUse);
long [] fromWords = (long [])UnsafeUtil.UNSAFE.getObject(from, WORDS_OFFSET);
long [] toWords = (long [])UnsafeUtil.UNSAFE.getObject(to, WORDS_OFFSET);
if (wordsInUse > toWords.length) {
toWords = new long [wordsInUse];
UnsafeUtil.UNSAFE.putObject(to, WORDS_OFFSET, toWords);
}
System.arraycopy(fromWords, 0 , toWords, 0 , wordsInUse);
}
}
{
to.clear();
to.or(from);
}
{
{
(UnsafeUtil.UNSAFE != ) {
WORDS_OFFSET = UnsafeUtil.UNSAFE.objectFieldOffset(BitSet.class.getDeclaredField( ));
WORDS_IN_USE_OFFSET = UnsafeUtil.UNSAFE.objectFieldOffset(BitSet.class.getDeclaredField( ));
} {
WORDS_OFFSET = ;
WORDS_IN_USE_OFFSET = ;
}
} (NoSuchFieldException e) {
SneakyThrow.sneakyThrow(e);
}
}
}
com/hypixel/hytale/common/util/BitUtil.java
package com.hypixel.hytale.common.util;
import javax.annotation.Nonnull;
public class BitUtil {
public BitUtil () {
}
public static void setNibble (@Nonnull byte [] data, int idx, byte b) {
int fieldIdx = idx >> 1 ;
byte val = data[fieldIdx];
b = (byte )(b & 15 );
int i = idx & 1 ;
b = (byte )(b << ((i ^ 1 ) << 2 ));
val = (byte )(val & 15 << (i << 2 ));
val = (byte )(val | b);
data[fieldIdx] = val;
}
public static byte getNibble (@Nonnull byte [] data, int idx) {
int fieldIdx = idx >> 1 ;
byte val = data[fieldIdx];
idx & ;
val = ( )(val >> ((i ^ ) << ));
val = ( )(val & );
val;
}
{
idx >> ;
data[fieldIdx];
idx & ;
( )(val >> ((i ^ ) << ));
oldVal = ( )(oldVal & );
b = ( )(b & );
b = ( )(b << ((i ^ ) << ));
val = ( )(val & << (i << ));
val = ( )(val | b);
data[fieldIdx] = val;
oldVal;
}
}
com/hypixel/hytale/common/util/CompletableFutureUtil.java
package com.hypixel.hytale.common.util;
import com.hypixel.hytale.logger.HytaleLogger;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class CompletableFutureUtil {
public static final Function<Throwable, ?> fn = (throwable) -> {
if (!(throwable instanceof TailedRuntimeException)) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(throwable)).log("Unhandled exception! " + String.valueOf(Thread.currentThread()));
}
throw new TailedRuntimeException (throwable);
};
public CompletableFutureUtil () {
}
@Nonnull
public static <T> CompletableFuture<T> whenComplete (@Nonnull CompletableFuture<T> future, @Nonnull CompletableFuture<T> callee) {
return future.whenComplete((result, throwable) -> {
if (throwable != null ) {
callee.completeExceptionally(throwable);
} else {
callee.complete(result);
}
});
}
public {
throwable CancellationException || throwable CompletionException && throwable.getCause() != && throwable.getCause() != throwable && isCanceled(throwable.getCause());
}
<T> CompletableFuture<T> {
future.exceptionally(fn);
}
<T> CompletableFuture<T> {
CompletableFuture<T> out = ();
out.cancel( );
out;
}
InterruptedException {
CompletableFuture<?> all = CompletableFuture.allOf((CompletableFuture[])list.toArray((x$ ) -> [x$ ]));
System.nanoTime();
TimeUnit.MILLISECONDS.toNanos(( )millisProgress);
list.size();
(!all.isDone()) {
Thread.sleep(( )millisSleep);
now;
(last + nanosProgress < (now = System.nanoTime())) {
last = now;
;
(CompletableFuture c : list) {
(c.isDone()) {
++done;
}
}
(done < listSize) {
callback.accept(( )done / ( )listSize, done, listSize);
}
}
}
callback.accept( , listSize, listSize);
all.join();
}
{
{
(cause);
}
}
{
;
}
}
com/hypixel/hytale/common/util/ExceptionUtil.java
package com.hypixel.hytale.common.util;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.annotation.Nonnull;
public class ExceptionUtil {
public ExceptionUtil () {
}
@Nonnull
public static String combineMessages (Throwable thrown, @Nonnull String joiner) {
StringBuilder sb = new StringBuilder ();
for (Throwable throwable = thrown; throwable != null ; throwable = throwable.getCause()) {
if (throwable.getCause() == throwable) {
return sb.toString();
}
if (throwable.getMessage() != null ) {
sb.append(throwable.getMessage()).append(joiner);
}
}
sb.setLength(sb.length() - joiner.length());
return sb.toString();
}
public static String toStringWithStack (@Nonnull Throwable t) {
try {
StringWriter out = new StringWriter ();
String var2;
{
t.printStackTrace( (out));
var2 = out.toString();
} (Throwable var5) {
{
out.close();
} (Throwable var4) {
var5.addSuppressed(var4);
}
var5;
}
out.close();
var2;
} (IOException var6) {
t.toString();
}
}
}
package com.hypixel.hytale.common.util;
import com.hypixel.hytale.metrics.metric.Metric;
import java.util.EnumMap;
import java.util.Formatter;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.DoubleUnaryOperator;
import javax.annotation.Nonnull;
public class FormatUtil {
private static final String[] NUMBER_SUFFIXES = new String []{"th" , "st" , "nd" , "rd" , "th" , "th" , "th" , "th" , "th" , "th" };
private static final EnumMap<TimeUnit, String> timeUnitToShortString = new EnumMap <TimeUnit, String>(TimeUnit.class) {
{
this .put(TimeUnit.DAYS, "days" );
this .put(TimeUnit.HOURS, "hours" );
this .put(TimeUnit.MINUTES, "min" );
this .put(TimeUnit.SECONDS, "s" );
this .put(TimeUnit.MILLISECONDS, "ms" );
this .put(TimeUnit.MICROSECONDS, "us" );
this .put(TimeUnit.NANOSECONDS, );
}
};
DAY_AS_NANOS;
HOUR_AS_NANOS;
MINUTE_AS_NANOS;
SECOND_AS_NANOS;
MILLISECOND_AS_NANOS;
MICOSECOND_AS_NANOS;
{
}
TimeUnit {
unit.toNanos(value);
(nanos > DAY_AS_NANOS) {
TimeUnit.DAYS;
} (nanos > HOUR_AS_NANOS) {
TimeUnit.HOURS;
} (nanos > MINUTE_AS_NANOS) {
TimeUnit.MINUTES;
} (nanos > SECOND_AS_NANOS) {
TimeUnit.SECONDS;
} (nanos > MILLISECOND_AS_NANOS) {
TimeUnit.MILLISECONDS;
} {
nanos > MICOSECOND_AS_NANOS ? TimeUnit.MICROSECONDS : TimeUnit.NANOSECONDS;
}
}
String {
largestUnit(Math.round(metric.getAverage()), timeUnit);
simpleTimeUnitFormat(metric, timeUnit, largestUnit, rounding);
}
String {
metric.getMin();
metric.getAverage();
metric.getMax();
simpleTimeUnitFormat(min, average, max, timeUnit, largestUnit, rounding);
}
String {
( )Math.pow( , ( )rounding);
Math.round(Math.max(Math.abs(average - ( )min), Math.abs(( )max - average)));
largestUnit.convert(Math.round(average * ( )roundValue), timeUnit);
largestUnit.convert(range * ( )roundValue, timeUnit);
(String)timeUnitToShortString.get(largestUnit);
( )averageNanos / ( )roundValue + unitStr + + ( )rangeNanos / ( )roundValue + unitStr;
}
String {
( )Math.pow( , ( )rounding);
largestUnit(value, timeUnit);
largestUnit.convert(value * ( )roundValue, timeUnit);
(String)timeUnitToShortString.get(largestUnit);
( )averageNanos / ( )roundValue + unitStr;
}
String {
doubleFunction.applyAsDouble(average1);
Math.abs(average - doubleFunction.applyAsDouble(( )min1));
Math.abs(doubleFunction.applyAsDouble(( )max1) - average);
Math.max(min, max);
simpleFormat(rounding, average, range);
}
String {
simpleFormat(metric, );
}
String {
metric.getAverage();
Math.abs(average - ( )metric.getMin());
Math.abs(( )metric.getMax() - average);
Math.max(min, max);
simpleFormat(rounding, average, range);
}
String {
( )Math.pow( , ( )rounding);
( )(( )(average * ( )roundValue)) / ( )roundValue + + ( )(( )(range * ( )roundValue)) / ( )roundValue;
}
String {
Math.abs(metric.getAverage() - ( )metric.getMin());
Math.abs(( )metric.getMax() - metric.getAverage());
Math.round(Math.max(min, max));
timeUnitToString(Math.round(metric.getAverage()), timeUnit);
var10000 + + timeUnitToString(range, timeUnit);
}
String {
timeUnitToString(value, timeUnit, );
}
String {
;
();
(value);
p |= timeToStringPart(time, sb, p, timeUnit, TimeUnit.DAYS, , , paddingBetween);
timeToStringPart(time, sb, p, timeUnit, TimeUnit.HOURS, , , paddingBetween);
p |= hasHours;
p |= timeToStringPart(time, sb, p, timeUnit, TimeUnit.MINUTES, hasHours ? : , , paddingBetween);
p |= timeToStringPart(time, sb, p, timeUnit, TimeUnit.SECONDS, hasHours ? : , !hasHours, paddingBetween);
p |= timeToStringPart(time, sb, p, timeUnit, TimeUnit.MILLISECONDS, , , paddingBetween);
p |= timeToStringPart(time, sb, p, timeUnit, TimeUnit.MICROSECONDS, , , paddingBetween);
p | timeToStringPart(time, sb, p, timeUnit, TimeUnit.NANOSECONDS, , , paddingBetween);
sb.toString();
}
String {
timeUnitToString(nanos, TimeUnit.NANOSECONDS);
}
{
(timeUnitFrom.ordinal() > timeUnitTo.ordinal()) {
;
} {
timeUnitTo.convert(time.get(), timeUnitFrom);
time.getAndAdd(-timeUnitFrom.convert(timeInUnitTo, timeUnitTo));
(timeInUnitTo > || previous && time.get() > || !previous && timeUnitFrom == timeUnitTo) {
(paddingBefore && previous) {
sb.append( );
}
sb.append(timeInUnitTo);
(paddingBetween) {
sb.append( );
}
sb.append(after);
;
} {
;
}
}
}
String {
bytesToString(bytes, );
}
String {
si ? : ;
(bytes < ( )unit) {
bytes + ;
} {
( )(Math.log(( )bytes) / Math.log(( )unit));
Object[] var10001 = []{( )bytes / Math.pow(( )unit, ( )exp), };
(si ? : ).charAt(exp - );
var10001[ ] = var10004 + (si ? : );
String.format( , var10001);
}
}
String {
String var10000;
(i % ) {
:
:
:
var10000 = i + ;
;
:
var10000 = i + NUMBER_SUFFIXES[i % ];
}
var10000;
}
{
(Object arg : args) {
formatter.format(format, arg);
}
}
{
formatArray(formatter, format, args);
}
{
DAY_AS_NANOS = TimeUnit.DAYS.toNanos( );
HOUR_AS_NANOS = TimeUnit.HOURS.toNanos( );
MINUTE_AS_NANOS = TimeUnit.MINUTES.toNanos( );
SECOND_AS_NANOS = TimeUnit.SECONDS.toNanos( );
MILLISECOND_AS_NANOS = TimeUnit.MILLISECONDS.toNanos( );
MICOSECOND_AS_NANOS = TimeUnit.MICROSECONDS.toNanos( );
}
}
com/hypixel/hytale/common/util/GCUtil.java
package com.hypixel.hytale.common.util;
import com.sun.management.GarbageCollectionNotificationInfo;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.openmbean.CompositeData;
public class GCUtil {
public GCUtil () {
}
public static void register (@Nonnull Consumer<GarbageCollectionNotificationInfo> consumer) {
for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) {
NotificationEmitter emitter = (NotificationEmitter)gcBean;
emitter.addNotificationListener((notification, handback) -> {
if (notification.getType().equals("com.sun.management.gc.notification" )) {
GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData)notification.getUserData());
consumer.accept(info);
}
}, (NotificationFilter)null , (Object)null );
}
}
}
com/hypixel/hytale/common/util/HardwareUtil.java
package com.hypixel.hytale.common.util;
import com.hypixel.hytale.function.supplier.SupplierUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
public class HardwareUtil {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
private static final int PROCESS_TIMEOUT_SECONDS = 2 ;
private static final Pattern UUID_PATTERN = Pattern.compile("([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})" );
private static final Supplier<UUID> WINDOWS = SupplierUtil.<UUID>cache(() -> {
String output = runCommand("reg" , "query" , , , );
(output != ) {
(String line : output.split( )) {
(line.contains( )) {
UUID_PATTERN.matcher(line);
(matcher.find()) {
UUID.fromString(matcher.group( ));
}
}
}
}
output = runCommand( , , , );
(output != ) {
parseUuidFromOutput(output);
(uuid != ) {
uuid;
}
}
output = runCommand( , , , );
(output != ) {
parseUuidFromOutput(output);
(uuid != ) {
uuid;
}
}
( );
});
Supplier<UUID> MAC = SupplierUtil.<UUID>cache(() -> {
runCommand( , , , );
(output != ) {
(String line : output.split( )) {
(line.contains( )) {
UUID_PATTERN.matcher(line);
(matcher.find()) {
UUID.fromString(matcher.group( ));
}
}
}
}
output = runCommand( , );
(output != ) {
(String line : output.split( )) {
(line.contains( )) {
UUID_PATTERN.matcher(line);
(matcher.find()) {
UUID.fromString(matcher.group( ));
}
}
}
}
( );
});
Supplier<UUID> LINUX = SupplierUtil.<UUID>cache(() -> {
readMachineIdFile(Path.of( ));
(machineId != ) {
machineId;
} {
machineId = readMachineIdFile(Path.of( ));
(machineId != ) {
machineId;
} {
{
Path.of( );
(Files.isReadable(path)) {
Files.readString(path, StandardCharsets.UTF_8).trim();
(!content.isEmpty()) {
UUID.fromString(content);
}
}
} (Exception var3) {
}
runCommand( , , );
(output != ) {
parseUuidFromOutput(output);
(uuid != ) {
uuid;
}
}
( );
}
}
});
{
}
String {
{
( (command)).start();
(process.waitFor( , TimeUnit.SECONDS)) {
( (process.getInputStream().readAllBytes(), StandardCharsets.UTF_8)).trim();
}
process.destroyForcibly();
} (Exception var2) {
}
;
}
UUID {
UUID_PATTERN.matcher(output);
matcher.find() ? UUID.fromString(matcher.group( )) : ;
}
UUID {
{
(!Files.isReadable(path)) {
;
} {
Files.readString(path, StandardCharsets.UTF_8).trim();
(!content.isEmpty() && content.length() == ) {
content.substring( , );
UUID.fromString(var10000 + + content.substring( , ) + + content.substring( , ) + + content.substring( , ) + + content.substring( , ));
} {
;
}
}
} (Exception var2) {
;
}
}
UUID {
{
UUID var10000;
(SystemUtil.TYPE) {
WINDOWS -> var10000 = (UUID)WINDOWS.get();
LINUX -> var10000 = (UUID)LINUX.get();
MACOS -> var10000 = (UUID)MAC.get();
OTHER -> ( );
-> ((String) , (Throwable) );
}
var10000;
} (Exception e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( );
;
}
}
}
com/hypixel/hytale/common/util/ListUtil.java
package com.hypixel.hytale.common.util;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
public class ListUtil {
public ListUtil () {
}
@Nonnull
public static <T> List<List<T>> partition (@Nonnull List<T> list, int sectionSize) {
List<List<T>> sections = new ObjectArrayList <List<T>>();
for (int i = 0 ; i < list.size(); i += sectionSize) {
int endIndex = Math.min(list.size(), i + sectionSize);
sections.add(list.subList(i, endIndex));
}
return sections;
}
public static <T> void removeIf (@Nonnull List<T> list, @Nonnull Predicate<T> predicate) {
for (int i = list.size() - 1 ; i >= 0 ; --i) {
(predicate.test(list.get(i))) {
list.remove(i);
}
}
}
<T, U> {
( list.size() - ; i >= ; --i) {
(predicate.test(list.get(i), obj)) {
list.remove(i);
}
}
}
<T> {
( ; i < list.size(); ++i) {
(T)list.get(i);
(e != ) {
;
}
}
;
}
<T, V> {
;
l.size() - ;
(low <= high) {
low + high >>> ;
(T)l.get(mid);
c.compare(func.apply(midVal), key);
(cmp < ) {
low = mid + ;
} {
(cmp <= ) {
mid;
}
high = mid - ;
}
}
-(low + );
}
}
com/hypixel/hytale/common/util/MapUtil.java
package com.hypixel.hytale.common.util;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Collections;
import java.util.Map;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public class MapUtil {
public MapUtil () {
}
@Nonnull
public static <T, V> Map<T, V> combineUnmodifiable (@Nonnull Map<T, V> one, @Nonnull Map<T, V> two) {
Map<T, V> map = new Object2ObjectOpenHashMap <T, V>();
map.putAll(one);
map.putAll(two);
return Collections.unmodifiableMap(map);
}
@Nonnull
public static <T, V, M extends Map <T, V>> Map<T, V> combineUnmodifiable (@Nonnull Map<T, V> one, @Nonnull Map<T, V> two, @Nonnull Supplier<M> supplier) {
Map<T, V> map = (Map)supplier.get();
map.putAll(one);
map.putAll(two);
return Collections.unmodifiableMap(map);
}
@Nonnull
public static <T, V, M extends Map <T, V>> M combine (@Nonnull Map<T, V> one, @Nonnull Map<T, V> two, Supplier<M> supplier) {
(M)(supplier.get());
map.putAll(one);
map.putAll(two);
map;
}
}
com/hypixel/hytale/common/util/NetworkUtil.java
package com.hypixel.hytale.common.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Enumeration;
import java.util.Locale;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class NetworkUtil {
public static Inet6Address ANY_IPV6_ADDRESS;
public static Inet4Address ANY_IPV4_ADDRESS;
public static Inet6Address LOOPBACK_IPV6_ADDRESS;
public static Inet4Address LOOPBACK_IPV4_ADDRESS;
public NetworkUtil () {
}
@Nullable
public static InetAddress getFirstNonLoopbackAddress () throws SocketException {
InetAddress firstInet6Address ;
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
(networkInterfaces.hasMoreElements()) {
(NetworkInterface)networkInterfaces.nextElement();
(!networkInterface.isLoopback() && networkInterface.isUp()) {
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
(inetAddresses.hasMoreElements()) {
(InetAddress)inetAddresses.nextElement();
(!inetAddress.isLoopbackAddress() && !inetAddress.isAnyLocalAddress() && !inetAddress.isLinkLocalAddress()) {
(inetAddress Inet4Address) {
inetAddress;
}
(inetAddress Inet6Address && firstInet6Address == ) {
firstInet6Address = inetAddress;
}
}
}
}
}
firstInet6Address;
}
InetAddress SocketException {
getFirstAddressWith(include, (AddressType[]) );
}
InetAddress SocketException {
getFirstAddressWith((AddressType[]) , include);
}
InetAddress SocketException {
;
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
(networkInterfaces.hasMoreElements()) {
(NetworkInterface)networkInterfaces.nextElement();
(!networkInterface.isLoopback() && networkInterface.isUp()) {
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
label70:
(inetAddresses.hasMoreElements()) {
(InetAddress)inetAddresses.nextElement();
(include != ) {
(AddressType addressType : include) {
(!addressType.predicate.test(inetAddress)) {
label70;
}
}
}
(exclude != ) {
(AddressType addressType : exclude) {
(addressType.predicate.test(inetAddress)) {
label70;
}
}
}
(inetAddress Inet4Address) {
inetAddress;
}
(inetAddress Inet6Address && firstInet6Address == ) {
firstInet6Address = inetAddress;
}
}
}
}
firstInet6Address;
}
{
(AddressType type : types) {
(!type.predicate.test(address)) {
;
}
}
;
}
{
addressMatchesAny(address, NetworkUtil.AddressType.values());
}
{
(AddressType type : types) {
(type.predicate.test(address)) {
;
}
}
;
}
String {
String str;
(address.getAddress() Inet6Address) {
address.getHostString();
(host.indexOf( ) >= ) {
str = + host + ;
} {
str = host;
}
str = str + + address.getPort();
} {
address.getHostString();
str = var10000 + + address.getPort();
}
str;
}
String {
;
{
InetAddress.getLocalHost();
localhost = localHost.getHostName();
(isAcceptableHostName(localhost)) {
localhost;
}
localHost.getCanonicalHostName();
(isAcceptableHostName(hostName)) {
hostName;
}
} (UnknownHostException var10) {
}
System.getenv( );
(isAcceptableHostName(hostName)) {
hostName;
} {
hostName = System.getenv( );
(isAcceptableHostName(hostName)) {
hostName;
} {
hostName = firstLineIfExists( );
(isAcceptableHostName(hostName)) {
hostName;
} {
hostName = firstLineIfExists( );
(isAcceptableHostName(hostName)) {
hostName;
} {
{
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
(en.hasMoreElements()) {
(NetworkInterface)en.nextElement();
(ni.isUp() && !ni.isLoopback() && !ni.isPointToPoint()) {
ni.getName().toLowerCase(Locale.ROOT);
(!name.startsWith( ) && !name.startsWith( ) && !name.startsWith( ) && !name.startsWith( ) && !name.startsWith( ) && !name.startsWith( ) && !name.startsWith( ) && !name.startsWith( )) {
Enumeration<InetAddress> e = ni.getInetAddresses();
(e.hasMoreElements()) {
(InetAddress)e.nextElement();
(!a.isLoopbackAddress() && !a.isLinkLocalAddress() && !a.isAnyLocalAddress()) {
a.getHostAddress();
a.getHostName();
(addressHostName != && !addressHostName.equals(hostAddress) && isAcceptableHostName(addressHostName)) {
addressHostName;
}
a.getCanonicalHostName();
(canonicalHostName != && !canonicalHostName.equals(hostAddress) && isAcceptableHostName(canonicalHostName)) {
canonicalHostName;
}
}
}
}
}
}
} (SocketException var11) {
}
;
}
}
}
}
}
String {
{
Path.of(path);
(!Files.isRegularFile(p, [ ])) {
;
} {
Files.newBufferedReader(p, StandardCharsets.UTF_8);
String var4;
{
reader.readLine();
var4 = line == ? : line.trim();
} (Throwable var6) {
(reader != ) {
{
reader.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(reader != ) {
reader.close();
}
var4;
}
} (IOException var7) {
;
}
}
{
(name == ) {
;
} {
name = name.trim();
(name.isEmpty()) {
;
} {
name.toLowerCase(Locale.ROOT);
(!isIPv4Literal(lower) && !isLikelyIPv6Literal(lower)) {
(! .equals(lower) && ! .equals(lower) && ! .equals(lower) && ! .equals(lower)) {
(!lower.contains( ) && !lower.contains( ) && !lower.endsWith( ) && !lower.endsWith( )) {
!lower.endsWith( );
} {
;
}
} {
;
}
} {
;
}
}
}
}
{
;
- ;
;
( ; i < name.length(); ++i) {
name.charAt(i);
(ch >= && ch <= ) {
(octet == - ) {
octet = ;
}
val = val * + (ch - );
(val > ) {
;
}
++octet;
(octet > ) {
;
}
} {
(ch != ) {
;
}
(octet <= ) {
;
}
++dots;
octet = - ;
val = ;
(dots > ) {
;
}
}
}
dots == && octet > ;
}
{
;
( ; i < name.length(); ++i) {
name.charAt(i);
(ch == ) {
colon = ;
} ((ch < || ch > ) && (ch < || ch > ) && (ch < || ch > )) {
;
}
}
colon;
}
{
{
ANY_IPV6_ADDRESS = Inet6Address.getByAddress( , [ ], (NetworkInterface) );
ANY_IPV4_ADDRESS = (Inet4Address)Inet4Address.getByAddress( , [ ]);
LOOPBACK_IPV6_ADDRESS = Inet6Address.getByAddress( , []{ , , , , , , , , , , , , , , , }, (NetworkInterface) );
LOOPBACK_IPV4_ADDRESS = (Inet4Address)Inet4Address.getByAddress( , []{ , , , });
} (UnknownHostException e) {
(e);
}
}
{
MULTICAST(InetAddress::isMulticastAddress),
ANY_LOCAL(InetAddress::isAnyLocalAddress),
LOOPBACK(InetAddress::isLoopbackAddress),
LINK_LOCAL(InetAddress::isLinkLocalAddress),
SITE_LOCAL(InetAddress::isSiteLocalAddress),
MC_GLOBAL(InetAddress::isMCGlobal),
MC_SITE_LOCAL(InetAddress::isMCSiteLocal),
MC_ORG_LOCAL(InetAddress::isMCOrgLocal);
Predicate<InetAddress> predicate;
{
.predicate = predicate;
}
}
}
com/hypixel/hytale/common/util/PathUtil.java
package com.hypixel.hytale.common.util;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PathUtil {
private static final Pattern PATH_PATTERN = Pattern.compile("[\\\\/]" );
public PathUtil () {
}
@Nonnull
public static Path getParent (@Nonnull Path path) {
if (path.isAbsolute()) {
return path.getParent().normalize();
} else {
Path parentAbsolute = path.toAbsolutePath().getParent();
Path parent = path.resolve(relativize(path, parentAbsolute));
return parent.normalize();
}
}
@Nonnull
public static Path relativize {
pathA.toAbsolutePath();
pathB.toAbsolutePath();
Objects.equals(absolutePathA.getRoot(), absolutePathB.getRoot()) ? absolutePathA.normalize().relativize(absolutePathB.normalize()).normalize() : absolutePathB.normalize();
}
Path {
pathA.toAbsolutePath().normalize();
pathB.toAbsolutePath().normalize();
getUserHome().toAbsolutePath();
(Objects.equals(absoluteUserHome.getRoot(), absolutePathB.getRoot())) {
absoluteUserHome.relativize(absolutePathB).normalize();
(Objects.equals(absolutePathA.getRoot(), absolutePathB.getRoot())) {
absolutePathA.relativize(absolutePathB).normalize();
relativizedHome.getNameCount() < relativized.getNameCount() ? Paths.get( ).resolve(relativizedHome) : relativized;
} {
relativizedHome.getNameCount() < absolutePathB.getNameCount() ? Paths.get( ).resolve(relativizedHome) : absolutePathB;
}
} {
Objects.equals(absolutePathA.getRoot(), absolutePathB.getRoot()) ? absolutePathA.relativize(absolutePathB).normalize() : absolutePathB;
}
}
Path {
get(Paths.get(path));
}
Path {
path.toString().charAt( ) == ? getUserHome().resolve(path.subpath( , path.getNameCount())).normalize() : path.normalize();
}
Path {
Paths.get(System.getProperty( ));
}
String {
String[] pathContents = PATH_PATTERN.split(extUrl.getPath());
pathContents[pathContents.length - ];
fileName.isEmpty() && pathContents.length > ? pathContents[pathContents.length - ] : fileName;
}
{
child.toAbsolutePath().normalize().startsWith(parent.toAbsolutePath().normalize());
}
{
path.toAbsolutePath();
(Files.isRegularFile(parent, [ ])) {
parent = parent.getParent();
}
(parent != ) {
{
consumer.accept(parent);
} ((parent = parent.getParent()) != && (limit == || isChildOf(limit, parent)));
}
}
String {
path.getFileName().toString();
fileName.lastIndexOf( );
index == - ? : fileName.substring(index);
}
String {
.equals(path.getFileSystem().getSeparator()) ? path.toString().replace( , ) : path.toString();
}
}
com/hypixel/hytale/common/util/PatternUtil.java
package com.hypixel.hytale.common.util;
import javax.annotation.Nonnull;
public class PatternUtil {
public PatternUtil () {
}
@Nonnull
public static String replaceBackslashWithForwardSlash (@Nonnull String name) {
return name.replace("\\" , "/" );
}
}
com/hypixel/hytale/common/util/RandomUtil.java
package com.hypixel.hytale.common.util;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class RandomUtil {
public static final ThreadLocal<SecureRandom> SECURE_RANDOM = ThreadLocal.withInitial(SecureRandom::new );
public RandomUtil () {
}
public static <T> T roll (int roll, T[] data, @Nonnull int [] chances) {
++roll;
int lower = 0 ;
int upper = 0 ;
for (int i = 0 ; i < chances.length; ++i) {
int thisOne = chances[i];
upper += thisOne;
if (roll > lower && roll <= upper) {
return (T)data[i];
}
lower += thisOne;
}
throw new AssertionError ( + roll + + Arrays.toString(data) + + Arrays.toString(chances) + );
}
{
++roll;
;
;
( ; i < chances.length; ++i) {
chances[i];
upper += thisOne;
(roll > lower && roll <= upper) {
data[i];
}
lower += thisOne;
}
( + roll + + Arrays.toString(data) + + Arrays.toString(chances) + );
}
SecureRandom {
(SecureRandom)SECURE_RANDOM.get();
}
<T> T {
(T)arr[random.nextInt(arr.length)];
}
<T> T {
random.nextInt(arr.length + );
(T)(index == arr.length ? : arr[index]);
}
<T> T {
(T)selectRandom(list, ThreadLocalRandom.current());
}
<T> T {
(T)list.get(random.nextInt(list.size()));
}
}
com/hypixel/hytale/common/util/StringCompareUtil.java
package com.hypixel.hytale.common.util;
import java.util.Locale;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class StringCompareUtil {
public StringCompareUtil () {
}
public static int indexOfDifference (@Nullable CharSequence cs1, @Nullable CharSequence cs2) {
if (cs1 == cs2) {
return -1 ;
} else if (cs1 != null && cs2 != null ) {
int i;
for (i = 0 ; i < cs1.length() && i < cs2.length() && cs1.charAt(i) == cs2.charAt(i); ++i) {
}
return i >= cs2.length() && i >= cs1.length() ? -1 : i;
} else {
return 0 ;
}
}
public static int getFuzzyDistance (@Nonnull CharSequence term, @Nonnull CharSequence query, @Nonnull Locale locale) {
if (term != null && query != null ) {
if (locale == null ) {
( );
} {
term.toString().toLowerCase(locale);
query.toString().toLowerCase(locale);
;
;
- ;
( ; queryIndex < queryLowerCase.length(); ++queryIndex) {
queryLowerCase.charAt(queryIndex);
( ; termIndex < termLowerCase.length() && !termCharacterMatchFound; ++termIndex) {
termLowerCase.charAt(termIndex);
(queryChar == termChar) {
++score;
(previousMatchingCharacterIndex + == termIndex) {
score += ;
}
previousMatchingCharacterIndex = termIndex;
termCharacterMatchFound = ;
}
}
}
score;
}
} {
( );
}
}
{
(s != && t != ) {
s.length();
t.length();
(n == ) {
m;
} (m == ) {
n;
} {
(n > m) {
s;
s = t;
t = tmp;
n = m;
m = tmp.length();
}
[] p = [n + ];
( ; i <= n; p[i] = i++) {
}
( ; j <= m; ++j) {
p[ ];
t.charAt(j - );
p[ ] = j;
( ; var12 <= n; ++var12) {
p[var12];
s.charAt(var12 - ) == t_j ? : ;
p[var12] = Math.min(Math.min(p[var12 - ] + , p[var12] + ), upper_left + cost);
upper_left = upper;
}
}
p[n];
}
} {
( );
}
}
}
com/hypixel/hytale/common/util/StringUtil.java
package com.hypixel.hytale.common.util;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.function.DoubleFunction;
import java.util.function.IntToDoubleFunction;
import java.util.function.IntToLongFunction;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class StringUtil {
public static final Pattern RAW_ARGS_PATTERN = Pattern.compile(" -- " );
@Nonnull
private static final char [] GRAPH_CHARS = new char []{'_' , '▄' , '─' , '▀' , '¯' };
public StringUtil () {
}
public {
( ; i < str.length(); ++i) {
str.charAt(i);
(c < || c > ) {
;
}
}
;
}
{
( ; i < str.length(); ++i) {
str.charAt(i);
((c < || c > || c > && c < || c > && c < ) && c != ) {
;
}
}
;
}
{
( ; i < str.length(); ++i) {
str.charAt(i);
((c < || c > || c > && c < || c > && c < ) && c != && c != ) {
;
}
}
;
}
{
;
( ; i < keyStr.length(); ++i) {
keyStr.charAt(i);
(wasDelimOrFirst && c != Character.toUpperCase(c)) {
;
}
wasDelimOrFirst = c == delim;
}
;
}
String {
;
();
( ; i < keyStr.length(); ++i) {
keyStr.charAt(i);
sb.append(wasDelimOrFirst ? Character.toUpperCase(c) : c);
wasDelimOrFirst = c == delim;
}
sb.toString();
}
<V <V>> V {
(V)parseEnum(enumConstants, str, StringUtil.MatchType.EQUALS);
}
<V <V>> V {
(matchType == StringUtil.MatchType.EQUALS) {
(V enumValue : enumConstants) {
(enumValue.name().equals(str)) {
enumValue;
}
}
} (matchType == StringUtil.MatchType.CASE_INSENSITIVE) {
(V enumValue : enumConstants) {
(enumValue.name().equalsIgnoreCase(str)) {
enumValue;
}
}
} {
str = str.toLowerCase();
;
- ;
(V enumValue : enumConstants) {
StringCompareUtil.indexOfDifference(str, enumValue.name().toLowerCase());
(index > diff && diff != - || index == - || diff == - ) {
closest = enumValue;
diff = index;
}
}
(diff > - ) {
closest;
}
}
;
}
String[] parseArgs(String rawString, Map<String, String> argOptions) {
String[] rawSplit = RAW_ARGS_PATTERN.split(rawString, );
rawSplit[ ];
rawSplit.length > ;
;
;
List<String> argsList = <String>();
( ; i < argsStr.length(); ++i) {
argsStr.charAt(i);
(c) {
:
(quote == ) {
(start != i) {
argsList.add(argsStr.substring(start, i));
}
start = i + ;
}
;
:
(quote) {
:
quote = ;
;
:
quote = ;
argsList.add(argsStr.substring(start, i + ));
start = i + ;
:
;
}
:
(quote) {
:
quote = ;
;
:
quote = ;
argsList.add(argsStr.substring(start, i + ));
start = i + ;
:
;
}
:
(i + >= argsStr.length()) {
( + (i + ) + + rawString);
}
argsStr.charAt(i + );
(c1) {
:
:
:
argsStr.substring( , i);
argsStr = var10000 + argsStr.substring(i + );
++i;
;
:
( + c1 + + (i + ) + + rawString);
}
}
}
(quote != ) {
( );
} {
(start != argsStr.length()) {
argsList.add(argsStr.substring(start));
}
argsList.removeIf((arg) -> {
(arg.startsWith( )) {
String[] split = arg.substring( ).split( , );
;
(split.length > ) {
value = split[ ];
value = removeQuotes(value);
}
argOptions.put(split[ ], value);
;
} {
;
}
});
argsList.replaceAll((value) -> removeQuotes(value.trim()));
(hasRaw) {
String[] strings = [argsList.size() + ];
argsList.toArray(strings);
strings[argsList.size()] = rawSplit[ ].trim();
strings;
} {
(String[])argsList.toArray((x$ ) -> [x$ ]);
}
}
}
String[] parseArgs(String rawString) {
String[] rawSplit = RAW_ARGS_PATTERN.split(rawString, );
rawSplit[ ];
rawSplit.length > ;
;
;
List<String> argsList = <String>();
( ; i < argsStr.length(); ++i) {
argsStr.charAt(i);
(c) {
:
(quote == ) {
(start != i) {
argsList.add(argsStr.substring(start, i));
}
start = i + ;
}
;
:
(quote) {
:
quote = ;
;
:
quote = ;
argsList.add(argsStr.substring(start, i + ));
start = i + ;
:
;
}
:
(quote) {
:
quote = ;
;
:
quote = ;
argsList.add(argsStr.substring(start, i + ));
start = i + ;
:
;
}
:
(i + >= argsStr.length()) {
( + (i + ) + + rawString);
}
argsStr.charAt(i + );
(c1) {
:
:
:
argsStr.substring( , i);
argsStr = var10000 + argsStr.substring(i + );
++i;
;
:
( + c1 + + (i + ) + + rawString);
}
}
}
(quote != ) {
( );
} {
(start != argsStr.length()) {
argsList.add(argsStr.substring(start));
}
argsList.replaceAll((value) -> removeQuotes(value.trim()));
(hasRaw) {
String[] strings = [argsList.size() + ];
argsList.toArray(strings);
strings[argsList.size()] = rawSplit[ ].trim();
strings;
} {
(String[])argsList.toArray((x$ ) -> [x$ ]);
}
}
}
String {
(value.charAt( )) {
:
:
value = value.substring( , value.length() - );
:
value;
}
}
String {
(s.length() >= ) {
s.charAt( );
s.charAt(s.length() - );
(first == && last == || first == && last == ) {
s.substring( , s.length() - );
}
}
s;
}
{
pattern.equals(text) || isGlobMatching(pattern, , text, );
}
{
(patternPos < pattern.length()) {
pattern.charAt(patternPos);
(charAt == ) {
++patternPos;
(patternPos < pattern.length() && pattern.charAt(patternPos) == ) {
++patternPos;
}
(patternPos == pattern.length()) {
;
}
( pattern.charAt(patternPos); textPos < text.length(); ++textPos) {
(matchChar == text.charAt(textPos) && isGlobMatching(pattern, patternPos + , text, textPos + )) {
;
}
}
;
}
(textPos == text.length()) {
;
}
(charAt != && charAt != text.charAt(textPos)) {
;
}
++patternPos;
++textPos;
}
textPos == text.length();
}
{
( ; i < text.length(); ++i) {
text.charAt(i);
(c == || c == ) {
;
}
}
;
}
String {
duration.toMillis();
length / ;
(length - days * ) / ;
(length - (days * + hours * )) / ;
days + + hours + + minutes + ;
(useSeconds) {
(length - (days * + hours * + minutes * )) / ;
base = base + + seconds + ;
}
base;
}
String {
humanizeTime(length, );
}
<T> List<T> {
List<T> list = sortByFuzzyDistance(str, collection);
list.size() > length ? list.subList( , length) : list;
}
<T> List<T> {
Object2IntMap<T> map = <T>(collection.size());
(T value : collection) {
map.put(value, StringCompareUtil.getFuzzyDistance(value.toString(), str, Locale.ENGLISH));
}
List<T> list = <T>(collection);
Objects.requireNonNull(map);
list.sort(Comparator.comparingInt(map::getInt).reversed());
list;
}
String {
[] buf = []{ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
Integer.numberOfLeadingZeros(val);
- leadingZeros;
Math.max(mag, );
{
--pos;
buf[leadingZeros + pos] = ( )( + (val & ));
val >>>= ;
} (pos > );
(buf, );
}
String {
!str.endsWith(end) ? str : str.substring( , str.length() - end.length());
}
{
maxY - minY;
maxX - minX;
lengthY / ( )height;
( )lengthX / ( )width;
[] values = [width];
Arrays.fill(values, - );
;
( ; i < width; ++i) {
;
;
( maxX - (lengthX - ( )(colAggLength * ( )i)); historyIndex < historyLength && timestampFunc.applyAsLong(historyIndex) < nextAggTimestamp; ++historyIndex) {
total += valueFunc.applyAsDouble(historyIndex);
++count;
}
(count != ) {
values[i] = total / ( )count;
} (i > ) {
values[i] = values[i - ];
}
}
- ;
( values.length - ; i >= ; --i) {
(values[i] != - ) {
last = values[i];
} (last != - ) {
values[i] = last;
}
}
;
String[] labels = [height];
( ; row < height; ++row) {
minY + lengthY - rowAggLength * ( )row;
(String)labelFormatFunc.apply(rowMaxValue);
labels[row] = label;
label.length();
(length > yLabelWidth) {
yLabelWidth = length;
}
}
.repeat(yLabelWidth);
var10000 + + .repeat(width + );
sb.append(bar).append( );
( ; row < height; ++row) {
sb.append( .repeat(Math.max( , yLabelWidth - labels[row].length()))).append(labels[row]).append( );
minY + lengthY - rowAggLength * ( )(row + );
( ; col < width; ++col) {
values[col] - rowMinValue;
(!(colRowValue <= ) && !(colRowValue > rowAggLength)) {
colRowValue / rowAggLength;
( )Math.round(valuePercent * ( )(GRAPH_CHARS.length - ));
sb.append(GRAPH_CHARS[Math.max( , charIndex)]);
} {
sb.append( );
}
}
sb.append( );
}
sb.append(bar).append( );
sb.append( );
}
{
INDEX_DIFFERENCE,
EQUALS,
CASE_INSENSITIVE;
{
}
}
}
com/hypixel/hytale/common/util/SystemUtil.java
package com.hypixel.hytale.common.util;
import javax.annotation.Nonnull;
public class SystemUtil {
public static final SystemType TYPE = getSystemType();
public SystemUtil () {
}
@Nonnull
private static SystemType getSystemType () {
String osName = System.getProperty("os.name" );
if (osName.startsWith("Windows" )) {
return SystemUtil.SystemType.WINDOWS;
} else if (osName.startsWith("Mac OS X" )) {
return SystemUtil.SystemType.MACOS;
} else if (osName.startsWith("Linux" )) {
return SystemUtil.SystemType.LINUX;
} else {
return osName.startsWith("LINUX" ) ? SystemUtil.SystemType.LINUX : SystemUtil.SystemType.OTHER;
}
}
public static enum SystemType {
WINDOWS,
MACOS,
LINUX,
OTHER;
private SystemType () {
}
}
}
com/hypixel/hytale/common/util/TimeUtil.java
package com.hypixel.hytale.common.util;
import java.time.DateTimeException;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import javax.annotation.Nonnull;
public class TimeUtil {
public TimeUtil () {
}
public static int compareDifference (@Nonnull Instant from, @Nonnull Instant to, @Nonnull Duration duration) {
if (from.equals(Instant.MIN) && !to.equals(Instant.MIN) && !duration.isZero()) {
return 1 ;
} else {
try {
long diff = from.until(to, ChronoUnit.NANOS);
return Long.compare(diff, duration.toNanos());
} catch (ArithmeticException | DateTimeException var13) {
long seconds = from.until(to, ChronoUnit.SECONDS);
long nanos;
try {
nanos = to.getLong(ChronoField.NANO_OF_SECOND) - from.getLong(ChronoField.NANO_OF_SECOND);
if (seconds > 0L && nanos < 0L ) {
++seconds;
} else if (seconds < && nanos > ) {
--seconds;
}
} (DateTimeException var12) {
nanos = ;
}
duration.getSeconds();
duration.getNano();
Long.compare(seconds, durSeconds);
(res == ) {
res = Integer.compare(( )nanos, durNanos);
}
res;
}
}
}
}
com/hypixel/hytale/common/util/java/ManifestUtil.java
package com.hypixel.hytale.common.util.java;
import com.hypixel.hytale.common.semver.Semver;
import com.hypixel.hytale.function.supplier.CachedSupplier;
import com.hypixel.hytale.function.supplier.SupplierUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Objects;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.logging.Level;
import javax.annotation.Nullable;
public class ManifestUtil {
public static final String VENDOR_ID_PROPERTY = "Implementation-Vendor-Id" ;
public static final String VERSION_PROPERTY = "Implementation-Version" ;
public static final String REVISION_ID_PROPERTY = "Implementation-Revision-Id" ;
public static final String PATCHLINE_PROPERTY = "Implementation-Patchline" ;
private CachedSupplier<Manifest> MANIFEST = SupplierUtil.<Manifest>cache(() -> {
{
ManifestUtil.class.getClassLoader();
Enumeration<URL> enumeration = cl.getResources( );
;
(enumeration.hasMoreElements()) {
(URL)enumeration.nextElement();
url.openStream();
Manifest possible;
{
possible = (is);
} (Throwable var9) {
(is != ) {
{
is.close();
} (Throwable x2) {
var9.addSuppressed(x2);
}
}
var9;
}
(is != ) {
is.close();
}
possible.getMainAttributes();
mainAttributes.getValue( );
(vendorId != && vendorId.equals( )) {
theManifest = possible;
;
}
}
theManifest;
} (Throwable t) {
HytaleLogger.getLogger().at(Level.WARNING).log( , t);
;
}
});
CachedSupplier<String> IMPLEMENTATION_VERSION = SupplierUtil.<String>cache(() -> {
{
MANIFEST.get();
localManifest == ? : (String)Objects.requireNonNull(localManifest.getMainAttributes().getValue( ), );
} (Throwable t) {
HytaleLogger.getLogger().at(Level.WARNING).log( , t);
;
}
});
CachedSupplier<String> IMPLEMENTATION_REVISION_ID = SupplierUtil.<String>cache(() -> {
{
MANIFEST.get();
localManifest == ? : (String)Objects.requireNonNull(localManifest.getMainAttributes().getValue( ), );
} (Throwable t) {
HytaleLogger.getLogger().at(Level.WARNING).log( , t);
;
}
});
CachedSupplier<String> IMPLEMENTATION_PATCHLINE = SupplierUtil.<String>cache(() -> {
{
MANIFEST.get();
(localManifest == ) {
;
} {
localManifest.getMainAttributes().getValue( );
value != && !value.isEmpty() ? value : ;
}
} (Throwable t) {
HytaleLogger.getLogger().at(Level.WARNING).log( , t);
;
}
});
CachedSupplier<Semver> VERSION = SupplierUtil.<Semver>cache(() -> {
IMPLEMENTATION_VERSION.get();
.equals(version) ? : Semver.fromString(version);
});
{
}
{
MANIFEST.get() != ;
}
Manifest {
MANIFEST.get();
}
String {
IMPLEMENTATION_VERSION.get();
}
Semver {
VERSION.get();
}
String {
IMPLEMENTATION_REVISION_ID.get();
}
String {
IMPLEMENTATION_PATCHLINE.get();
}
}